2 * Main window title bar routines.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <epan/prefs.h>
34 #include "gtkglobals.h"
35 #include "gui_utils.h"
36 #include "main_titlebar.h"
38 #include "../version_info.h"
41 * Key to attach the "un-decorated" title to the window, so that if the
42 * user-specified decoration changes, we can correctly update the
45 #define MAIN_WINDOW_NAME_KEY "main_window_name"
47 /* Set the name of the top level main_window_name with the specified string and call
48 main_titlebar_update() to construct the full title and display it in the main window. */
50 main_set_window_name(const gchar
*window_name
)
52 gchar
*old_window_name
;
54 /* Attach the new un-decorated window name to the window. */
55 old_window_name
= (gchar
*)g_object_get_data(G_OBJECT(top_level
), MAIN_WINDOW_NAME_KEY
);
56 g_free(old_window_name
);
57 g_object_set_data(G_OBJECT(top_level
), MAIN_WINDOW_NAME_KEY
, g_strdup(window_name
));
59 main_titlebar_update();
62 /* Construct the main window's title with the current main_window_name, optionally appended
63 with the user-specified title and/or wireshark version. Display the result in the main
66 main_titlebar_update(void)
71 /* Get the current filename or other title set in main_set_window_name */
72 window_name
= (gchar
*)g_object_get_data(G_OBJECT(top_level
), MAIN_WINDOW_NAME_KEY
);
73 if (window_name
!= NULL
) {
74 /* Optionally append the user-defined window title */
75 title
= create_user_window_title(window_name
);
77 /* Optionally append the version */
78 if ((prefs
.gui_version_placement
== version_title_only
) ||
79 (prefs
.gui_version_placement
== version_both
)) {
80 gchar
*old_title
= title
;
81 title
= g_strdup_printf("%s [Wireshark %s %s]", title
, VERSION
, wireshark_svnversion
);
84 gtk_window_set_title(GTK_WINDOW(top_level
), title
);
89 /* Set titlebar to reflect the current state of the capture file, if any */
91 set_titlebar_for_capture_file(capture_file
*cf
)
96 if (cf
&& cf
->filename
) {
97 display_name
= cf_get_display_name(cf
);
98 window_name
= g_strdup_printf("%s%s", cf_has_unsaved_data(cf
) ? "*" : "",
100 g_free(display_name
);
101 main_set_window_name(window_name
);
104 main_set_window_name("The Wireshark Network Analyzer");
108 /* Set titlebar to reflect a capture in progress */
110 set_titlebar_for_capture_in_progress(capture_file
*cf
)
114 window_name
= g_strdup_printf("Capturing from %s ", cf_get_tempfile_source(cf
));
115 main_set_window_name(window_name
);