5 * Ulf Lamping <ulf.lamping@web.de>
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <epan/filesystem.h>
33 #include <epan/plugins.h>
34 #include "about_dlg.h"
36 #include "dlg_utils.h"
37 #include "compat_macros.h"
39 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
40 #include "text_page.h"
43 #include "svnversion.h"
45 #include "../image/eicon3d64.xpm"
46 #include "gtkglobals.h"
48 extern GString *comp_info_str, *runtime_info_str;
51 extern GtkWidget *about_plugins_page_new(void);
54 static void about_ethereal_destroy_cb(GtkWidget *, gpointer);
58 * Keep a static pointer to the current "About Ethereal" window, if any, so
59 * that if somebody tries to do "About Ethereal" while there's already an
60 * "About Ethereal" window up, we just pop up the existing one, rather than
63 static GtkWidget *about_ethereal_w;
67 about_ethereal(GtkWidget *parent, GtkWidget *main_vb, const char *title)
69 GtkWidget *msg_label, *icon;
70 #if GTK_MAJOR_VERSION >= 2
74 icon = xpm_to_widget_from_parent(parent, eicon3d64_xpm);
75 gtk_container_add(GTK_CONTAINER(main_vb), icon);
77 msg_label = gtk_label_new(title);
78 #if GTK_MAJOR_VERSION >= 2
79 message = g_strdup_printf("<span size=\"x-large\" weight=\"bold\">%s</span>", title);
80 gtk_label_set_markup(GTK_LABEL(msg_label), message);
83 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
88 splash_new(char *message)
95 win = splash_window_new();
97 /* When calling about_ethereal(), we must realize the top-level
98 widget for the window, otherwise GTK will throw a warning
99 because we don't have a colormap associated with that window and
100 can't handle the pixmap. */
101 gtk_widget_realize(win);
103 main_vb = gtk_vbox_new(FALSE, 6);
104 gtk_container_border_width(GTK_CONTAINER(main_vb), 24);
105 gtk_container_add(GTK_CONTAINER(win), main_vb);
107 about_ethereal(win, main_vb, "Ethereal - Network Protocol Analyzer");
109 main_lb = gtk_label_new(message);
110 gtk_container_add(GTK_CONTAINER(main_vb), main_lb);
111 OBJECT_SET_DATA(win, "splash_label", main_lb);
113 gtk_widget_show_all(win);
115 splash_update(win, message);
121 splash_update(GtkWidget *win, char *message)
125 if (win == NULL) return;
127 main_lb = OBJECT_GET_DATA(win, "splash_label");
128 gtk_label_set_text(GTK_LABEL(main_lb), message);
130 /* Process all pending GUI events before continuing, so that
131 the splash screen window gets updated. */
132 while (gtk_events_pending()) gtk_main_iteration();
136 splash_destroy(GtkWidget *win)
138 if (win == NULL) return FALSE;
140 gtk_widget_destroy(win);
146 about_ethereal_page_new(void)
148 GtkWidget *main_vb, *msg_label /*, *icon*/;
150 const char title[] = "Ethereal - Network Protocol Analyzer";
152 main_vb = gtk_vbox_new(FALSE, 6);
153 gtk_container_border_width(GTK_CONTAINER(main_vb), 12);
155 about_ethereal(top_level, main_vb, title);
157 /* Construct the message string */
158 message = g_strdup_printf(
163 " (C) 1998-2005 Gerald Combs <gerald@ethereal.com>\n\n"
167 "Ethereal is Open Source Software released under the GNU General Public License.\n\n"
169 "Check the man page and http://www.ethereal.com for more information.",
170 comp_info_str->str, runtime_info_str->str);
172 msg_label = gtk_label_new(message);
174 gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
175 #if GTK_MAJOR_VERSION >= 2
176 gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
178 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
183 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
185 about_authors_page_new(void)
190 absolute_path = get_datafile_path("AUTHORS-SHORT");
191 page = text_page_new(absolute_path);
198 about_folders_row(GtkWidget *table, const char *label, const char *dir, const char *tip)
200 simple_list_append(table, 0, label, 1, dir, 2, tip, -1);
205 about_folders_page_new(void)
208 const char *constpath;
210 const gchar *titles[] = { "Name", "Folder", "Typical Files"};
211 GtkWidget *scrolledwindow;
213 scrolledwindow = scrolled_window_new(NULL, NULL);
214 #if GTK_MAJOR_VERSION >= 2
215 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
219 /* Container for our data */
220 table = simple_list_new(3, titles);
223 about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
227 path = get_tempfile_path("");
228 about_folders_row(table, "Temp", path,
229 "untitled capture files");
230 g_free((void *) path);
233 path = get_persconffile_path("", FALSE);
234 about_folders_row(table, "Personal configuration", path,
235 "\"dfilters\", \"preferences\", \"ethers\", ...");
236 g_free((void *) path);
239 constpath = get_datafile_dir();
240 about_folders_row(table, "Global configuration", constpath,
241 "\"dfilters\", \"preferences\", \"manuf\", ...");
244 constpath = get_systemfile_dir();
245 about_folders_row(table, "System", constpath,
246 "\"ethers\", \"ipxnets\"");
249 path = g_strdup(ethereal_path);
250 path = get_dirname(path);
251 about_folders_row(table, "Program", path,
253 g_free((void *) path);
257 path = get_plugins_pers_dir();
258 about_folders_row(table, "Personal Plugins", path,
259 "dissector plugins");
260 g_free((void *) path);
263 path = get_plugins_global_dir(PLUGIN_DIR);
264 about_folders_row(table, "Global Plugins", path,
265 "dissector plugins");
266 g_free((void *) path);
269 gtk_container_add(GTK_CONTAINER(scrolledwindow), table);
271 return scrolledwindow;
276 about_ethereal_cb( GtkWidget *w _U_, gpointer data _U_ )
278 GtkWidget *main_vb, *main_nb, *bbox, *ok_btn;
280 GtkWidget *page_lb, *about_page, *folders_page, *plugins_page;
281 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
282 GtkWidget *authors_page;
285 if (about_ethereal_w != NULL) {
286 /* There's already an "About Ethereal" dialog box; reactivate it. */
287 reactivate_window(about_ethereal_w);
292 * XXX - use GtkDialog? The GNOME 2.x GnomeAbout widget does.
293 * Should we use GtkDialog for simple_dialog() as well? Or
294 * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
295 * not? (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
297 about_ethereal_w = dlg_window_new("About Ethereal");
298 /* set the initial position (must be done, before show is called!) */
299 /* default position is not appropriate for the about dialog */
300 #if GTK_MAJOR_VERSION >= 2
301 gtk_window_set_position(GTK_WINDOW(about_ethereal_w), GTK_WIN_POS_CENTER_ON_PARENT);
303 gtk_window_set_position(GTK_WINDOW(about_ethereal_w), GTK_WIN_POS_CENTER);
305 /* setting the size is dangerous here, as making it too short will
306 * clip content on GTK1, so simply use the natural size */
307 /*gtk_window_set_default_size(GTK_WINDOW(about_ethereal_w), 600, 400);*/
308 gtk_container_border_width(GTK_CONTAINER(about_ethereal_w), 6);
310 main_vb = gtk_vbox_new(FALSE, 12);
311 gtk_container_border_width(GTK_CONTAINER(main_vb), 6);
312 gtk_container_add(GTK_CONTAINER(about_ethereal_w), main_vb);
314 main_nb = gtk_notebook_new();
315 gtk_box_pack_start(GTK_BOX(main_vb), main_nb, TRUE, TRUE, 0);
317 about_page = about_ethereal_page_new();
318 page_lb = gtk_label_new("Ethereal");
319 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about_page, page_lb);
321 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
322 authors_page = about_authors_page_new();
323 page_lb = gtk_label_new("Authors");
324 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), authors_page, page_lb);
327 folders_page = about_folders_page_new();
328 page_lb = gtk_label_new("Folders");
329 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), folders_page, page_lb);
332 plugins_page = about_plugins_page_new();
333 page_lb = gtk_label_new("Plugins");
334 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), plugins_page, page_lb);
338 bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
339 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
341 ok_btn = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
342 window_set_cancel_button(about_ethereal_w, ok_btn, window_cancel_button_cb);
344 SIGNAL_CONNECT(about_ethereal_w, "delete_event", window_delete_event_cb, NULL);
345 SIGNAL_CONNECT(about_ethereal_w, "destroy", about_ethereal_destroy_cb, NULL);
347 gtk_widget_show_all(about_ethereal_w);
348 window_present(about_ethereal_w);
352 about_ethereal_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
354 /* Note that we no longer have an "About Ethereal" dialog box. */
355 about_ethereal_w = NULL;