mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-28 04:04:57 +01:00
Merge branch 'develop' into 'develop'
Display page labels in the index See merge request pwmt/zathura!96
This commit is contained in:
commit
f98f8ee659
4 changed files with 27 additions and 9 deletions
|
@ -363,7 +363,7 @@ cb_index_row_activated(GtkTreeView* 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, 2, &index_element, -1);
|
||||
gtk_tree_model_get(model, &iter, 3, &index_element, -1);
|
||||
|
||||
if (index_element == NULL) {
|
||||
return;
|
||||
|
|
|
@ -1203,7 +1203,7 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
goto error_free;
|
||||
}
|
||||
|
||||
model = GTK_TREE_MODEL(gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER));
|
||||
model = GTK_TREE_MODEL(gtk_tree_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER));
|
||||
if (model == NULL) {
|
||||
goto error_free;
|
||||
}
|
||||
|
@ -1228,12 +1228,13 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
goto error_free;
|
||||
}
|
||||
|
||||
document_index_build(model, NULL, document_index);
|
||||
document_index_build(session, model, NULL, document_index);
|
||||
girara_node_free(document_index);
|
||||
|
||||
/* 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", renderer2, "text", 1, NULL);
|
||||
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW (treeview), 2, "(alt)", renderer2, "text", 2, NULL);
|
||||
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
|
||||
g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||
|
|
|
@ -70,7 +70,9 @@ index_element_free(void* data, GObject* UNUSED(object))
|
|||
zathura_index_element_free(element);
|
||||
}
|
||||
|
||||
void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree) {
|
||||
void document_index_build(girara_session_t* session, GtkTreeModel* model,
|
||||
GtkTreeIter* parent, girara_tree_node_t* tree)
|
||||
{
|
||||
girara_list_t* list = girara_node_get_children(tree);
|
||||
|
||||
for (size_t idx = 0; idx != girara_list_size(list); ++idx) {
|
||||
|
@ -80,8 +82,20 @@ void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_
|
|||
zathura_link_target_t target = zathura_link_get_target(index_element->link);
|
||||
|
||||
gchar* description = NULL;
|
||||
gchar* description2 = NULL;
|
||||
|
||||
if (type == ZATHURA_LINK_GOTO_DEST) {
|
||||
description = g_strdup_printf("Page %d", target.page_number + 1);
|
||||
zathura_t *zathura = session->global.data;
|
||||
zathura_page_t *page = zathura_document_get_page(zathura->document, target.page_number);
|
||||
char *label = zathura_page_get_label(page, NULL);
|
||||
|
||||
if (label != NULL) {
|
||||
description = g_strdup_printf("Page %s", label);
|
||||
description2 = g_strdup_printf("(%d)", target.page_number + 1);
|
||||
g_free(label);
|
||||
} else {
|
||||
description = g_strdup_printf("Page %d", target.page_number + 1);
|
||||
}
|
||||
} else {
|
||||
description = g_strdup(target.value);
|
||||
}
|
||||
|
@ -89,13 +103,15 @@ void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_
|
|||
GtkTreeIter tree_iter;
|
||||
gtk_tree_store_append(GTK_TREE_STORE(model), &tree_iter, parent);
|
||||
gchar* markup = g_markup_escape_text(index_element->title, -1);
|
||||
gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, markup, 1, description, 2, index_element, -1);
|
||||
gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, markup,
|
||||
1, description, 2, description2, 3, index_element, -1);
|
||||
g_free(markup);
|
||||
g_object_weak_ref(G_OBJECT(model), index_element_free, index_element);
|
||||
g_free(description);
|
||||
g_free(description2);
|
||||
g_object_weak_ref(G_OBJECT(model), index_element_free, index_element);
|
||||
|
||||
if (girara_node_get_num_children(node) > 0) {
|
||||
document_index_build(model, &tree_iter, node);
|
||||
document_index_build(session, model, &tree_iter, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,12 @@ bool file_valid_extension(zathura_t* zathura, const char* path);
|
|||
* Generates the document index based upon the list retrieved from the document
|
||||
* object.
|
||||
*
|
||||
* @param session The session
|
||||
* @param model The tree model
|
||||
* @param parent The tree iterator parent
|
||||
* @param tree The Tree iterator
|
||||
*/
|
||||
void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree);
|
||||
void document_index_build(girara_session_t* session, GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree);
|
||||
|
||||
/**
|
||||
* Rotate a rectangle by 0, 90, 180 or 270 degree
|
||||
|
|
Loading…
Reference in a new issue