aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-01-20 20:05:18 +0000
committerGuy Harris <guy@alum.mit.edu>2002-01-20 20:05:18 +0000
commita0d7e9051920dea67c6558c65b9529f7d8609b85 (patch)
tree7f2d96a8b7b1f8095f1bcf9ad6ee3b6201af67ec
parente2e7d2961e77ac7f5f5c7690e9553ca3443740f1 (diff)
Make the blurbs for protocol preference items into tooltips. (This also
lets us add tooltips to other preference items whose widgets are created with the "create_preference_XXX()" routines - just pass in a tooltip text string rather than a null pointer.) svn path=/trunk/; revision=4577
-rw-r--r--gtk/capture_prefs.c11
-rw-r--r--gtk/gui_prefs.c18
-rw-r--r--gtk/nameres_prefs.c8
-rw-r--r--gtk/prefs_dlg.c101
-rw-r--r--gtk/prefs_dlg.h11
-rw-r--r--gtk/print_prefs.c9
6 files changed, 110 insertions, 48 deletions
diff --git a/gtk/capture_prefs.c b/gtk/capture_prefs.c
index 4ae81e22b3..fdf6863c48 100644
--- a/gtk/capture_prefs.c
+++ b/gtk/capture_prefs.c
@@ -1,7 +1,7 @@
/* capture_prefs.c
* Dialog box for capture preferences
*
- * $Id: capture_prefs.c,v 1.7 2002/01/13 20:35:11 guy Exp $
+ * $Id: capture_prefs.c,v 1.8 2002/01/20 20:05:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -95,18 +95,21 @@ capture_prefs_show(void)
/* Promiscuous mode */
promisc_cb = create_preference_check_button(main_tb, 1,
- "Capture packets in promiscuous mode:", prefs.capture_prom_mode);
+ "Capture packets in promiscuous mode:", NULL,
+ prefs.capture_prom_mode);
gtk_object_set_data(GTK_OBJECT(main_vb), PROM_MODE_KEY, promisc_cb);
/* Real-time capture */
sync_cb = create_preference_check_button(main_tb, 2,
- "Update list of packets in real time:", prefs.capture_real_time);
+ "Update list of packets in real time:", NULL,
+ prefs.capture_real_time);
gtk_object_set_data(GTK_OBJECT(main_vb), CAPTURE_REAL_TIME_KEY,
sync_cb);
/* Auto-scroll real-time capture */
auto_scroll_cb = create_preference_check_button(main_tb, 3,
- "Automatic scrolling in live capture:", prefs.capture_auto_scroll);
+ "Automatic scrolling in live capture:", NULL,
+ prefs.capture_auto_scroll);
gtk_object_set_data(GTK_OBJECT(main_vb), AUTO_SCROLL_KEY,
auto_scroll_cb);
diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c
index 2be9382f1b..875161a856 100644
--- a/gtk/gui_prefs.c
+++ b/gtk/gui_prefs.c
@@ -1,7 +1,7 @@
/* gui_prefs.c
* Dialog box for GUI preferences
*
- * $Id: gui_prefs.c,v 1.32 2002/01/13 20:35:11 guy Exp $
+ * $Id: gui_prefs.c,v 1.33 2002/01/20 20:05:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -155,54 +155,54 @@ gui_prefs_show(void)
/* Scrollbar placement */
scrollbar_om = create_preference_option_menu(main_tb, 0,
- "Vertical scrollbar placement:", scrollbar_placement_vals,
+ "Vertical scrollbar placement:", NULL, scrollbar_placement_vals,
prefs.gui_scrollbar_on_right);
gtk_object_set_data(GTK_OBJECT(main_vb), SCROLLBAR_PLACEMENT_KEY,
scrollbar_om);
/* Packet list selection browseable */
plist_browse_om = create_preference_option_menu(main_tb, 1,
- "Packet list mouse behavior:", selection_mode_vals,
+ "Packet list mouse behavior:", NULL, selection_mode_vals,
prefs.gui_plist_sel_browse);
gtk_object_set_data(GTK_OBJECT(main_vb), PLIST_SEL_BROWSE_KEY,
plist_browse_om);
/* Proto tree selection browseable */
ptree_browse_om = create_preference_option_menu(main_tb, 2,
- "Protocol tree mouse behavior:", selection_mode_vals,
+ "Protocol tree mouse behavior:", NULL, selection_mode_vals,
prefs.gui_ptree_sel_browse);
gtk_object_set_data(GTK_OBJECT(main_vb), PTREE_SEL_BROWSE_KEY,
ptree_browse_om);
/* Tree line style */
line_style_om = create_preference_option_menu(main_tb, 3,
- "Tree line style:", line_style_vals,
+ "Tree line style:", NULL, line_style_vals,
prefs.gui_ptree_line_style);
gtk_object_set_data(GTK_OBJECT(main_vb), PTREE_LINE_STYLE_KEY,
line_style_om);
/* Tree expander style */
expander_style_om = create_preference_option_menu(main_tb, 4,
- "Tree expander style:", expander_style_vals,
+ "Tree expander style:", NULL, expander_style_vals,
prefs.gui_ptree_expander_style);
gtk_object_set_data(GTK_OBJECT(main_vb), PTREE_EXPANDER_STYLE_KEY,
expander_style_om);
/* Hex Dump highlight style */
highlight_style_om = create_preference_option_menu(main_tb, 5,
- "Hex display highlight style:", highlight_style_vals,
+ "Hex display highlight style:", NULL, highlight_style_vals,
prefs.gui_hex_dump_highlight_style);
gtk_object_set_data(GTK_OBJECT(main_vb), HEX_DUMP_HIGHLIGHT_STYLE_KEY,
highlight_style_om);
/* Geometry prefs */
save_position_cb = create_preference_check_button(main_tb,
- 6, "Save window position:", prefs.gui_geometry_save_position);
+ 6, "Save window position:", NULL, prefs.gui_geometry_save_position);
gtk_object_set_data(GTK_OBJECT(main_vb), GEOMETRY_POSITION_KEY,
save_position_cb);
save_size_cb = create_preference_check_button(main_tb,
- 7, "Save window size:", prefs.gui_geometry_save_size);
+ 7, "Save window size:", NULL, prefs.gui_geometry_save_size);
gtk_object_set_data(GTK_OBJECT(main_vb), GEOMETRY_SIZE_KEY,
save_size_cb);
diff --git a/gtk/nameres_prefs.c b/gtk/nameres_prefs.c
index bd2c22e8fd..08d10587fd 100644
--- a/gtk/nameres_prefs.c
+++ b/gtk/nameres_prefs.c
@@ -1,7 +1,7 @@
/* nameres_prefs.c
* Dialog box for name resolution preferences
*
- * $Id: nameres_prefs.c,v 1.1 2002/01/13 20:35:12 guy Exp $
+ * $Id: nameres_prefs.c,v 1.2 2002/01/20 20:05:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -73,19 +73,19 @@ nameres_prefs_show(void)
/* Resolve MAC addresses */
m_resolv_cb = create_preference_check_button(main_tb, 0,
- "Enable MAC name resolution:",
+ "Enable MAC name resolution:", NULL,
prefs.name_resolve & RESOLV_MAC);
gtk_object_set_data(GTK_OBJECT(main_vb), M_RESOLVE_KEY, m_resolv_cb);
/* Resolve network addresses */
n_resolv_cb = create_preference_check_button(main_tb, 1,
- "Enable network name resolution:",
+ "Enable network name resolution:", NULL,
prefs.name_resolve & RESOLV_NETWORK);
gtk_object_set_data(GTK_OBJECT(main_vb), N_RESOLVE_KEY, n_resolv_cb);
/* Resolve transport addresses */
t_resolv_cb = create_preference_check_button(main_tb, 2,
- "Enable transport name resolution:",
+ "Enable transport name resolution:", NULL,
prefs.name_resolve & RESOLV_TRANSPORT);
gtk_object_set_data(GTK_OBJECT(main_vb), T_RESOLVE_KEY, t_resolv_cb);
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 6feee32d20..e3fad138c3 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.39 2002/01/14 01:14:52 guy Exp $
+ * $Id: prefs_dlg.c,v 1.40 2002/01/20 20:05:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -79,6 +79,7 @@ static void prefs_tree_select_cb(GtkCTree *, GtkCTreeNode *, gint, gpointer);
#define E_GUI_PAGE_KEY "gui_options_page"
#define E_CAPTURE_PAGE_KEY "capture_options_page"
#define E_NAMERES_PAGE_KEY "nameres_options_page"
+#define E_TOOLTIPS_KEY "tooltips"
#define FIRST_PROTO_PREFS_PAGE 4
@@ -107,6 +108,7 @@ struct ct_struct {
GtkWidget *notebook;
GtkWidget *ctree;
GtkCTreeNode *node;
+ GtkTooltips *tooltips;
gint page;
};
@@ -152,13 +154,14 @@ pref_show(pref_t *pref, gpointer user_data)
break;
}
pref->control = create_preference_entry(main_tb, pref->ordinal,
- label_string, uint_str);
+ label_string, pref->description,
+ uint_str);
break;
case PREF_BOOL:
pref->saved_val.bool = *pref->varp.bool;
pref->control = create_preference_check_button(main_tb, pref->ordinal,
- label_string,
+ label_string, pref->description,
pref->saved_val.bool);
break;
@@ -167,13 +170,13 @@ pref_show(pref_t *pref, gpointer user_data)
if (pref->info.enum_info.radio_buttons) {
/* Show it as radio buttons. */
pref->control = create_preference_radio_buttons(main_tb, pref->ordinal,
- label_string,
+ label_string, pref->description,
pref->info.enum_info.enumvals,
pref->saved_val.enumval);
} else {
/* Show it as an option menu. */
pref->control = create_preference_option_menu(main_tb, pref->ordinal,
- label_string,
+ label_string, pref->description,
pref->info.enum_info.enumvals,
pref->saved_val.enumval);
}
@@ -184,7 +187,7 @@ pref_show(pref_t *pref, gpointer user_data)
g_free(pref->saved_val.string);
pref->saved_val.string = g_strdup(*pref->varp.string);
pref->control = create_preference_entry(main_tb, pref->ordinal,
- label_string,
+ label_string, pref->description,
pref->saved_val.string);
break;
@@ -218,6 +221,7 @@ module_prefs_show(module_t *module, gpointer user_data)
gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
+ gtk_object_set_data(GTK_OBJECT(main_tb), E_TOOLTIPS_KEY, cts->tooltips);
/* Add items for each of the preferences */
prefs_pref_foreach(module, pref_show, main_tb);
@@ -235,7 +239,8 @@ module_prefs_show(module_t *module, gpointer user_data)
}
void
-prefs_cb(GtkWidget *w, gpointer dummy) {
+prefs_cb(GtkWidget *w, gpointer dummy)
+{
GtkWidget *main_vb, *top_hb, *bbox, *prefs_nb, *ct_sb, *frame,
*ok_bt, *apply_bt, *save_bt, *cancel_bt;
GtkWidget *print_pg, *column_pg, *stream_pg, *gui_pg, *capture_pg;
@@ -244,7 +249,6 @@ prefs_cb(GtkWidget *w, gpointer dummy) {
GtkCTreeNode *ct_node;
struct ct_struct cts;
-
if (prefs_w != NULL) {
/* There's already a "Preferences" dialog box; reactivate it. */
reactivate_window(prefs_w);
@@ -261,6 +265,14 @@ prefs_cb(GtkWidget *w, gpointer dummy) {
gtk_signal_connect(GTK_OBJECT(prefs_w), "destroy",
GTK_SIGNAL_FUNC(prefs_main_destroy_cb), NULL);
+ /*
+ * Unfortunately, we can't arrange that a GtkTable widget wrap an event box
+ * around a table row, so the spacing between the preference item's label
+ * and its control widgets is inactive and the tooltip doesn't pop up when
+ * the mouse is over it.
+ */
+ cts.tooltips = gtk_tooltips_new();
+
/* Container for each row of widgets */
main_vb = gtk_vbox_new(FALSE, 5);
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
@@ -439,43 +451,62 @@ prefs_cb(GtkWidget *w, gpointer dummy) {
static void
set_option_label(GtkWidget *main_tb, int table_position,
- const gchar *label_text)
+ const gchar *label_text, const gchar *tooltip_text, GtkTooltips *tooltips)
{
GtkWidget *label;
+ GtkWidget *event_box;
label = gtk_label_new(label_text);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1,
- table_position, table_position + 1);
gtk_widget_show(label);
+
+ event_box = gtk_event_box_new();
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), event_box, 0, 1,
+ table_position, table_position + 1);
+ if (tooltip_text != NULL && tooltips != NULL)
+ gtk_tooltips_set_tip(tooltips, event_box, tooltip_text, NULL);
+ gtk_container_add(GTK_CONTAINER(event_box), label);
+ gtk_widget_show(event_box);
}
GtkWidget *
create_preference_check_button(GtkWidget *main_tb, int table_position,
- const gchar *label_text, gboolean active)
+ const gchar *label_text, const gchar *tooltip_text, gboolean active)
{
+ GtkTooltips *tooltips;
GtkWidget *check_box;
- set_option_label(main_tb, table_position, label_text);
+ tooltips = gtk_object_get_data(GTK_OBJECT(main_tb), E_TOOLTIPS_KEY);
+
+ set_option_label(main_tb, table_position, label_text, tooltip_text,
+ tooltips);
check_box = gtk_check_button_new();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box), active);
gtk_table_attach_defaults(GTK_TABLE(main_tb), check_box, 1, 2,
table_position, table_position + 1);
+ if (tooltip_text != NULL && tooltips != NULL)
+ gtk_tooltips_set_tip(tooltips, check_box, tooltip_text, NULL);
return check_box;
}
GtkWidget *
create_preference_radio_buttons(GtkWidget *main_tb, int table_position,
- const gchar *label_text, const enum_val_t *enumvals, gint current_val)
+ const gchar *label_text, const gchar *tooltip_text,
+ const enum_val_t *enumvals, gint current_val)
{
+ GtkTooltips *tooltips;
GtkWidget *radio_button_hbox, *button = NULL;
GSList *rb_group;
int index;
const enum_val_t *enum_valp;
+ GtkWidget *event_box;
+
+ tooltips = gtk_object_get_data(GTK_OBJECT(main_tb), E_TOOLTIPS_KEY);
- set_option_label(main_tb, table_position, label_text);
+ set_option_label(main_tb, table_position, label_text, tooltip_text,
+ tooltips);
radio_button_hbox = gtk_hbox_new(FALSE, 0);
rb_group = NULL;
@@ -494,8 +525,14 @@ create_preference_radio_buttons(GtkWidget *main_tb, int table_position,
}
}
gtk_widget_show(radio_button_hbox);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), radio_button_hbox, 1, 2,
+
+ event_box = gtk_event_box_new();
+ gtk_container_add(GTK_CONTAINER(event_box), radio_button_hbox);
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), event_box, 1, 2,
table_position, table_position+1);
+ if (tooltip_text != NULL && tooltips != NULL)
+ gtk_tooltips_set_tip(tooltips, event_box, tooltip_text, NULL);
+ gtk_widget_show(event_box);
/*
* It doesn't matter which of the buttons we return - we fetch
@@ -544,16 +581,24 @@ fetch_preference_radio_buttons_val(GtkWidget *button,
GtkWidget *
create_preference_option_menu(GtkWidget *main_tb, int table_position,
- const gchar *label_text, const enum_val_t *enumvals, gint current_val)
+ const gchar *label_text, const gchar *tooltip_text,
+ const enum_val_t *enumvals, gint current_val)
{
+ GtkTooltips *tooltips;
GtkWidget *label, *menu_box, *menu, *menu_item, *option_menu;
int menu_index, index;
const enum_val_t *enum_valp;
+ GtkWidget *event_box;
+
+ tooltips = gtk_object_get_data(GTK_OBJECT(main_tb), E_TOOLTIPS_KEY);
- set_option_label(main_tb, table_position, label_text);
+ set_option_label(main_tb, table_position, label_text, tooltip_text,
+ tooltips);
/* Create a menu from the enumvals */
menu = gtk_menu_new();
+ if (tooltip_text != NULL && tooltips != NULL)
+ gtk_tooltips_set_tip(tooltips, menu, tooltip_text, NULL);
menu_index = -1;
for (enum_valp = enumvals, index = 0; enum_valp->name != NULL;
enum_valp++, index++) {
@@ -579,9 +624,15 @@ create_preference_option_menu(GtkWidget *main_tb, int table_position,
* space.
*/
menu_box = gtk_hbox_new(FALSE, 0);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), menu_box,
- 1, 2, table_position, table_position + 1);
gtk_box_pack_start(GTK_BOX(menu_box), option_menu, FALSE, FALSE, 0);
+
+ event_box = gtk_event_box_new();
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), event_box,
+ 1, 2, table_position, table_position + 1);
+ if (tooltip_text != NULL && tooltips != NULL)
+ gtk_tooltips_set_tip(tooltips, event_box, tooltip_text, NULL);
+ gtk_container_add(GTK_CONTAINER(event_box), menu_box);
+
return option_menu;
}
@@ -600,17 +651,23 @@ fetch_preference_option_menu_val(GtkWidget *optmenu, const enum_val_t *enumvals)
GtkWidget *
create_preference_entry(GtkWidget *main_tb, int table_position,
- const gchar *label_text, char *value)
+ const gchar *label_text, const gchar *tooltip_text, char *value)
{
+ GtkTooltips *tooltips;
GtkWidget *entry;
- set_option_label(main_tb, table_position, label_text);
+ tooltips = gtk_object_get_data(GTK_OBJECT(main_tb), E_TOOLTIPS_KEY);
+
+ set_option_label(main_tb, table_position, label_text, tooltip_text,
+ tooltips);
entry = gtk_entry_new();
if (value != NULL)
gtk_entry_set_text(GTK_ENTRY(entry), value);
gtk_table_attach_defaults(GTK_TABLE(main_tb), entry, 1, 2,
table_position, table_position + 1);
+ if (tooltip_text != NULL && tooltips != NULL)
+ gtk_tooltips_set_tip(tooltips, entry, tooltip_text, NULL);
gtk_widget_show(entry);
return entry;
diff --git a/gtk/prefs_dlg.h b/gtk/prefs_dlg.h
index 612547248a..275dc33df9 100644
--- a/gtk/prefs_dlg.h
+++ b/gtk/prefs_dlg.h
@@ -1,7 +1,7 @@
/* prefs_dlg.h
* Definitions for preference handling routines
*
- * $Id: prefs_dlg.h,v 1.7 2002/01/13 20:35:12 guy Exp $
+ * $Id: prefs_dlg.h,v 1.8 2002/01/20 20:05:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -29,13 +29,14 @@ void prefs_cb(GtkWidget *, gpointer);
void properties_cb(GtkWidget *, gpointer);
GtkWidget *create_preference_check_button(GtkWidget *, int, const gchar *,
- gboolean);
+ const gchar *, gboolean);
GtkWidget *create_preference_radio_buttons(GtkWidget *, int, const gchar *,
- const enum_val_t *, gint);
+ const gchar *, const enum_val_t *, gint);
gint fetch_preference_radio_buttons_val(GtkWidget *, const enum_val_t *);
GtkWidget *create_preference_option_menu(GtkWidget *, int, const gchar *,
- const enum_val_t *, gint);
+ const gchar *, const enum_val_t *, gint);
gint fetch_preference_option_menu_val(GtkWidget *, const enum_val_t *);
-GtkWidget *create_preference_entry(GtkWidget *, int, const gchar *, char *);
+GtkWidget *create_preference_entry(GtkWidget *, int, const gchar *,
+ const gchar *, char *);
#endif
diff --git a/gtk/print_prefs.c b/gtk/print_prefs.c
index 888915bb72..aafb2c9f78 100644
--- a/gtk/print_prefs.c
+++ b/gtk/print_prefs.c
@@ -1,7 +1,7 @@
/* print_prefs.c
* Dialog boxes for preferences for printing
*
- * $Id: print_prefs.c,v 1.10 2002/01/13 20:35:12 guy Exp $
+ * $Id: print_prefs.c,v 1.11 2002/01/20 20:05:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -79,17 +79,18 @@ GtkWidget * printer_prefs_show(void)
/* Output format */
button = create_preference_radio_buttons(main_tb, 0, "Format:",
- print_format_vals, prefs.pr_format);
+ NULL, print_format_vals, prefs.pr_format);
gtk_object_set_data(GTK_OBJECT(main_vb), E_PRINT_FORMAT_KEY, button);
/* Output destination */
button = create_preference_radio_buttons(main_tb, 1, "Print to:",
- print_dest_vals, prefs.pr_dest);
+ NULL, print_dest_vals, prefs.pr_dest);
gtk_object_set_data(GTK_OBJECT(main_vb), E_PRINT_DESTINATION_KEY,
button);
/* Command text entry */
- cmd_te = create_preference_entry(main_tb, 2, "Command:", prefs.pr_cmd);
+ cmd_te = create_preference_entry(main_tb, 2, "Command:", NULL,
+ prefs.pr_cmd);
gtk_object_set_data(GTK_OBJECT(main_vb), PRINT_CMD_TE_KEY, cmd_te);
/* File button and text entry */