2 * Dialog boxes for plugins
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1999 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <epan/plugins.h>
33 #include "dlg_utils.h"
34 #include "gui_utils.h"
35 #include "compat_macros.h"
36 #include "plugins_dlg.h"
40 static void plugins_destroy_cb(GtkWidget *, gpointer);
43 * Keep a static pointer to the current "Plugins" window, if any, so that
44 * if somebody tries to do "Help->About Plugins" while there's already a
45 * "Plugins" window up, we just pop up the existing one, rather than
48 static GtkWidget *plugins_window = NULL;
53 * Fill the list widget with a list of the plugin modules.
56 plugins_scan(GtkWidget *list)
62 pt_plug = plugin_list;
65 type = g_string_new("");
67 if (pt_plug->register_protoinfo)
69 type = g_string_append(type, sep);
70 type = g_string_append(type, "dissector");
73 if (pt_plug->register_tap_listener)
75 type = g_string_append(type, sep);
76 type = g_string_append(type, "tap");
79 simple_list_append(list, 0, pt_plug->name, 1, pt_plug->version,
81 g_string_free(type, TRUE);
82 pt_plug = pt_plug->next;
88 about_plugins_page_new(void)
90 GtkWidget *scrolledwindow;
91 GtkWidget *plugins_list;
92 const gchar *titles[] = {"Name", "Version", "Type"};
95 scrolledwindow = scrolled_window_new(NULL, NULL);
96 #if GTK_MAJOR_VERSION >= 2
97 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
101 plugins_list = simple_list_new(3 , titles);
102 plugins_scan(plugins_list);
104 gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_list);
106 return scrolledwindow;
110 tools_plugins_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
112 GtkWidget *main_vbox;
113 GtkWidget *main_frame;
114 GtkWidget *frame_hbox;
119 if (plugins_window != NULL) {
120 /* There's already a "Plugins" dialog box; reactivate it. */
121 reactivate_window(plugins_window);
125 plugins_window = dlg_window_new("Ethereal: Plugins");
126 gtk_window_set_default_size(GTK_WINDOW(plugins_window), 250, 200);
128 main_vbox = gtk_vbox_new(FALSE, 0);
129 gtk_container_add(GTK_CONTAINER(plugins_window), main_vbox);
131 main_frame = gtk_frame_new("Plugins List");
132 gtk_box_pack_start(GTK_BOX(main_vbox), main_frame, TRUE, TRUE, 0);
133 gtk_container_set_border_width(GTK_CONTAINER(main_frame), 5);
135 frame_hbox = gtk_hbox_new(FALSE,0);
136 gtk_container_add(GTK_CONTAINER(main_frame), frame_hbox);
137 gtk_container_set_border_width(GTK_CONTAINER(frame_hbox), 5);
139 page = about_plugins_page_new();
140 gtk_box_pack_start(GTK_BOX(frame_hbox), page, TRUE, TRUE, 0);
143 bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
144 gtk_box_pack_end(GTK_BOX(main_vbox), bbox, FALSE, FALSE, 3);
146 ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
147 window_set_cancel_button(plugins_window, ok_bt, window_cancel_button_cb);
149 SIGNAL_CONNECT(plugins_window, "delete_event", window_delete_event_cb, NULL);
150 SIGNAL_CONNECT(plugins_window, "destroy", plugins_destroy_cb, NULL);
152 gtk_widget_show_all(plugins_window);
153 window_present(plugins_window);
157 plugins_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
159 /* Note that we no longer have a Plugins window. */
160 plugins_window = NULL;
164 #endif /* HAVE_PLUGINS */