From df0bef704ab266208002356b39696cfa543bf81d Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Tue, 31 Jul 2012 07:27:39 +0000 Subject: From Michael Mann: Expand show version preference. implementation of Steven's suggestion of a radio button (actually dropdown) of the 4 possibilities. I changed the default to have the version on both in the welcome screen and on the window as that's how it was and people tend not to change the preferences I think. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6437 svn path=/trunk/; revision=44153 --- epan/prefs.c | 31 ++++++++++++++++++------------- epan/prefs.h | 12 +++++++++++- ui/gtk/main_titlebar.c | 3 ++- ui/gtk/main_welcome.c | 3 ++- ui/gtk/prefs_gui.c | 26 +++++++++++++++++--------- 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/epan/prefs.c b/epan/prefs.c index d7265bc5cc..33fa427150 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -98,6 +98,9 @@ static const gchar *gui_hex_dump_highlight_style_text[] = static const gchar *gui_console_open_text[] = { "NEVER", "AUTOMATIC", "ALWAYS", NULL }; +static const gchar *gui_version_placement_text[] = + { "WELCOME", "TITLE", "BOTH", "NEITHER", NULL }; + static const gchar *gui_fileopen_style_text[] = { "LAST_OPENED", "SPECIFIED", NULL }; @@ -1519,7 +1522,7 @@ init_prefs(void) prefs.gui_webbrowser = g_strdup(HTML_VIEWER " %s"); prefs.gui_window_title = g_strdup(""); prefs.gui_start_title = g_strdup("The World's Most Popular Network Protocol Analyzer"); - prefs.gui_version_in_start_page = TRUE; + prefs.gui_version_placement = version_both; prefs.gui_auto_scroll_on_expand = FALSE; prefs.gui_auto_scroll_percentage = 0; prefs.gui_layout_type = layout_type_5; @@ -2206,7 +2209,7 @@ prefs_capture_device_monitor_mode(const char *name) #define PRS_GUI_WEBBROWSER "gui.webbrowser" #define PRS_GUI_WINDOW_TITLE "gui.window_title" #define PRS_GUI_START_TITLE "gui.start_title" -#define PRS_GUI_VERSION_IN_START_PAGE "gui.version_in_start_page" +#define PRS_GUI_VERSION_PLACEMENT "gui.version_placement" #define PRS_GUI_AUTO_SCROLL "gui.auto_scroll_on_expand" #define PRS_GUI_AUTO_SCROLL_PERCENTAGE "gui.auto_scroll_percentage" #define PRS_GUI_LAYOUT_TYPE "gui.layout_type" @@ -2628,11 +2631,12 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_, } else if (strcmp(pref_name, PRS_GUI_START_TITLE) == 0) { g_free(prefs.gui_start_title); prefs.gui_start_title = g_strdup(value); - } else if (strcmp(pref_name, PRS_GUI_VERSION_IN_START_PAGE) == 0) { - if (g_ascii_strcasecmp(value, "true") == 0) { - prefs.gui_version_in_start_page = TRUE; - } else { - prefs.gui_version_in_start_page = FALSE; + } else if (strcmp(pref_name, PRS_GUI_VERSION_PLACEMENT) == 0) { + prefs.gui_version_placement = strtoul(value, NULL, 10); + if (prefs.gui_version_placement > version_neither) { + /* XXX - report an error? It's not a syntax error - we'd need to + add a way of reporting a *semantic* error. */ + prefs.gui_version_placement = version_welcome_only; } } else if (strcmp(pref_name, PRS_GUI_AUTO_SCROLL) == 0) { if (g_ascii_strcasecmp(value, "true") == 0) { @@ -3475,12 +3479,13 @@ write_prefs(char **pf_path_return) fprintf(pf, PRS_GUI_START_TITLE ": %s\n", prefs.gui_start_title); - fprintf(pf, "\n# Show version in the start page and main screen's title bar.\n"); - fprintf(pf, "# TRUE or FALSE (case-insensitive).\n"); - if (prefs.gui_version_in_start_page == default_prefs.gui_version_in_start_page) + + fprintf(pf, "\n# Show version in the start page and/or main screen's title bar.\n"); + fprintf(pf, "# One of: WELCOME, TITLE, BOTH, NEITHER\n"); + if (prefs.gui_version_placement == default_prefs.gui_version_placement) fprintf(pf, "#"); - fprintf(pf, PRS_GUI_VERSION_IN_START_PAGE ": %s\n", - prefs.gui_version_in_start_page == TRUE ? "TRUE" : "FALSE"); + fprintf(pf, PRS_GUI_VERSION_PLACEMENT ": %s\n", + gui_version_placement_text[prefs.gui_version_placement]); fprintf(pf, "\n# Automatically scroll the recently expanded item.\n"); fprintf(pf, "# TRUE or FALSE (case-insensitive).\n"); @@ -3848,7 +3853,7 @@ copy_prefs(e_prefs *dest, e_prefs *src) dest->gui_webbrowser = g_strdup(src->gui_webbrowser); dest->gui_window_title = g_strdup(src->gui_window_title); dest->gui_start_title = g_strdup(src->gui_start_title); - dest->gui_version_in_start_page = src->gui_version_in_start_page; + dest->gui_version_placement = src->gui_version_placement; dest->console_log_level = src->console_log_level; /* values for the capture dialog box */ dest->capture_device = g_strdup(src->capture_device); diff --git a/epan/prefs.h b/epan/prefs.h index b7ea7d8025..0520b830e9 100644 --- a/epan/prefs.h +++ b/epan/prefs.h @@ -103,6 +103,16 @@ typedef enum { console_open_always } console_open_e; +/* + * Places version information will show up + */ +typedef enum { + version_welcome_only, + version_title_only, + version_both, + version_neither +} version_info_e; + typedef struct _e_prefs { gint pr_format; @@ -146,7 +156,7 @@ typedef struct _e_prefs { gchar *gui_webbrowser; gchar *gui_window_title; gchar *gui_start_title; - gboolean gui_version_in_start_page; + version_info_e gui_version_placement; gboolean gui_auto_scroll_on_expand; guint gui_auto_scroll_percentage; layout_type_e gui_layout_type; diff --git a/ui/gtk/main_titlebar.c b/ui/gtk/main_titlebar.c index e2e1c45c68..bcae30299a 100644 --- a/ui/gtk/main_titlebar.c +++ b/ui/gtk/main_titlebar.c @@ -74,7 +74,8 @@ main_titlebar_update(void) title = create_user_window_title(window_name); /* Optionally append the version */ - if (prefs.gui_version_in_start_page) { + if ((prefs.gui_version_placement == version_title_only) || + (prefs.gui_version_placement == version_both)) { gchar *old_title = title; title = g_strdup_printf("%s [Wireshark %s %s]", title, VERSION, wireshark_svnversion); g_free(old_title); diff --git a/ui/gtk/main_welcome.c b/ui/gtk/main_welcome.c index c1c09df32e..a7757dbe90 100644 --- a/ui/gtk/main_welcome.c +++ b/ui/gtk/main_welcome.c @@ -328,7 +328,8 @@ welcome_header_set_message(gchar *msg) { g_string_append(message, prefs.gui_start_title); } - if (prefs.gui_version_in_start_page) { + if ((prefs.gui_version_placement == version_welcome_only) || + (prefs.gui_version_placement == version_both)) { g_string_append_printf(message, "\nVersion " VERSION "%s", wireshark_svnversion); } diff --git a/ui/gtk/prefs_gui.c b/ui/gtk/prefs_gui.c index 86470b53a7..fdfd506540 100644 --- a/ui/gtk/prefs_gui.c +++ b/ui/gtk/prefs_gui.c @@ -131,6 +131,14 @@ static const enum_val_t gui_console_open_vals[] = { }; #endif +static const enum_val_t gui_version_placement_vals[] = { + { "WELCOME", "Welcome only", version_welcome_only }, + { "TITLE", "Title only", version_title_only }, + { "BOTH", "Both", version_both }, + { "NEITHER", "Neither", version_neither }, + { NULL, NULL, 0 } +}; + static const enum_val_t gui_fileopen_vals[] = { { "LAST_OPENED", "Remember last directory", FO_STYLE_LAST_OPENED }, { "SPECIFIED", "Always start in:", FO_STYLE_SPECIFIED }, @@ -175,7 +183,7 @@ gui_prefs_show(void) GtkWidget *fileopen_rb, *fileopen_dir_te, *fileopen_preview_te; GtkWidget *recent_files_count_max_te, *recent_df_entries_max_te, *ask_unsaved_cb, *find_wrap_cb; GtkWidget *use_pref_save_cb; - GtkWidget *show_version_cb; + GtkWidget *show_version_om; GtkWidget *auto_scroll_cb, *scroll_percent_te; GtkWidget *webbrowser_te; GtkWidget *save_position_cb, *save_size_cb, *save_maximized_cb; @@ -328,12 +336,12 @@ gui_prefs_show(void) prefs.gui_use_pref_save); g_object_set_data(G_OBJECT(main_vb), GUI_USE_PREF_SAVE_KEY, use_pref_save_cb); - /* Show version in welcome screen */ - show_version_cb = create_preference_check_button(main_tb, pos++, - "Welcome screen and title bar shows version:", - "Whether version should be shown in the start page and main screen's title bar.", - prefs.gui_version_in_start_page ); - g_object_set_data(G_OBJECT(main_vb), GUI_SHOW_VERSION_KEY, show_version_cb); + /* Show version in welcome and/or title screen */ + show_version_om = create_preference_option_menu(main_tb, pos++, + "Welcome screen and title bar shows version", + "Whether version should be shown in the start page and/or main screen's title bar.", + gui_version_placement_vals, prefs.gui_version_placement); + g_object_set_data(G_OBJECT(main_vb), GUI_SHOW_VERSION_KEY, show_version_om); /* Whether to auto scroll when expanding items */ auto_scroll_cb = create_preference_check_button(main_tb, pos++, @@ -471,8 +479,8 @@ gui_prefs_fetch(GtkWidget *w) prefs.gui_use_pref_save = gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), GUI_USE_PREF_SAVE_KEY)); - prefs.gui_version_in_start_page = - gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), GUI_SHOW_VERSION_KEY)); + prefs.gui_version_placement = + fetch_enum_value(g_object_get_data(G_OBJECT(w), GUI_SHOW_VERSION_KEY), gui_version_placement_vals); prefs.gui_auto_scroll_on_expand = gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), GUI_AUTO_SCROLL_KEY)); -- cgit v1.2.3