"ssn_range" needs to be a copy of "global_ssn_range", so that it's not
[obnox/wireshark/wip.git] / gtk / plugins_dlg.c
1 /* plugins_dlg.c
2  * Dialog boxes for plugins
3  *
4  * $Id$
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1999 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include <gtk/gtk.h>
30
31 #include "globals.h"
32 #include <epan/plugins.h>
33 #include "dlg_utils.h"
34 #include "ui_util.h"
35 #include "compat_macros.h"
36
37 #ifdef HAVE_PLUGINS
38
39 static void plugins_destroy_cb(GtkWidget *, gpointer);
40
41 /*
42  * Keep a static pointer to the current "Plugins" window, if any, so that
43  * if somebody tries to do "Help->About Plugins" while there's already a
44  * "Plugins" window up, we just pop up the existing one, rather than
45  * creating a new one.
46 */
47 static GtkWidget *plugins_window = NULL;
48
49
50
51 /*
52  * Fill the list widget with a list of the plugin modules.
53  */
54 static void
55 plugins_scan(GtkWidget *list)
56 {
57     plugin     *pt_plug;
58
59     pt_plug = plugin_list;
60     while (pt_plug)
61     {
62     simple_list_append(list, 0, pt_plug->name, 1, pt_plug->version, -1);
63         pt_plug = pt_plug->next;
64     }
65 }
66
67
68 GtkWidget *
69 about_plugins_page_new(void)
70 {
71     GtkWidget *scrolledwindow;
72     GtkWidget *plugins_list;
73     gchar     *titles[] = {"Name", "Version"};
74
75     
76     scrolledwindow = scrolled_window_new(NULL, NULL);
77 #if GTK_MAJOR_VERSION >= 2
78     gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), 
79                                    GTK_SHADOW_IN);
80 #endif
81
82     plugins_list = simple_list_new(2, titles);
83     plugins_scan(plugins_list);
84
85     gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_list);
86
87     return scrolledwindow;
88 }
89
90 void
91 tools_plugins_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
92 {
93     GtkWidget *main_vbox;
94     GtkWidget *main_frame;
95     GtkWidget *frame_hbox;
96     GtkWidget *page;
97     GtkWidget *bbox;
98     GtkWidget *ok_bt;
99
100     if (plugins_window != NULL) {
101         /* There's already a "Plugins" dialog box; reactivate it. */
102         reactivate_window(plugins_window);
103         return;
104     }
105
106     plugins_window = dlg_window_new("Ethereal: Plugins");
107     gtk_window_set_default_size(GTK_WINDOW(plugins_window), 250, 200);
108
109     main_vbox = gtk_vbox_new(FALSE, 0);
110     gtk_container_add(GTK_CONTAINER(plugins_window), main_vbox);
111
112     main_frame = gtk_frame_new("Plugins List");
113     gtk_box_pack_start(GTK_BOX(main_vbox), main_frame, TRUE, TRUE, 0);
114     gtk_container_set_border_width(GTK_CONTAINER(main_frame), 5);
115
116     frame_hbox = gtk_hbox_new(FALSE,0);
117     gtk_container_add(GTK_CONTAINER(main_frame), frame_hbox);
118     gtk_container_set_border_width(GTK_CONTAINER(frame_hbox), 5);
119
120     page = about_plugins_page_new();
121     gtk_box_pack_start(GTK_BOX(frame_hbox), page, TRUE, TRUE, 0);
122
123     /* button row */
124     bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
125     gtk_box_pack_end(GTK_BOX(main_vbox), bbox, FALSE, FALSE, 3);
126
127     ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
128     window_set_cancel_button(plugins_window, ok_bt, window_cancel_button_cb);
129
130     SIGNAL_CONNECT(plugins_window, "delete_event", window_delete_event_cb, NULL);
131     SIGNAL_CONNECT(plugins_window, "destroy", plugins_destroy_cb, NULL);
132
133     gtk_widget_show_all(plugins_window);
134     window_present(plugins_window);
135 }
136
137 static void
138 plugins_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
139 {
140     /* Note that we no longer have a Plugins window. */
141     plugins_window = NULL;
142 }
143
144
145 #endif /* HAVE_PLUGINS */