Implement G and gg for index mode

Closes: #52

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2014-01-10 17:45:36 +01:00
parent dbe5f7429a
commit bacdc19d23
2 changed files with 16 additions and 0 deletions

View file

@ -354,6 +354,9 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_navigate_index, INDEX, EXPAND, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_navigate_index, INDEX, EXPAND, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_navigate_index, INDEX, SELECT, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(gsession, 0, 0, "gg", sc_navigate_index, INDEX, TOP, NULL);
girara_shortcut_add(gsession, 0, 0, "G", sc_navigate_index, INDEX, BOTTOM, NULL);
/* Presentation mode */ /* Presentation mode */
girara_shortcut_add(gsession, 0, GDK_KEY_J, NULL, sc_navigate, PRESENTATION, NEXT, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_J, NULL, sc_navigate, PRESENTATION, NEXT, NULL);

View file

@ -983,6 +983,19 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
gboolean is_valid_path = TRUE; gboolean is_valid_path = TRUE;
switch(argument->n) { switch(argument->n) {
case TOP:
gtk_tree_path_free(path);
path = gtk_tree_path_new_first();
break;
case BOTTOM:
gtk_tree_path_free(path);
path = gtk_tree_path_new_from_indices(gtk_tree_model_iter_n_children(model, NULL) - 1, -1);
gtk_tree_model_get_iter(model, &iter, path);
while (gtk_tree_model_iter_has_child(model, &iter) == TRUE &&
gtk_tree_view_row_expanded(tree_view, path) == TRUE) {
gtk_tree_path_append_index(path, gtk_tree_model_iter_n_children(model, &iter) - 1);
}
break;
case UP: case UP:
if (gtk_tree_path_prev(path) == FALSE) { if (gtk_tree_path_prev(path) == FALSE) {
/* For some reason gtk_tree_path_up returns TRUE although we're not /* For some reason gtk_tree_path_up returns TRUE although we're not