diff --git a/config.c b/config.c index c11237b..d25a386 100644 --- a/config.c +++ b/config.c @@ -452,6 +452,7 @@ config_load_default(zathura_t* zathura) girara_argument_mapping_add(gsession, "expand", EXPAND); girara_argument_mapping_add(gsession, "expand-all", EXPAND_ALL); girara_argument_mapping_add(gsession, "select", SELECT); + girara_argument_mapping_add(gsession, "toggle", TOGGLE); girara_argument_mapping_add(gsession, "forward", FORWARD); girara_argument_mapping_add(gsession, "full-down", FULL_DOWN); girara_argument_mapping_add(gsession, "full-up", FULL_UP); diff --git a/shortcuts.c b/shortcuts.c index 23f0a59..103ac09 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -989,7 +989,7 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument, * moving anywhere. */ is_valid_path = gtk_tree_path_up(path) && (gtk_tree_path_get_depth(path) > 0); } else { /* row above */ - while(gtk_tree_view_row_expanded(tree_view, path)) { + while (gtk_tree_view_row_expanded(tree_view, path)) { gtk_tree_model_get_iter(model, &iter, path); /* select last child */ gtk_tree_model_iter_nth_child(model, &child_iter, &iter, @@ -1035,13 +1035,23 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument, path = gtk_tree_path_new_first(); gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE); break; + case TOGGLE: + gtk_tree_model_get_iter(model, &iter, path); + if (gtk_tree_model_iter_has_child(model, &iter) == TRUE) { + if (gtk_tree_view_row_expanded(tree_view, path) == TRUE) { + gtk_tree_view_collapse_row(tree_view, path); + } else { + gtk_tree_view_expand_row(tree_view, path, FALSE); + } + break; + } case SELECT: cb_index_row_activated(tree_view, path, NULL, zathura); gtk_tree_path_free(path); return false; } - if (is_valid_path) { + if (is_valid_path == TRUE) { gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE); } diff --git a/zathura.h b/zathura.h index 8436db1..57431f3 100644 --- a/zathura.h +++ b/zathura.h @@ -10,14 +10,58 @@ #include "macros.h" #include "types.h" -enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT, - DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP, - PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD, - BACKWARD, CONTINUOUS, DELETE_LAST, EXPAND, EXPAND_ALL, COLLAPSE_ALL, COLLAPSE, - SELECT, GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, - FULL_DOWN, HALF_LEFT, HALF_RIGHT, FULL_LEFT, FULL_RIGHT, NEXT_CHAR, - PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, ROTATE_CW, ROTATE_CCW, - PAGE_BOTTOM, PAGE_TOP }; +enum { + NEXT, + PREVIOUS, + LEFT, + RIGHT, + UP, + DOWN, + BOTTOM, + TOP, + HIDE, + HIGHLIGHT, + DELETE_LAST_WORD, + DELETE_LAST_CHAR, + DEFAULT, + ERROR, + WARNING, + NEXT_GROUP, + PREVIOUS_GROUP, + ZOOM_IN, + ZOOM_OUT, + ZOOM_ORIGINAL, + ZOOM_SPECIFIC, + FORWARD, + BACKWARD, + CONTINUOUS, + DELETE_LAST, + EXPAND, + EXPAND_ALL, + COLLAPSE_ALL, + COLLAPSE, + TOGGLE, + SELECT, + GOTO_DEFAULT, + GOTO_LABELS, + GOTO_OFFSET, + HALF_UP, + HALF_DOWN, + FULL_UP, + FULL_DOWN, + HALF_LEFT, + HALF_RIGHT, + FULL_LEFT, + FULL_RIGHT, + NEXT_CHAR, + PREVIOUS_CHAR, + DELETE_TO_LINE_START, + APPEND_FILEPATH, + ROTATE_CW, + ROTATE_CCW, + PAGE_BOTTOM, + PAGE_TOP +}; /* unspecified page number */ enum {