5 * Ulf Lamping <ulf.lamping@web.de>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 2000 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
33 #include <epan/filesystem.h>
34 #include <epan/plugins.h>
35 #include "about_dlg.h"
36 #include "gui_utils.h"
37 #include "dlg_utils.h"
39 #include "compat_macros.h"
41 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
42 #include "text_page.h"
45 #include "../image/wssplash.xpm"
46 #include "gtkglobals.h"
47 #include "version_info.h"
49 #include "plugins_dlg.h"
51 static void about_wireshark_destroy_cb(GtkWidget *, gpointer);
55 * Keep a static pointer to the current "About Wireshark" window, if any, so
56 * that if somebody tries to do "About Wireshark" while there's already an
57 * "About Wireshark" window up, we just pop up the existing one, rather than
60 static GtkWidget *about_wireshark_w;
64 about_wireshark(GtkWidget *parent, GtkWidget *main_vb)
66 GtkWidget *msg_label, *icon;
67 #if GTK_MAJOR_VERSION >= 2
70 const char *title = "Network Protocol Analyzer";
72 icon = xpm_to_widget_from_parent(parent, wssplash_xpm);
73 gtk_container_add(GTK_CONTAINER(main_vb), icon);
75 msg_label = gtk_label_new(title);
76 #if GTK_MAJOR_VERSION >= 2
77 message = g_strdup_printf("<span size=\"x-large\" weight=\"bold\">%s</span>", title);
78 gtk_label_set_markup(GTK_LABEL(msg_label), message);
81 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
85 splash_update_label(GtkWidget *win, const char *message)
89 if (win == NULL) return;
91 main_lb = OBJECT_GET_DATA(win, "splash_label");
92 gtk_label_set_text(GTK_LABEL(main_lb), message);
94 /* Process all pending GUI events before continuing, so that
95 the splash screen window gets updated. */
96 while (gtk_events_pending()) gtk_main_iteration();
100 splash_new(const char *message)
106 GtkWidget *percentage_hb;
108 GtkWidget *percentage_lb;
110 win = splash_window_new();
112 /* When calling about_wireshark(), we must realize the top-level
113 widget for the window, otherwise GTK will throw a warning
114 because we don't have a colormap associated with that window and
115 can't handle the pixmap. */
116 gtk_widget_realize(win);
118 main_vb = gtk_vbox_new(FALSE, 6);
119 gtk_container_border_width(GTK_CONTAINER(main_vb), 24);
120 gtk_container_add(GTK_CONTAINER(win), main_vb);
122 about_wireshark(win, main_vb);
124 main_lb = gtk_label_new(message);
125 gtk_container_add(GTK_CONTAINER(main_vb), main_lb);
126 OBJECT_SET_DATA(win, "splash_label", main_lb);
128 main_lb = gtk_label_new("");
129 gtk_container_add(GTK_CONTAINER(main_vb), main_lb);
130 OBJECT_SET_DATA(win, "protocol_label", main_lb);
132 percentage_hb = gtk_hbox_new(FALSE, 1);
133 gtk_box_pack_start(GTK_BOX(main_vb), percentage_hb, FALSE, TRUE, 3);
135 prog_bar = gtk_progress_bar_new();
136 #if GTK_MAJOR_VERSION < 2
137 gtk_progress_set_activity_mode(GTK_PROGRESS(prog_bar), FALSE);
139 gtk_box_pack_start(GTK_BOX(percentage_hb), prog_bar, FALSE, TRUE, 3);
140 OBJECT_SET_DATA(win, "progress_bar", prog_bar);
142 percentage_lb = gtk_label_new(" 0%");
143 gtk_misc_set_alignment(GTK_MISC(percentage_lb), 0.0, 0.0);
144 gtk_box_pack_start(GTK_BOX(percentage_hb), percentage_lb, FALSE, TRUE, 3);
145 OBJECT_SET_DATA(win, "percentage_label", percentage_lb);
147 gtk_widget_show_all(win);
149 splash_update_label(win, message);
154 #define REGISTER_FREQ 100 /* Milliseconds */
157 splash_update(register_action_e action, const char *message, gpointer client_data)
162 GtkWidget *percentage_lb;
164 gulong ul_percentage;
166 const char *action_msg;
168 static gulong ul_sofar = 0;
169 static gulong ul_count = 0;
171 static register_action_e last_action = RA_NONE;
173 static GTimeVal cur_tv;
174 static GTimeVal next_tv = {0, 0};
176 win = (GtkWidget *)client_data;
178 if (win == NULL) return;
180 g_get_current_time(&cur_tv);
181 if (cur_tv.tv_sec <= next_tv.tv_sec && cur_tv.tv_usec <= next_tv.tv_usec && ul_sofar < ul_count - 1) {
182 /* Only update every REGISTER_FREQ milliseconds */
186 memcpy(&next_tv, &cur_tv, sizeof(next_tv));
187 next_tv.tv_usec += REGISTER_FREQ * 1000;
188 if (next_tv.tv_usec >= 1000000) {
190 next_tv.tv_usec -= 1000000;
193 if(last_action != action) {
194 /* the action has changed */
197 action_msg = "Initializing dissectors ...";
200 action_msg = "Initializing tap listeners ...";
203 action_msg = "Registering dissector ...";
205 case RA_PLUGIN_REGISTER:
206 action_msg = "Registering plugins ...";
209 action_msg = "Handing off dissector ...";
211 case RA_PLUGIN_HANDOFF:
212 action_msg = "Handing off plugins ...";
215 action_msg = "Loading module preferences ...";
217 case RA_CONFIGURATION:
218 action_msg = "Loading configuration files ...";
221 action_msg = "(Unknown action)";;
224 splash_update_label(win, action_msg);
225 last_action = action;
228 if(ul_count == 0) /* get the count of dissectors */
229 ul_count = register_count() + 6; /* additional 6 for:
230 dissectors, listeners,
231 registering plugins, handingoff plugins,
232 preferences and configuration */
234 main_lb = OBJECT_GET_DATA(win, "protocol_label");
235 /* make_dissector_reg.py changed -
236 so we need to strip off the leading elements to get back to the protocol */
238 if(!strncmp(message, "proto_register_", 15))
240 else if(!strncmp(message, "proto_reg_handoff_", 18))
243 gtk_label_set_text(GTK_LABEL(main_lb), message ? message : "");
247 g_assert (ul_sofar <= ul_count);
249 percentage = (gfloat)ul_sofar/(gfloat)ul_count;
250 ul_percentage = (gulong)(percentage * 100);
252 /* update progress bar */
253 prog_bar = OBJECT_GET_DATA(win, "progress_bar");
254 #if GTK_MAJOR_VERSION < 2
255 gtk_progress_bar_update(GTK_PROGRESS_BAR(prog_bar), percentage);
257 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(prog_bar), percentage);
260 percentage_lb = OBJECT_GET_DATA(win, "percentage_label");
261 g_snprintf(tmp, sizeof(tmp), "%lu%%", ul_percentage);
262 gtk_label_set_text((GtkLabel*)percentage_lb, tmp);
264 /* Process all pending GUI events before continuing, so that
265 the splash screen window gets updated. */
266 while (gtk_events_pending()) gtk_main_iteration();
271 splash_destroy(GtkWidget *win)
273 if (win == NULL) return FALSE;
275 gtk_widget_destroy(win);
281 about_wireshark_page_new(void)
283 GtkWidget *main_vb, *msg_label /*, *icon*/;
286 main_vb = gtk_vbox_new(FALSE, 6);
287 gtk_container_border_width(GTK_CONTAINER(main_vb), 12);
289 about_wireshark(top_level, main_vb);
291 /* Construct the message string */
292 message = g_strdup_printf(
293 "Version " VERSION "%s\n"
301 "Wireshark is Open Source Software released under the GNU General Public License.\n"
303 "Check the man page and http://www.wireshark.org for more information.",
304 wireshark_svnversion, get_copyright_info(), comp_info_str->str,
305 runtime_info_str->str);
307 msg_label = gtk_label_new(message);
309 gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
310 #if GTK_MAJOR_VERSION >= 2
311 gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
313 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
318 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
320 about_authors_page_new(void)
325 absolute_path = get_datafile_path("AUTHORS-SHORT");
326 page = text_page_new(absolute_path);
333 about_folders_row(GtkWidget *table, const char *label, const char *dir, const char *tip)
335 simple_list_append(table, 0, label, 1, dir, 2, tip, -1);
340 about_folders_page_new(void)
343 const char *constpath;
345 const gchar *titles[] = { "Name", "Folder", "Typical Files"};
346 GtkWidget *scrolledwindow;
348 scrolledwindow = scrolled_window_new(NULL, NULL);
349 #if GTK_MAJOR_VERSION >= 2
350 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
354 /* Container for our data */
355 table = simple_list_new(3, titles);
358 about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
362 path = get_tempfile_path("");
363 about_folders_row(table, "Temp", path,
364 "untitled capture files");
365 g_free((void *) path);
368 path = get_persconffile_path("", FALSE);
369 about_folders_row(table, "Personal configuration", path,
370 "\"dfilters\", \"preferences\", \"ethers\", ...");
371 g_free((void *) path);
374 constpath = get_datafile_dir();
375 if (constpath != NULL) {
376 about_folders_row(table, "Global configuration", constpath,
377 "\"dfilters\", \"preferences\", \"manuf\", ...");
381 constpath = get_systemfile_dir();
382 about_folders_row(table, "System", constpath,
383 "\"ethers\", \"ipxnets\"");
386 constpath = get_progfile_dir();
387 about_folders_row(table, "Program", constpath,
392 path = get_plugins_pers_dir();
393 about_folders_row(table, "Personal Plugins", path,
394 "dissector plugins");
395 g_free((void *) path);
398 about_folders_row(table, "Global Plugins", get_plugin_dir(),
399 "dissector plugins");
402 gtk_container_add(GTK_CONTAINER(scrolledwindow), table);
404 return scrolledwindow;
407 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
409 about_license_page_new(void)
414 absolute_path = get_datafile_path("COPYING");
415 page = text_page_new(absolute_path);
422 about_wireshark_cb( GtkWidget *w _U_, gpointer data _U_ )
424 GtkWidget *main_vb, *main_nb, *bbox, *ok_btn;
425 GtkWidget *page_lb, *about_page, *folders_page;
428 GtkWidget *plugins_page;
431 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
432 GtkWidget *authors_page, *license_page;
435 if (about_wireshark_w != NULL) {
436 /* There's already an "About Wireshark" dialog box; reactivate it. */
437 reactivate_window(about_wireshark_w);
442 * XXX - use GtkDialog? The GNOME 2.x GnomeAbout widget does.
443 * Should we use GtkDialog for simple_dialog() as well? Or
444 * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
445 * not? (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
447 about_wireshark_w = dlg_window_new("About Wireshark");
448 /* set the initial position (must be done, before show is called!) */
449 /* default position is not appropriate for the about dialog */
450 #if GTK_MAJOR_VERSION >= 2
451 gtk_window_set_position(GTK_WINDOW(about_wireshark_w), GTK_WIN_POS_CENTER_ON_PARENT);
453 gtk_window_set_position(GTK_WINDOW(about_wireshark_w), GTK_WIN_POS_CENTER);
455 /* setting the size is dangerous here, as making it too short will
456 * clip content on GTK1, so simply use the natural size */
457 /*gtk_window_set_default_size(GTK_WINDOW(about_wireshark_w), 600, 400);*/
458 gtk_container_border_width(GTK_CONTAINER(about_wireshark_w), 6);
460 main_vb = gtk_vbox_new(FALSE, 12);
461 gtk_container_border_width(GTK_CONTAINER(main_vb), 6);
462 gtk_container_add(GTK_CONTAINER(about_wireshark_w), main_vb);
464 main_nb = gtk_notebook_new();
465 gtk_box_pack_start(GTK_BOX(main_vb), main_nb, TRUE, TRUE, 0);
467 about_page = about_wireshark_page_new();
468 page_lb = gtk_label_new("Wireshark");
469 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about_page, page_lb);
471 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
472 authors_page = about_authors_page_new();
473 page_lb = gtk_label_new("Authors");
474 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), authors_page, page_lb);
477 folders_page = about_folders_page_new();
478 page_lb = gtk_label_new("Folders");
479 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), folders_page, page_lb);
482 plugins_page = about_plugins_page_new();
483 page_lb = gtk_label_new("Plugins");
484 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), plugins_page, page_lb);
487 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
488 license_page = about_license_page_new();
489 page_lb = gtk_label_new("License");
490 /* set a minmum width to avoid a lot of line breaks at the wrong places */
491 WIDGET_SET_SIZE(license_page, 600, -1);
492 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), license_page, page_lb);
496 bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
497 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
499 ok_btn = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
500 gtk_widget_grab_focus(ok_btn);
501 gtk_widget_grab_default(ok_btn);
502 window_set_cancel_button(about_wireshark_w, ok_btn, window_cancel_button_cb);
504 SIGNAL_CONNECT(about_wireshark_w, "delete_event", window_delete_event_cb, NULL);
505 SIGNAL_CONNECT(about_wireshark_w, "destroy", about_wireshark_destroy_cb, NULL);
507 gtk_widget_show_all(about_wireshark_w);
508 window_present(about_wireshark_w);
512 about_wireshark_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
514 /* Note that we no longer have an "About Wireshark" dialog box. */
515 about_wireshark_w = NULL;