From 1e18d7f3eaaafe30e381aa7c89320e00ef76e297 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 29 Sep 2011 17:28:09 +0200 Subject: [PATCH] display page in index --- callbacks.c | 2 +- shortcuts.c | 4 +++- utils.c | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/callbacks.c b/callbacks.c index d7200e5..a0d7dec 100644 --- a/callbacks.c +++ b/callbacks.c @@ -106,7 +106,7 @@ cb_index_row_activated(GtkTreeModel* tree_view, GtkTreePath* path, if(gtk_tree_model_get_iter(model, &iter, path)) { zathura_index_element_t* index_element; - gtk_tree_model_get(model, &iter, 1, &index_element, -1); + gtk_tree_model_get(model, &iter, 2, &index_element, -1); if (index_element == NULL) { return; diff --git a/shortcuts.c b/shortcuts.c index eb398eb..8c2e0cc 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -262,7 +262,7 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument), goto error_free; } - model = GTK_TREE_MODEL(gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER)); + model = GTK_TREE_MODEL(gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER)); if (model == NULL) { goto error_free; } @@ -284,6 +284,8 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument), /* setup widget */ gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW (treeview), 0, "Title", renderer, "markup", 0, NULL); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW (treeview), 1, "Target", renderer, "text", 1, NULL); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL); g_object_set(G_OBJECT(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), 0)), "expand", TRUE, NULL); diff --git a/utils.c b/utils.c index ed0595d..790952e 100644 --- a/utils.c +++ b/utils.c @@ -156,10 +156,18 @@ document_index_build(GtkTreeModel* model, GtkTreeIter* parent, GIRARA_LIST_FOREACH(list, girara_tree_node_t*, iter, node) zathura_index_element_t* index_element = (zathura_index_element_t*)girara_node_get_data(node); + gchar* description = NULL; + if (index_element->type == ZATHURA_LINK_TO_PAGE) { + description = g_strdup_printf("Page %d", index_element->target.page_number); + } else { + description = g_strdup(index_element->target.uri); + } + GtkTreeIter tree_iter; gtk_tree_store_append(GTK_TREE_STORE(model), &tree_iter, parent); - gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, index_element->title, 1, index_element, -1); + gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, index_element->title, 1, description, 2, index_element, -1); g_object_weak_ref(G_OBJECT(model), (GWeakNotify) zathura_index_element_free, index_element); + g_free(description); if (girara_node_get_num_children(node) > 0) { document_index_build(model, &tree_iter, node);