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"
35 #include "gui_utils.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 "../image/eicon3d64.xpm"
44 #include "gtkglobals.h"
45 #include "version_info.h"
47 #include "plugins_dlg.h"
49 static void about_ethereal_destroy_cb(GtkWidget *, gpointer);
53 * Keep a static pointer to the current "About Ethereal" window, if any, so
54 * that if somebody tries to do "About Ethereal" while there's already an
55 * "About Ethereal" window up, we just pop up the existing one, rather than
58 static GtkWidget *about_ethereal_w;
62 about_ethereal(GtkWidget *parent, GtkWidget *main_vb, const char *title)
64 GtkWidget *msg_label, *icon;
65 #if GTK_MAJOR_VERSION >= 2
69 icon = xpm_to_widget_from_parent(parent, eicon3d64_xpm);
70 gtk_container_add(GTK_CONTAINER(main_vb), icon);
72 msg_label = gtk_label_new(title);
73 #if GTK_MAJOR_VERSION >= 2
74 message = g_strdup_printf("<span size=\"x-large\" weight=\"bold\">%s</span>", title);
75 gtk_label_set_markup(GTK_LABEL(msg_label), message);
78 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
83 splash_new(char *message)
90 win = splash_window_new();
92 /* When calling about_ethereal(), we must realize the top-level
93 widget for the window, otherwise GTK will throw a warning
94 because we don't have a colormap associated with that window and
95 can't handle the pixmap. */
96 gtk_widget_realize(win);
98 main_vb = gtk_vbox_new(FALSE, 6);
99 gtk_container_border_width(GTK_CONTAINER(main_vb), 24);
100 gtk_container_add(GTK_CONTAINER(win), main_vb);
102 about_ethereal(win, main_vb, "Ethereal - Network Protocol Analyzer");
104 main_lb = gtk_label_new(message);
105 gtk_container_add(GTK_CONTAINER(main_vb), main_lb);
106 OBJECT_SET_DATA(win, "splash_label", main_lb);
108 gtk_widget_show_all(win);
110 splash_update(win, message);
116 splash_update(GtkWidget *win, char *message)
120 if (win == NULL) return;
122 main_lb = OBJECT_GET_DATA(win, "splash_label");
123 gtk_label_set_text(GTK_LABEL(main_lb), message);
125 /* Process all pending GUI events before continuing, so that
126 the splash screen window gets updated. */
127 while (gtk_events_pending()) gtk_main_iteration();
131 splash_destroy(GtkWidget *win)
133 if (win == NULL) return FALSE;
135 gtk_widget_destroy(win);
141 about_ethereal_page_new(void)
143 GtkWidget *main_vb, *msg_label /*, *icon*/;
145 const char title[] = "Ethereal - Network Protocol Analyzer";
147 main_vb = gtk_vbox_new(FALSE, 6);
148 gtk_container_border_width(GTK_CONTAINER(main_vb), 12);
150 about_ethereal(top_level, main_vb, title);
152 /* Construct the message string */
153 message = g_strdup_printf(
154 "Version " VERSION "%s"
155 " (C) 1998-2005 Gerald Combs <gerald@ethereal.com>\n\n"
159 "Ethereal is Open Source Software released under the GNU General Public License.\n\n"
161 "Check the man page and http://www.ethereal.com for more information.",
162 svnversion, comp_info_str->str, runtime_info_str->str);
164 msg_label = gtk_label_new(message);
166 gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
167 #if GTK_MAJOR_VERSION >= 2
168 gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
170 gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
175 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
177 about_authors_page_new(void)
182 absolute_path = get_datafile_path("AUTHORS-SHORT");
183 page = text_page_new(absolute_path);
190 about_folders_row(GtkWidget *table, const char *label, const char *dir, const char *tip)
192 simple_list_append(table, 0, label, 1, dir, 2, tip, -1);
197 about_folders_page_new(void)
200 const char *constpath;
202 const gchar *titles[] = { "Name", "Folder", "Typical Files"};
203 GtkWidget *scrolledwindow;
205 scrolledwindow = scrolled_window_new(NULL, NULL);
206 #if GTK_MAJOR_VERSION >= 2
207 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
211 /* Container for our data */
212 table = simple_list_new(3, titles);
215 about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
219 path = get_tempfile_path("");
220 about_folders_row(table, "Temp", path,
221 "untitled capture files");
222 g_free((void *) path);
225 path = get_persconffile_path("", FALSE);
226 about_folders_row(table, "Personal configuration", path,
227 "\"dfilters\", \"preferences\", \"ethers\", ...");
228 g_free((void *) path);
231 constpath = get_datafile_dir();
232 about_folders_row(table, "Global configuration", constpath,
233 "\"dfilters\", \"preferences\", \"manuf\", ...");
236 constpath = get_systemfile_dir();
237 about_folders_row(table, "System", constpath,
238 "\"ethers\", \"ipxnets\"");
241 path = g_strdup(ethereal_path);
242 path = get_dirname(path);
243 about_folders_row(table, "Program", path,
245 g_free((void *) path);
249 path = get_plugins_pers_dir();
250 about_folders_row(table, "Personal Plugins", path,
251 "dissector plugins");
252 g_free((void *) path);
255 path = get_plugins_global_dir(PLUGIN_DIR);
256 about_folders_row(table, "Global Plugins", path,
257 "dissector plugins");
258 g_free((void *) path);
261 gtk_container_add(GTK_CONTAINER(scrolledwindow), table);
263 return scrolledwindow;
268 about_ethereal_cb( GtkWidget *w _U_, gpointer data _U_ )
270 GtkWidget *main_vb, *main_nb, *bbox, *ok_btn;
272 GtkWidget *page_lb, *about_page, *folders_page, *plugins_page;
273 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
274 GtkWidget *authors_page;
277 if (about_ethereal_w != NULL) {
278 /* There's already an "About Ethereal" dialog box; reactivate it. */
279 reactivate_window(about_ethereal_w);
284 * XXX - use GtkDialog? The GNOME 2.x GnomeAbout widget does.
285 * Should we use GtkDialog for simple_dialog() as well? Or
286 * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
287 * not? (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
289 about_ethereal_w = dlg_window_new("About Ethereal");
290 /* set the initial position (must be done, before show is called!) */
291 /* default position is not appropriate for the about dialog */
292 #if GTK_MAJOR_VERSION >= 2
293 gtk_window_set_position(GTK_WINDOW(about_ethereal_w), GTK_WIN_POS_CENTER_ON_PARENT);
295 gtk_window_set_position(GTK_WINDOW(about_ethereal_w), GTK_WIN_POS_CENTER);
297 /* setting the size is dangerous here, as making it too short will
298 * clip content on GTK1, so simply use the natural size */
299 /*gtk_window_set_default_size(GTK_WINDOW(about_ethereal_w), 600, 400);*/
300 gtk_container_border_width(GTK_CONTAINER(about_ethereal_w), 6);
302 main_vb = gtk_vbox_new(FALSE, 12);
303 gtk_container_border_width(GTK_CONTAINER(main_vb), 6);
304 gtk_container_add(GTK_CONTAINER(about_ethereal_w), main_vb);
306 main_nb = gtk_notebook_new();
307 gtk_box_pack_start(GTK_BOX(main_vb), main_nb, TRUE, TRUE, 0);
309 about_page = about_ethereal_page_new();
310 page_lb = gtk_label_new("Ethereal");
311 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about_page, page_lb);
313 #if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
314 authors_page = about_authors_page_new();
315 page_lb = gtk_label_new("Authors");
316 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), authors_page, page_lb);
319 folders_page = about_folders_page_new();
320 page_lb = gtk_label_new("Folders");
321 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), folders_page, page_lb);
324 plugins_page = about_plugins_page_new();
325 page_lb = gtk_label_new("Plugins");
326 gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), plugins_page, page_lb);
330 bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
331 gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
333 ok_btn = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
334 window_set_cancel_button(about_ethereal_w, ok_btn, window_cancel_button_cb);
336 SIGNAL_CONNECT(about_ethereal_w, "delete_event", window_delete_event_cb, NULL);
337 SIGNAL_CONNECT(about_ethereal_w, "destroy", about_ethereal_destroy_cb, NULL);
339 gtk_widget_show_all(about_ethereal_w);
340 window_present(about_ethereal_w);
344 about_ethereal_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
346 /* Note that we no longer have an "About Ethereal" dialog box. */
347 about_ethereal_w = NULL;