aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/prefs_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-05-24 02:25:21 +0000
committerGuy Harris <guy@alum.mit.edu>2004-05-24 02:25:21 +0000
commit911bad80f01e1a526cb5db6a1c8b67224a0eb6fd (patch)
treeea0dc09abb3bad519585a3c81e2c1592383a9bc7 /gtk/prefs_dlg.c
parent9cccb951f0afece3eb83d45275d903852298839c (diff)
Have two strings in an enum_val_t - one that's a short string that is
convenient to put into a command line (no capital letters, no spaces to require quotes), and one that's a detailed description for use in the UI. Allow either of them in the preferences file or "-o" option; use the detailed description in the UI, and also use it when writing the preferences out, so that the preference will be readable by older versions of Ethereal (assuming the preference existed in that version). Update "README.developer" to give more detail about an enum_val_t (and to put the _t in), and to give a more detailed description of the "radio_buttons" argument to "prefs_register_enum_preference()". svn path=/trunk/; revision=10982
Diffstat (limited to 'gtk/prefs_dlg.c')
-rw-r--r--gtk/prefs_dlg.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 67bd3adb44..9b0705510b 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.81 2004/04/29 17:03:27 ulfl Exp $
+ * $Id: prefs_dlg.c,v 1.82 2004/05/24 02:25:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -738,7 +738,7 @@ create_preference_radio_buttons(GtkWidget *main_tb, int table_position,
for (enum_valp = enumvals, index = 0; enum_valp->name != NULL;
enum_valp++, index++) {
button = gtk_radio_button_new_with_label(rb_group,
- enum_valp->name);
+ enum_valp->description);
gtk_widget_show(button);
rb_group = gtk_radio_button_group(GTK_RADIO_BUTTON(button));
gtk_box_pack_start(GTK_BOX(radio_button_hbox), button, FALSE,
@@ -770,13 +770,21 @@ static gint
label_to_enum_val(GtkWidget *label, const enum_val_t *enumvals)
{
char *label_string;
- gint enumval;
+ int i;
- /* Get the label's text, and translate it to a value. */
+ /* Get the label's text, and translate it to a value.
+ We match only the descriptions, as those are what appear in
+ the option menu items or as labels for radio buttons.
+ We fail if we don't find a match, as that "can't happen". */
gtk_label_get(GTK_LABEL(label), &label_string);
- enumval = find_val_for_string(label_string, enumvals, 1);
- return enumval;
+ for (i = 0; enumvals[i].name != NULL; i++) {
+ if (strcasecmp(label_string, enumvals[i].description) == 0) {
+ return enumvals[i].value;
+ }
+ }
+ g_assert_not_reached();
+ return -1;
}
gint
@@ -826,7 +834,7 @@ create_preference_option_menu(GtkWidget *main_tb, int table_position,
menu_index = -1;
for (enum_valp = enumvals, index = 0; enum_valp->name != NULL;
enum_valp++, index++) {
- menu_item = gtk_menu_item_new_with_label(enum_valp->name);
+ menu_item = gtk_menu_item_new_with_label(enum_valp->description);
gtk_menu_append(GTK_MENU(menu), menu_item);
if (enum_valp->value == current_val)
menu_index = index;