1999-12-09 20:43:38 +00:00
|
|
|
/* plugins_dlg.c
|
|
|
|
* Dialog boxes for plugins
|
|
|
|
*
|
2002-11-11 15:39:06 +00:00
|
|
|
* $Id: plugins_dlg.c,v 1.28 2002/11/11 15:39:05 oabad Exp $
|
1999-12-09 20:55:49 +00:00
|
|
|
*
|
1999-12-09 20:43:38 +00:00
|
|
|
* Ethereal - Network traffic analyzer
|
2002-01-21 07:37:49 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-12-09 20:55:49 +00:00
|
|
|
* Copyright 1999 Gerald Combs
|
1999-12-09 20:43:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-10-20 04:26:40 +00:00
|
|
|
#include <gtk/gtk.h>
|
1999-12-09 20:43:38 +00:00
|
|
|
|
|
|
|
#include "globals.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/plugins.h>
|
2000-07-05 02:45:42 +00:00
|
|
|
#include "dlg_utils.h"
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
#include "ui_util.h"
|
|
|
|
#endif
|
2002-11-11 15:39:06 +00:00
|
|
|
#include "compat_macros.h"
|
1999-12-09 20:43:38 +00:00
|
|
|
|
2000-01-17 17:12:43 +00:00
|
|
|
#ifdef HAVE_PLUGINS
|
|
|
|
|
1999-12-09 20:43:38 +00:00
|
|
|
static void plugins_close_cb(GtkWidget *, gpointer);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-09 20:43:38 +00:00
|
|
|
static void plugins_scan(GtkWidget *);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
static void plugins_scan(GtkListStore *);
|
|
|
|
#endif
|
1999-12-09 20:43:38 +00:00
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
tools_plugins_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
1999-12-09 20:43:38 +00:00
|
|
|
{
|
|
|
|
GtkWidget *plugins_window;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *main_frame;
|
|
|
|
GtkWidget *frame_hbox;
|
|
|
|
GtkWidget *scrolledwindow;
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *plugins_list;
|
1999-12-09 20:43:38 +00:00
|
|
|
GtkWidget *frame_vbnbox;
|
|
|
|
GtkWidget *main_hbnbox;
|
|
|
|
GtkWidget *close_bn;
|
2001-01-28 21:17:29 +00:00
|
|
|
gchar *titles[] = {"Name", "Version"};
|
2002-11-11 15:39:06 +00:00
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkListStore *store;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
#endif
|
1999-12-09 20:43:38 +00:00
|
|
|
|
2000-08-23 06:56:31 +00:00
|
|
|
plugins_window = dlg_window_new("Ethereal: Plugins");
|
1999-12-09 20:43:38 +00:00
|
|
|
|
|
|
|
main_vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(plugins_window), main_vbox);
|
|
|
|
gtk_widget_show(main_vbox);
|
|
|
|
|
|
|
|
main_frame = gtk_frame_new("Plugins List");
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), main_frame, TRUE, TRUE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_frame), 10);
|
|
|
|
gtk_widget_show(main_frame);
|
|
|
|
|
|
|
|
frame_hbox = gtk_hbox_new(FALSE,0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_frame), frame_hbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(frame_hbox), 5);
|
|
|
|
gtk_widget_show(frame_hbox);
|
|
|
|
|
|
|
|
scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(frame_hbox), scrolledwindow, TRUE, TRUE, 0);
|
2002-11-11 15:39:06 +00:00
|
|
|
WIDGET_SET_SIZE(scrolledwindow, 400, 150);
|
1999-12-09 20:43:38 +00:00
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
|
2002-11-03 17:38:45 +00:00
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
1999-12-09 20:43:38 +00:00
|
|
|
gtk_widget_show(scrolledwindow);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
plugins_list = gtk_clist_new_with_titles(2, titles);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_list);
|
|
|
|
gtk_clist_set_selection_mode(GTK_CLIST(plugins_list), GTK_SELECTION_SINGLE);
|
|
|
|
gtk_clist_column_titles_passive(GTK_CLIST(plugins_list));
|
|
|
|
gtk_clist_column_titles_show(GTK_CLIST(plugins_list));
|
|
|
|
gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 0, TRUE);
|
|
|
|
gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 1, TRUE);
|
|
|
|
plugins_scan(plugins_list);
|
|
|
|
#else
|
2002-11-11 15:39:06 +00:00
|
|
|
store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
|
2002-11-03 17:38:45 +00:00
|
|
|
plugins_scan(store);
|
|
|
|
plugins_list = tree_view_new(GTK_TREE_MODEL(store));
|
|
|
|
gtk_tree_view_set_search_column(GTK_TREE_VIEW(plugins_list), 0);
|
|
|
|
g_object_unref(G_OBJECT(store));
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_list);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
2002-11-11 15:39:06 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes(titles[0], renderer,
|
|
|
|
"text", 0, NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, 0);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(plugins_list), column);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
2002-11-11 15:39:06 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes(titles[1], renderer,
|
|
|
|
"text", 1, NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, 1);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(plugins_list), column);
|
|
|
|
#endif
|
|
|
|
gtk_widget_show(plugins_list);
|
1999-12-09 20:43:38 +00:00
|
|
|
|
|
|
|
frame_vbnbox = gtk_vbutton_box_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(frame_hbox), frame_vbnbox, FALSE, TRUE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(frame_vbnbox), 20);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_button_box_set_layout(GTK_BUTTON_BOX(frame_vbnbox),
|
|
|
|
GTK_BUTTONBOX_SPREAD);
|
1999-12-09 20:43:38 +00:00
|
|
|
gtk_widget_show(frame_vbnbox);
|
|
|
|
|
|
|
|
main_hbnbox = gtk_hbutton_box_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), main_hbnbox, FALSE, TRUE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_hbnbox), 10);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_button_box_set_layout(GTK_BUTTON_BOX(main_hbnbox),
|
|
|
|
GTK_BUTTONBOX_SPREAD);
|
1999-12-09 20:43:38 +00:00
|
|
|
gtk_widget_show(main_hbnbox);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-21 20:11:51 +00:00
|
|
|
close_bn = gtk_button_new_with_label("Close");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
close_bn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
|
|
|
#endif
|
2000-08-21 20:11:51 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(main_hbnbox), close_bn);
|
|
|
|
gtk_widget_show(close_bn);
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(close_bn, "clicked", plugins_close_cb, plugins_window);
|
2000-08-21 20:11:51 +00:00
|
|
|
|
1999-12-09 20:43:38 +00:00
|
|
|
gtk_widget_show(plugins_window);
|
1999-12-26 22:38:07 +00:00
|
|
|
|
1999-12-09 20:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-11-03 17:38:45 +00:00
|
|
|
* Fill the list widget with a list of the plugin modules.
|
1999-12-09 20:43:38 +00:00
|
|
|
*/
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
static void
|
|
|
|
plugins_scan(GtkWidget *list)
|
|
|
|
#else
|
1999-12-09 20:43:38 +00:00
|
|
|
static void
|
2002-11-03 17:38:45 +00:00
|
|
|
plugins_scan(GtkListStore *store)
|
|
|
|
#endif
|
1999-12-09 20:43:38 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
plugin *pt_plug;
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gchar *plugent[2]; /* new entry added in clist */
|
|
|
|
#else
|
|
|
|
GtkTreeIter iter;
|
|
|
|
#endif
|
1999-12-09 20:43:38 +00:00
|
|
|
|
|
|
|
pt_plug = plugin_list;
|
|
|
|
while (pt_plug)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-09 20:43:38 +00:00
|
|
|
plugent[0] = pt_plug->name;
|
2001-01-28 21:17:29 +00:00
|
|
|
plugent[1] = pt_plug->version;
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_clist_append(GTK_CLIST(list), plugent);
|
|
|
|
#else
|
|
|
|
gtk_list_store_append(store, &iter);
|
2002-11-11 15:39:06 +00:00
|
|
|
gtk_list_store_set(store, &iter, 0, pt_plug->name, 1, pt_plug->version,
|
|
|
|
-1);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
1999-12-09 20:43:38 +00:00
|
|
|
pt_plug = pt_plug->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
plugins_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
|
1999-12-09 20:43:38 +00:00
|
|
|
{
|
2000-01-04 20:37:18 +00:00
|
|
|
gtk_grab_remove(GTK_WIDGET(parent_w));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(parent_w));
|
1999-12-09 20:43:38 +00:00
|
|
|
}
|
|
|
|
#endif
|