aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2009-09-22 12:39:16 +0000
committerAnders Broman <anders.broman@ericsson.com>2009-09-22 12:39:16 +0000
commit08525e79d7cd7fee1c5936e9d9630d9d57ee4cdb (patch)
tree01f1828ba07bf2399d785a0d4fa7f8d13b161281
parentb8af7c77c8d07ff4b9e3fed2c6c7eecd259c3795 (diff)
- Add new_packet_list_set_sel_browse()
- When scrolling to the end don't select the row. svn path=/trunk/; revision=30065
-rw-r--r--gtk/new_packet_list.c60
-rw-r--r--gtk/new_packet_list.h8
-rw-r--r--gtk/prefs_gui.c8
3 files changed, 65 insertions, 11 deletions
diff --git a/gtk/new_packet_list.c b/gtk/new_packet_list.c
index 0dab1b2789..9a1733b4d0 100644
--- a/gtk/new_packet_list.c
+++ b/gtk/new_packet_list.c
@@ -83,6 +83,8 @@ static void show_cell_data_func(GtkTreeViewColumn *col,
gpointer data);
static guint row_number_from_iter(GtkTreeIter *iter);
+void new_packet_list_set_sel_browse(gboolean val, gboolean force_set);
+
GtkWidget *
new_packet_list_create(void)
{
@@ -92,6 +94,8 @@ new_packet_list_create(void)
view = create_view_and_model();
+ new_packet_list_set_sel_browse(prefs.gui_plist_sel_browse, FALSE);
+
gtk_container_add(GTK_CONTAINER(scrollwin), view);
g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY, view);
@@ -450,16 +454,12 @@ new_packet_list_moveto_end(void)
path = gtk_tree_model_get_path(model, &iter);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
- if (!gtk_tree_selection_path_is_selected(selection, path)) {
- /* XXX - this doesn't seem to work, i.e. gtk_tree_selection_path_is_selected() is always false? */
- gtk_tree_selection_select_path(selection, path);
- gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(packetlist->view),
- path,
- NULL,
- TRUE, /* use_align */
- 0.5, /* row_align determines where the row is placed, 0.5 means center */
- 0); /* The horizontal alignment of the column */
- }
+ gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(packetlist->view),
+ path,
+ NULL,
+ TRUE, /* use_align */
+ 0.5, /* row_align determines where the row is placed, 0.5 means center */
+ 0); /* The horizontal alignment of the column */
gtk_tree_path_free(path);
}
@@ -765,6 +765,46 @@ void new_packet_list_unmark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_)
mark_all_frames(FALSE);
}
+/* Set the selection mode of the packet list window. */
+void
+new_packet_list_set_sel_browse(gboolean val, gboolean force_set)
+{
+ GtkSelectionMode new_mode;
+ /* initialize with a mode we don't use, so that the mode == new_mode
+ * test will fail the first time */
+ static GtkSelectionMode mode = GTK_SELECTION_MULTIPLE;
+
+ /* Yeah, GTK uses "browse" in the case where we do not, but oh well. I
+ * think "browse" in Wireshark makes more sense than "SINGLE" in GTK+ */
+ new_mode = val ? GTK_SELECTION_SINGLE : GTK_SELECTION_BROWSE;
+
+ if ((mode == new_mode) && !force_set) {
+ /*
+ * The mode isn't changing, so don't do anything.
+ * In particular, don't gratuitiously unselect the
+ * current packet.
+ *
+ * XXX - Copied code from "old" packet list
+ * - I don't know if the comment below is still true...
+ * XXX - why do we have to unselect the current packet
+ * ourselves? The documentation for the GtkCList at
+ *
+ * http://developer.gnome.org/doc/API/gtk/gtkclist.html
+ *
+ * says "Note that setting the widget's selection mode to
+ * one of GTK_SELECTION_BROWSE or GTK_SELECTION_SINGLE will
+ * cause all the items in the GtkCList to become deselected."
+ */
+ return;
+ }
+
+ if (cfile.finfo_selected)
+ cf_unselect_field(&cfile);
+
+ mode = new_mode;
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view)), mode);
+}
+
void
new_packet_list_set_font(PangoFontDescription *font)
{
diff --git a/gtk/new_packet_list.h b/gtk/new_packet_list.h
index 4ae1912359..a716f69719 100644
--- a/gtk/new_packet_list.h
+++ b/gtk/new_packet_list.h
@@ -73,6 +73,14 @@ extern void new_packet_list_recent_write_all(FILE *rf);
GtkWidget * new_packet_list_get_widget(void);
void new_packet_list_colorize_packets(void);
+/** Set the selection mode of the packet list window.
+ *
+ * @param val TRUE for GTK_SELECTION_SINGLE, FALSE for GTK_SELECTION_BROWSE
+ * @param force_set TRUE to force setting of the selection mode even if it
+ * was already set (used within packet_list_recreate).
+ */
+extern void new_packet_list_set_sel_browse(gboolean val, gboolean force_set);
+
#endif /* NEW_PACKET_LIST */
#endif /* __NEW_PACKET_LIST_H__ */
diff --git a/gtk/prefs_gui.c b/gtk/prefs_gui.c
index f6ccf9b615..9fe35ad53b 100644
--- a/gtk/prefs_gui.c
+++ b/gtk/prefs_gui.c
@@ -42,7 +42,11 @@
#include "gtk/gui_utils.h"
#include "gtk/dlg_utils.h"
#include "gtk/main.h"
+#ifdef NEW_PACKET_LIST
+#include "gtk/new_packet_list.h"
+#else
#include "gtk/main_packet_list.h"
+#endif
#include "gtk/main_proto_draw.h"
#include "gtk/main_toolbar.h"
#include "gtk/font_utils.h"
@@ -502,7 +506,9 @@ gui_prefs_apply(GtkWidget *w _U_ , gboolean redissect)
toolbar_redraw_all();
set_scrollbar_placement_all();
-#ifndef NEW_PACKET_LIST
+#ifdef NEW_PACKET_LIST
+ new_packet_list_set_sel_browse(prefs.gui_plist_sel_browse, FALSE);
+#else
packet_list_set_sel_browse(prefs.gui_plist_sel_browse, FALSE);
#endif
set_ptree_sel_browse_all(prefs.gui_ptree_sel_browse);