We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
[metze/wireshark/wip.git] / ui / gtk / plugins_dlg.c
1 /* plugins_dlg.c
2  * Dialog boxes for plugins
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #include "config.h"
26
27 #include <gtk/gtk.h>
28
29 #include "epan/plugins.h"
30
31 #include "ui/gtk/dlg_utils.h"
32 #include "ui/gtk/gui_utils.h"
33 #include "ui/gtk/plugins_dlg.h"
34
35
36 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
37
38 /*
39  * Fill the list widget with a list of the plugin modules.
40  * XXX - We might want to combine this with plugins_dump_all().
41  */
42 static void
43 plugins_scan(GtkWidget *list)
44 {
45 #ifdef HAVE_PLUGINS
46     plugin     *pt_plug;
47     const char *sep;
48 #endif
49 #ifdef HAVE_LUA
50     wslua_plugin  *lua_plug;
51 #endif
52     GString    *type;
53
54 #ifdef HAVE_PLUGINS
55     for (pt_plug = plugin_list; pt_plug != NULL; pt_plug = pt_plug->next)
56     {
57         type = g_string_new("");
58         sep = "";
59         if (pt_plug->register_protoinfo)
60         {
61             type = g_string_append(type, "dissector");
62             sep = ", ";
63         }
64         if (pt_plug->register_tap_listener)
65         {
66             type = g_string_append(type, sep);
67             type = g_string_append(type, "tap");
68             sep = ", ";
69         }
70         if (pt_plug->register_wtap_module)
71         {
72             type = g_string_append(type, sep);
73             type = g_string_append(type, "file format");
74             sep = ", ";
75         }
76         if (pt_plug->register_codec_module)
77         {
78             type = g_string_append(type, sep);
79             type = g_string_append(type, "codec");
80         }
81         simple_list_append(list, 0, pt_plug->name, 1, pt_plug->version,
82                            2, type->str, 3, g_module_name(pt_plug->handle), -1);
83         g_string_free(type, TRUE);
84     }
85 #endif
86
87 #ifdef HAVE_LUA
88     for (lua_plug = wslua_plugin_list; lua_plug != NULL; lua_plug = lua_plug->next)
89     {
90         type = g_string_new("");
91         type = g_string_append(type, "lua script");
92
93         simple_list_append(list, 0, lua_plug->name, 1, lua_plug->version, 2, type->str, 3, lua_plug->filename, -1);
94         g_string_free(type, TRUE);
95     }
96 #endif
97 }
98
99
100 GtkWidget *
101 about_plugins_page_new(void)
102 {
103     GtkWidget *scrolledwindow;
104     GtkWidget *plugins_list;
105     const gchar     *titles[] = {"Name", "Version", "Type", "Path"};
106
107
108     scrolledwindow = scrolled_window_new(NULL, NULL);
109     gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
110                                    GTK_SHADOW_IN);
111
112     plugins_list = simple_list_new(4, titles);
113     plugins_scan(plugins_list);
114
115     gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_list);
116
117     return scrolledwindow;
118 }
119
120 #endif /* HAVE_PLUGINS || HAVE_LUA */