- Add new_packet_list_set_sel_browse()

- When scrolling to the end don't select the row.

svn path=/trunk/; revision=30065
This commit is contained in:
Anders Broman 2009-09-22 12:39:16 +00:00
parent b8af7c77c8
commit 08525e79d7
3 changed files with 65 additions and 11 deletions

View File

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

View File

@ -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__ */

View File

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