From Cal Turney:
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 7 Aug 2010 14:37:37 +0000 (14:37 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 7 Aug 2010 14:37:37 +0000 (14:37 +0000)
Optionally display Wireshark version in the main window's title bar.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5040

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@33729 f5534014-38df-0310-8fa8-9805f1628bb7

epan/prefs.c
gtk/gui_utils.c
gtk/gui_utils.h
gtk/main.c
gtk/prefs_gui.c
gtk/prefs_layout.c
ui_util.h

index 532a843247b6bec4957d71b7e31e923cdbd3ade5..a29d3c0c909601a455f42e0759b4bcda9eddaa89 100644 (file)
@@ -2971,7 +2971,7 @@ write_prefs(char **pf_path_return)
   fprintf(pf, "# Ex: mozilla %%s\n");
   fprintf(pf, PRS_GUI_WEBBROWSER ": %s\n", prefs.gui_webbrowser);
 
-  fprintf(pf, "\n# Custom window title. (Prepended to existing titles.)\n");
+  fprintf(pf, "\n# Custom window title. (Appended to existing titles.)\n");
   fprintf(pf, PRS_GUI_WINDOW_TITLE ": %s\n",
          prefs.gui_window_title);
 
@@ -2979,7 +2979,7 @@ write_prefs(char **pf_path_return)
   fprintf(pf, PRS_GUI_START_TITLE ": %s\n",
          prefs.gui_start_title);
 
-  fprintf(pf, "\n# Show version in start page, can be useful in custom builds.\n");
+  fprintf(pf, "\n# Show version in the start page and main screen's title bar.\n");
   fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
   fprintf(pf, PRS_GUI_VERSION_IN_START_PAGE ": %s\n",
          prefs.gui_version_in_start_page == TRUE ? "TRUE" : "FALSE");
index 954cda355b6734ebab7ef9365f4d5585dea5e74c..d227fa79aaeb7927d4c67832cf1d0d26dfbbaf10 100644 (file)
@@ -48,6 +48,8 @@
 
 #include "image/wsicon16.xpm"
 
+#include "../version_info.h"
+
 #ifdef _WIN32
 #include <windows.h>
 #endif
@@ -542,8 +544,9 @@ GtkWidget *pixbuf_to_widget(const char * pb_data) {
  */
 #define MAIN_WINDOW_NAME_KEY  "main_window_name"
 
-/* Set the name of the top-level window and its icon to the specified
-   string. */
+/* Set the name of the top level main_window_name with the specified string and call 
+   update_main_window_title() to construct the full title and display it in the main window
+   and its icon title. */
 void
 set_main_window_name(const gchar *window_name)
 {
@@ -554,25 +557,35 @@ set_main_window_name(const gchar *window_name)
     g_free(old_window_name);
     g_object_set_data(G_OBJECT(top_level), MAIN_WINDOW_NAME_KEY, g_strdup(window_name));
 
-    update_main_window_name();
+  update_main_window_title();
 }
 
-/* Update the name of the main window if the user-specified decoration
-   changed. */
+/* Construct the main window's title with the current main_window_name, optionally appended
+   with the user-specified title and/or wireshark version. Display the result in the main
+   window title bar and in its icon title. 
+   NOTE: The name was changed from '_name' to '_title' because main_window_name is actually
+         set in set_main_window_name() and is only one of the components of the title. */
 void
-update_main_window_name(void)
+update_main_window_title(void)
 {
     gchar *window_name;
     gchar *title;
 
+    /* Get the current filename or other title set in set_main_window_name */
     window_name = g_object_get_data(G_OBJECT(top_level), MAIN_WINDOW_NAME_KEY);
     if (window_name != NULL) {
-        /* use user-defined window title if preference is set */
-        title = create_user_window_title(window_name);
-        gtk_window_set_title(GTK_WINDOW(top_level), title);
-        gdk_window_set_icon_name(top_level->window, title);
-        g_free(title);
-    }
+
+    /* Optionally append the user-defined window title */
+    title = create_user_window_title(window_name);
+
+    /* Optionally append the version */
+    if (prefs.gui_version_in_start_page) {
+        title = g_strdup_printf("%s   [Wireshark %s %s]", title, VERSION, wireshark_svnversion);
+    } 
+    gtk_window_set_title(GTK_WINDOW(top_level), title);
+    gdk_window_set_icon_name(top_level->window, title);
+    g_free(title);
+  }
 }
 
 /* update the main window */
@@ -1148,7 +1161,7 @@ create_user_window_title(const gchar *caption)
     if ((prefs.gui_window_title == NULL) || (*prefs.gui_window_title == '\0'))
         return g_strdup(caption);
 
-    return g_strdup_printf("%s %s", prefs.gui_window_title, caption);
+    return g_strdup_printf("%s   [%s]", caption, prefs.gui_window_title);
 }
 
 /* XXX move toggle_tree over from proto_draw.c to handle GTK+ 1 */
