2 * Dialog boxes for plugins
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "epan/plugins.h"
31 #include "ui/gtk/dlg_utils.h"
32 #include "ui/gtk/gui_utils.h"
33 #include "ui/gtk/plugins_dlg.h"
35 #include "webbrowser.h"
37 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
40 about_plugins_callback(GtkWidget
*widget
, GdkEventButton
*event
, gint id _U_
)
42 GtkTreeSelection
*tree_selection
;
48 tree_selection
= gtk_tree_view_get_selection (GTK_TREE_VIEW(widget
));
50 if (gtk_tree_selection_count_selected_rows (tree_selection
) == 0)
53 if (event
->type
!= GDK_2BUTTON_PRESS
)
54 /* not a double click */
57 if (gtk_tree_selection_get_selected (tree_selection
, &model
, &iter
)) {
58 gtk_tree_model_get (model
, &iter
, 2, &type
, -1);
59 if (strcmp (type
, "lua script") == 0) {
60 gtk_tree_model_get (model
, &iter
, 3, &file
, -1);
61 browser_open_data_file (file
);
71 * Fill the list widget with a list of the plugin modules.
72 * XXX - We might want to combine this with plugins_dump_all().
75 plugins_scan(GtkWidget
*list
)
82 wslua_plugin
*lua_plug
;
87 for (pt_plug
= plugin_list
; pt_plug
!= NULL
; pt_plug
= pt_plug
->next
)
89 type
= g_string_new("");
91 if (pt_plug
->register_protoinfo
)
93 type
= g_string_append(type
, "dissector");
96 if (pt_plug
->register_tap_listener
)
98 type
= g_string_append(type
, sep
);
99 type
= g_string_append(type
, "tap");
102 if (pt_plug
->register_wtap_module
)
104 type
= g_string_append(type
, sep
);
105 type
= g_string_append(type
, "file format");
108 if (pt_plug
->register_codec_module
)
110 type
= g_string_append(type
, sep
);
111 type
= g_string_append(type
, "codec");
113 simple_list_append(list
, 0, pt_plug
->name
, 1, pt_plug
->version
,
114 2, type
->str
, 3, g_module_name(pt_plug
->handle
), -1);
115 g_string_free(type
, TRUE
);
120 for (lua_plug
= wslua_plugin_list
; lua_plug
!= NULL
; lua_plug
= lua_plug
->next
)
122 type
= g_string_new("");
123 type
= g_string_append(type
, "lua script");
125 simple_list_append(list
, 0, lua_plug
->name
, 1, lua_plug
->version
, 2, type
->str
, 3, lua_plug
->filename
, -1);
126 g_string_free(type
, TRUE
);
133 about_plugins_page_new(void)
135 GtkWidget
*scrolledwindow
;
136 GtkWidget
*plugins_list
;
137 static const gchar
*titles
[] = {"Name", "Version", "Type", "Path"};
140 scrolledwindow
= scrolled_window_new(NULL
, NULL
);
141 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow
),
144 plugins_list
= simple_list_new(4, titles
);
145 plugins_scan(plugins_list
);
147 /* connect a callback so we can spot a double-click */
148 g_signal_connect(plugins_list
, "button_press_event",
149 G_CALLBACK(about_plugins_callback
), NULL
);
151 gtk_container_add(GTK_CONTAINER(scrolledwindow
), plugins_list
);
153 return scrolledwindow
;
156 #endif /* HAVE_PLUGINS || HAVE_LUA */