Implement TOGGLE for sc_navigate_index

Closes: #396

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2014-01-10 14:52:51 +01:00
parent f41d372f75
commit f504da0dd1
3 changed files with 65 additions and 10 deletions

View file

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

View file

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

View file

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