index a9f3a4e5bb595552b55f3c5dedf81396e5cec69b..0cea21615615b5ba8f1298c73df5897e239ac3f8 100644 (file)
@@ -324,6 +324,12 @@ extern void copy_binary_to_clipboard(const guint8* data_p, int len);
  */
 extern gchar *create_user_window_title(const gchar *caption);
 
+/** Construct the main window's title with the current main_window_name optionally appended
+ *  with the user-specified title and/or wireshark version. 
+ *  Display the result in the main window's title bar and in its icon title
+ */
+extern void update_main_window_title(void);
+
 /** Renders a float with two decimals precission, called from gtk_tree_view_column_set_cell_data_func().
  * the user data must be the colum number.
  * Present floats with two decimals 
index 7632a504615e5a36487d5d65002e2c3c5454b80f..164cddb24feb375d725361292986d2e5ef69173f 100644 (file)
@@ -1415,21 +1415,19 @@ resolv_update_cb(gpointer data _U_)
 }
 
 
-/* Set the file name in the name for the main window and in the name for the main window's icon. */
-static void
+/* Set main_window_name and it's icon title to the capture filename */
+void
 set_display_filename(capture_file *cf)
 {
-  gchar       *win_name;
+  gchar *window_name;
 
-  if (!cf->is_tempfile && cf->filename) {
-    /* Add this filename to the list of recent files in the "Recent Files" submenu */
-    add_menu_recent_capture_file(cf->filename);
+  if (cf->filename) {
+         window_name = g_strdup_printf("%s", cf_get_display_name(cf));
+  } else {
+         window_name = "The Wireshark Network Analyzer";
   }
-
-  /* window title */
-  win_name = g_strdup_printf("%s - Wireshark", cf_get_display_name(cf));
-  set_main_window_name(win_name);
-  g_free(win_name);
+  set_main_window_name(window_name);
+  g_free(window_name);
 }
 
 GtkWidget           *close_dlg = NULL;
@@ -1508,7 +1506,11 @@ main_cf_cb_file_read_started(capture_file *cf _U_)
 static void
 main_cf_cb_file_read_finished(capture_file *cf)
 {
-    set_display_filename(cf);
+       if (!cf->is_tempfile && cf->filename) {
+               /* Add this filename to the list of recent files in the "Recent Files" submenu */
+               add_menu_recent_capture_file(cf->filename);
+       }
+       set_display_filename(cf);
 
     /* Enable menu items that make sense if you have a capture file you've
        finished reading. */
@@ -1568,8 +1570,6 @@ main_capture_set_main_window_title(capture_options *capture_opts)
     if(capture_opts->iface) {
         g_string_append_printf(title, "from %s ", cf_get_tempfile_source(capture_opts->cf));
     }
-    g_string_append(title, "- Wireshark");
-
     set_main_window_name(title->str);
     g_string_free(title, TRUE);
 }
@@ -1619,7 +1619,11 @@ main_capture_cb_capture_update_finished(capture_options *capture_opts)
     capture_file *cf = capture_opts->cf;
     static GList *icon_list = NULL;
 
-    set_display_filename(cf);
+       if (!cf->is_tempfile && cf->filename) {
+               /* Add this filename to the list of recent files in the "Recent Files" submenu */
+               add_menu_recent_capture_file(cf->filename);
+       }
+       set_display_filename(cf);
 
     /* Enable menu items that make sense if you're not currently running
      a capture. */
@@ -3564,14 +3568,10 @@ static void
 create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs_p)
 {
     GtkAccelGroup *accel;
-    gchar         *title;
 
-    /* use user-defined title if preference is set */
-    title = create_user_window_title("The Wireshark Network Analyzer");
-
-    /* Main window */
-    top_level = window_new(GTK_WINDOW_TOPLEVEL, title);
-    g_free(title);
+       /* Main window */
+    top_level = window_new(GTK_WINDOW_TOPLEVEL, "");
+    set_main_window_name("The Wireshark Network Analyzer");
 
     gtk_widget_set_name(top_level, "main window");
     g_signal_connect(top_level, "delete_event", G_CALLBACK(main_window_delete_event_cb),
@@ -3751,7 +3751,7 @@ void change_configuration_profile (const gchar *profile_name)
    prefs_apply_all();
 
    /* Update window view and redraw the toolbar */
-   update_main_window_name();
+   update_main_window_title();
    toolbar_redraw_all();
 
    /* Enable all protocols and disable from the disabled list */
index 42c15224d3c80e261797dad2f4163c577c9743ca..01c4bf0510f9deaded8674dcfe934ed4886d5c0f 100644 (file)
@@ -326,8 +326,8 @@ gui_prefs_show(void)
 
        /* Show version in welcome screen */
        show_version_cb = create_preference_check_button(main_tb, pos++,
-           "Welcome screen shows version:",
-           "Whether version should be shown in the start page or not.",
+           "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);
 
@@ -498,6 +498,9 @@ gui_prefs_apply(GtkWidget *w _U_ , gboolean redissect)
                redraw_packet_bytes_all();
        }
 
+       /* Redisplay the main window's title */
+       update_main_window_title();
+
        /* Redraw the help window(s). */
        supported_redraw();
        help_redraw();
index b11d700f1a868eb5950d8b187b2b023e3af43180..7f10c4efd2d1f8b9be285f2a6f9ef74d1c5be797 100644 (file)
@@ -432,8 +432,8 @@ layout_prefs_show(void)
 
     /* Window title */
     window_title_te = create_preference_entry(main_tb, pos++,
-        "Custom window title (prepended to existing titles):", 
-        "Enter the text to be prepended to the window title.",
+        "Custom window title (appended to existing titles):", 
+        "Enter the text to be appended to the window title.",
         prefs.gui_window_title);
     gtk_entry_set_text(GTK_ENTRY(window_title_te), prefs.gui_window_title);
     g_object_set_data(G_OBJECT(main_vb), GUI_WINDOW_TITLE_KEY, window_title_te);
@@ -485,7 +485,7 @@ layout_prefs_fetch(GtkWidget *w)
 void
 layout_prefs_apply(GtkWidget *w _U_)
 {
-    update_main_window_name();
+    update_main_window_title();
     main_widgets_rearrange();
 }
 
index 4481505538d3b3a6802481eb54868850b2afb80f..ef85561643b5653fee8cf8e94b4bbe3673e04196 100644 (file)
--- a/ui_util.h
+++ b/ui_util.h
@@ -43,7 +43,7 @@ extern "C" {
 void set_main_window_name(const gchar *);
 /* Update the name of the main window if the user-specified decoration
    changed. */
-void update_main_window_name(void);
+void update_main_window_title(void);
 /* update the main window */
 extern void main_window_update(void);
 /* exit the main window */