Commit a94cc260 authored by Moritz Lipp's avatar Moritz Lipp
Browse files

Implemented cb_index_row_activated

parent 225bc75b
......@@ -89,3 +89,36 @@ cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), girara_setting
page_view_set_mode(zathura, pages_per_row);
}
void
cb_index_row_activated(GtkTreeModel* tree_view, GtkTreePath* path,
GtkTreeViewColumn* column, zathura_t* zathura)
{
if (tree_view == NULL || zathura == NULL || zathura->ui.session == NULL) {
return;
}
GtkTreeModel *model;
GtkTreeIter iter;
g_object_get(tree_view, "model", &model, NULL);
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);
if (index_element == NULL) {
return;
}
if (index_element->type == ZATHURA_LINK_TO_PAGE) {
page_set(zathura, index_element->target.page_number);
sc_toggle_index(zathura->ui.session, NULL, 0);
} else if (index_element->type == ZATHURA_LINK_EXTERNAL) {
// TODO
}
}
g_object_unref(model);
}
......@@ -6,6 +6,8 @@
#include <gtk/gtk.h>
#include <girara.h>
#include "zathura.h"
/**
* Quits the current zathura session
*
......@@ -39,4 +41,15 @@ void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
*/
void cb_pages_per_row_value_changed(girara_session_t* session, girara_setting_t* setting);
/**
* Called when an index element is activated (e.g.: double click)
*
* @param tree_view Tree view
* @param path Path
* @param column Column
* @param zathura Zathura session
*/
void cb_index_row_activated(GtkTreeModel* tree_view, GtkTreePath* path,
GtkTreeViewColumn* column, zathura_t* zathura);
#endif // CALLBACKS_H
......@@ -231,13 +231,12 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
}
bool
sc_toggle_index(girara_session_t* session, girara_argument_t* argument, unsigned
int UNUSED(t))
sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
unsigned int UNUSED(t))
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
girara_tree_node_t* document_index = NULL;
......@@ -289,7 +288,7 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* argument, unsigned
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);
gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), gtk_tree_path_new_first(), NULL, FALSE);
/*g_signal_connect(G_OBJECT(treeview), "row-activated", G_CALLBACK(cb_index_row_activated), NULL); TODO*/
g_signal_connect(G_OBJECT(treeview), "row-activated", G_CALLBACK(cb_index_row_activated), zathura);
gtk_container_add(GTK_CONTAINER(zathura->ui.index), treeview);
gtk_widget_show(treeview);
......@@ -298,9 +297,11 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* argument, unsigned
if (gtk_widget_get_visible(GTK_WIDGET(zathura->ui.index))) {
girara_set_view(session, zathura->ui.page_view);
gtk_widget_hide(GTK_WIDGET(zathura->ui.index));
girara_mode_set(zathura->ui.session, zathura->modes.normal);
} else {
girara_set_view(session, zathura->ui.index);
gtk_widget_show(GTK_WIDGET(zathura->ui.index));
girara_mode_set(zathura->ui.session, zathura->modes.index);
}
return false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment