aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/gui_utils.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-10-23 14:24:17 +0000
committerMichael Mann <mmann78@netscape.net>2013-10-23 14:24:17 +0000
commitbb25fad9de068caf872f883c55fdbda988b3b899 (patch)
tree8614d8bb9ab5645483b7e97bb56706837750b354 /ui/gtk/gui_utils.c
parentf4306bb0cdd397b2054a705521dfcf121c069c9c (diff)
Add the ability to collapse subtrees with Shift+Left + additional menu items. Bug 9008 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9008).
Currently this is only for GTK, but allows users to test it to see if its worth adding to Qt (my personal opinion is yes). From Jiří Engelthaler svn path=/trunk/; revision=52790
Diffstat (limited to 'ui/gtk/gui_utils.c')
-rw-r--r--ui/gtk/gui_utils.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/ui/gtk/gui_utils.c b/ui/gtk/gui_utils.c
index 09b726617d..c08ba8a9a4 100644
--- a/ui/gtk/gui_utils.c
+++ b/ui/gtk/gui_utils.c
@@ -1136,6 +1136,47 @@ set_window_title(GtkWidget *win,
}
/*
+ * Collapse row and his children
+ */
+static void
+tree_collapse_row_with_children(GtkTreeView *tree_view, GtkTreeModel *model, GtkTreePath *path,
+ GtkTreeIter *iter)
+{
+ GtkTreeIter child;
+
+ if (gtk_tree_view_row_expanded(tree_view, path)) {
+ if (gtk_tree_model_iter_children(model, &child, iter)) {
+ gtk_tree_path_down(path);
+
+ do {
+
+ if (gtk_tree_view_row_expanded(tree_view, path)) {
+ tree_collapse_row_with_children(tree_view, model, path, &child);
+ }
+
+ gtk_tree_path_next(path);
+ } while (gtk_tree_model_iter_next(model, &child));
+
+ gtk_tree_path_up(path);
+
+ gtk_tree_view_collapse_row(tree_view, path);
+ }
+ }
+}
+
+void
+tree_collapse_path_all(GtkTreeView *tree_view, GtkTreePath *path)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+
+ model = gtk_tree_view_get_model(tree_view);
+ gtk_tree_model_get_iter(model, &iter, path);
+
+ tree_collapse_row_with_children(tree_view, model, path, &iter);
+}
+
+/*
* This callback is invoked when keyboard focus is within either
* the packetlist view or the detail view. The keystrokes processed
* within this callback are attempting to modify the detail view.
@@ -1165,11 +1206,11 @@ tree_view_key_pressed_cb(GtkWidget *tree,
GdkEventKey *event,
gpointer user_data _U_)
{
- GtkTreeSelection* selection;
+ GtkTreeSelection *selection;
GtkTreeIter iter;
GtkTreeIter parent;
- GtkTreeModel* model;
- GtkTreePath* path;
+ GtkTreeModel *model;
+ GtkTreePath *path;
gboolean expanded, expandable;
int rc = FALSE;
@@ -1195,7 +1236,12 @@ tree_view_key_pressed_cb(GtkWidget *tree,
case GDK_Left:
if(expanded) {
/* Subtree is expanded. Collapse it. */
- gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
+ if (event->state & GDK_SHIFT_MASK)
+ {
+ tree_collapse_row_with_children(GTK_TREE_VIEW(tree), model, path, &iter);
+ }
+ else
+ gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
rc = TRUE;
break;
}