2 * Dialog boxes for plugins
4 * $Id: plugins_dlg.c,v 1.23 2002/01/21 07:37:42 guy Exp $
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.
31 #ifdef HAVE_SYS_TYPES_H
32 #include <sys/types.h>
40 #include <epan/plugins.h>
41 #include "dlg_utils.h"
45 static void plugins_close_cb(GtkWidget *, gpointer);
46 static void plugins_scan(GtkWidget *);
49 tools_plugins_cmd_cb(GtkWidget *widget, gpointer data)
51 GtkWidget *plugins_window;
53 GtkWidget *main_frame;
54 GtkWidget *frame_hbox;
55 GtkWidget *scrolledwindow;
56 GtkWidget *plugins_clist;
57 GtkWidget *frame_vbnbox;
58 GtkWidget *main_hbnbox;
60 gchar *titles[] = {"Name", "Version"};
62 plugins_window = dlg_window_new("Ethereal: Plugins");
64 main_vbox = gtk_vbox_new(FALSE, 0);
65 gtk_container_add(GTK_CONTAINER(plugins_window), main_vbox);
66 gtk_widget_show(main_vbox);
68 main_frame = gtk_frame_new("Plugins List");
69 gtk_box_pack_start(GTK_BOX(main_vbox), main_frame, TRUE, TRUE, 0);
70 gtk_container_set_border_width(GTK_CONTAINER(main_frame), 10);
71 gtk_widget_show(main_frame);
73 frame_hbox = gtk_hbox_new(FALSE,0);
74 gtk_container_add(GTK_CONTAINER(main_frame), frame_hbox);
75 gtk_container_set_border_width(GTK_CONTAINER(frame_hbox), 5);
76 gtk_widget_show(frame_hbox);
78 scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
79 gtk_box_pack_start(GTK_BOX(frame_hbox), scrolledwindow, TRUE, TRUE, 0);
80 gtk_widget_set_usize(scrolledwindow, 400, 150);
81 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
82 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
83 gtk_widget_show(scrolledwindow);
85 plugins_clist = gtk_clist_new_with_titles(2, titles);
86 gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_clist);
87 gtk_clist_set_selection_mode(GTK_CLIST(plugins_clist), GTK_SELECTION_SINGLE);
88 gtk_clist_column_titles_passive(GTK_CLIST(plugins_clist));
89 gtk_clist_column_titles_show(GTK_CLIST(plugins_clist));
90 gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_clist), 0, TRUE);
91 gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_clist), 1, TRUE);
92 plugins_scan(plugins_clist);
93 gtk_widget_show(plugins_clist);
95 frame_vbnbox = gtk_vbutton_box_new();
96 gtk_box_pack_start(GTK_BOX(frame_hbox), frame_vbnbox, FALSE, TRUE, 0);
97 gtk_container_set_border_width(GTK_CONTAINER(frame_vbnbox), 20);
98 gtk_button_box_set_layout(GTK_BUTTON_BOX(frame_vbnbox), GTK_BUTTONBOX_SPREAD);
99 gtk_widget_show(frame_vbnbox);
101 main_hbnbox = gtk_hbutton_box_new();
102 gtk_box_pack_start(GTK_BOX(main_vbox), main_hbnbox, FALSE, TRUE, 0);
103 gtk_container_set_border_width(GTK_CONTAINER(main_hbnbox), 10);
104 gtk_button_box_set_layout(GTK_BUTTON_BOX(main_hbnbox), GTK_BUTTONBOX_SPREAD);
105 gtk_widget_show(main_hbnbox);
107 close_bn = gtk_button_new_with_label("Close");
108 gtk_container_add(GTK_CONTAINER(main_hbnbox), close_bn);
109 gtk_widget_show(close_bn);
110 gtk_signal_connect(GTK_OBJECT(close_bn), "clicked",
111 GTK_SIGNAL_FUNC(plugins_close_cb), GTK_OBJECT(plugins_window));
113 gtk_widget_show(plugins_window);
118 * Fill the clist widget with a list of the plugin modules.
121 plugins_scan(GtkWidget *clist)
124 gchar *plugent[2]; /* new entry added in clist */
126 pt_plug = plugin_list;
129 plugent[0] = pt_plug->name;
130 plugent[1] = pt_plug->version;
131 gtk_clist_append(GTK_CLIST(clist), plugent);
132 pt_plug = pt_plug->next;
137 plugins_close_cb(GtkWidget *close_bt, gpointer parent_w)
139 gtk_grab_remove(GTK_WIDGET(parent_w));
140 gtk_widget_destroy(GTK_WIDGET(parent_w));