display page in index

This commit is contained in:
Sebastian Ramacher 2011-09-29 17:28:09 +02:00
parent 3d0abd5292
commit 1e18d7f3ea
3 changed files with 13 additions and 3 deletions

View File

@ -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;

View File

@ -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);

10
utils.c
View File

@ -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);