aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/proto_dlg.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2002-12-01 19:11:54 +0000
committerGerald Combs <gerald@wireshark.org>2002-12-01 19:11:54 +0000
commit07e0a47740f7310e36078b65b1bd3be789fa7dea (patch)
treea33364983a9780fe134db2b3f7a5214668e8f522 /gtk/proto_dlg.c
parenteb6384af0d2121367ce99a7a21cf48153fd94bde (diff)
Update some text in the help dialog.
Replace the large matrix of protocol togglebuttons with a GtkCList. The CList displays three columns: the enabled/disabled state, the protocol's abbreviated name and the protocol's full name. Protocols can be enabled or disabled by double-clicking on them. The enable all, disable all, and invert buttons were left intact. I made a half-assed attempt at Gtk2 support by copying code from plugins_dlg.c. It's incomplete, and probably won't compile. Using check boxes in the first column instead of the word "Disabled" would have been nice. GtkCLists don't let you embed anything besides text and pixmaps unfortunately. Update the man page accordingly. We still need a way to save a list of disabled protocols. svn path=/trunk/; revision=6707
Diffstat (limited to 'gtk/proto_dlg.c')
-rw-r--r--gtk/proto_dlg.c359
1 files changed, 224 insertions, 135 deletions
diff --git a/gtk/proto_dlg.c b/gtk/proto_dlg.c
index c6d301437f..a6d6a35f46 100644
--- a/gtk/proto_dlg.c
+++ b/gtk/proto_dlg.c
@@ -1,6 +1,6 @@
/* proto_dlg.c
*
- * $Id: proto_dlg.c,v 1.19 2002/11/28 01:58:27 guy Exp $
+ * $Id: proto_dlg.c,v 1.20 2002/12/01 19:11:54 gerald Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@@ -45,13 +45,21 @@ static void proto_apply_cb(GtkWidget *, gpointer);
static void proto_cancel_cb(GtkWidget *, gpointer);
static void proto_destroy_cb(GtkWidget *, gpointer);
-static void show_proto_selection(GtkWidget *main, GtkWidget *container);
+#if GTK_MAJOR_VERSION < 2
+static void show_proto_selection(GtkCList *proto_list);
+#else
+static void show_proto_selection(GtkListStore *proto_store);
+#endif
static gboolean set_proto_selection(GtkWidget *);
static gboolean revert_proto_selection(void);
static void toggle_all_cb(GtkWidget *button, gpointer parent_w);
static void enable_all_cb(GtkWidget *button, gpointer parent_w);
static void disable_all_cb(GtkWidget *button, gpointer parent_w);
+#if GTK_MAJOR_VERSION < 2
+static void proto_list_select_cb(GtkCList *proto_list, gint row, gint col,
+ GdkEventButton *ev, gpointer gp);
+#endif
static GtkWidget *proto_w = NULL;
@@ -62,21 +70,38 @@ typedef struct protocol_data {
char *name;
char *abbrev;
int hfinfo_index;
- gboolean was_enabled;
+ gboolean enabled;
+#if GTK_MAJOR_VERSION < 2
+ gint row;
+#else
+ GtkTreeIter iter;
+#endif
} protocol_data_t;
-void proto_cb(GtkWidget *w _U_, gpointer data _U_)
+#define DISABLED "Disabled"
+#define STATUS_TXT(x) ((x) ? "" : DISABLED)
+
+void
+proto_cb(GtkWidget *w _U_, gpointer data _U_)
{
- GtkWidget *main_vb, *bbox, *proto_nb, *apply_bt, *cancel_bt, *ok_bt,
- *label, *scrolled_w, *selection_vb, *button;
+ GtkWidget *main_vb, *bbox, *proto_list, *label, *proto_sw, *proto_frame,
+ *proto_vb, *button;
+ gchar *titles[] = { "Status", "Protocol", "Description" };
+ gint width;
+#if GTK_MAJOR_VERSION >= 2
+ GtkListStore *proto_store;
+ GtkCellRenderer *proto_rend;
+ GtkTreeViewColumn *proto_col;
+#endif
+
if (proto_w != NULL) {
reactivate_window(proto_w);
return;
}
- proto_w = dlg_window_new("Ethereal: Protocol");
+ proto_w = dlg_window_new("Ethereal: Enabled Protocols");
SIGNAL_CONNECT(proto_w, "delete_event", proto_delete_cb, NULL);
SIGNAL_CONNECT(proto_w, "destroy", proto_destroy_cb, NULL);
WIDGET_SET_SIZE(proto_w, DEF_WIDTH * 2/3, DEF_HEIGHT * 2/3);
@@ -88,162 +113,228 @@ void proto_cb(GtkWidget *w _U_, gpointer data _U_)
gtk_container_add(GTK_CONTAINER(proto_w), main_vb);
gtk_widget_show(main_vb);
- /* Protocol topics container */
+ /* Protocol selection list ("enable/disable" protocols) */
+
+ proto_frame = gtk_frame_new("Enabled Protocols");
+ gtk_box_pack_start(GTK_BOX(main_vb), proto_frame, TRUE, TRUE, 0);
+ gtk_container_border_width(GTK_CONTAINER(proto_frame), 5);
+ gtk_widget_show(proto_frame);
+
+ /* Protocol list */
+
+ proto_vb = gtk_vbox_new(FALSE, 0);
+ gtk_container_border_width(GTK_CONTAINER(proto_vb), 1);
+ gtk_container_add(GTK_CONTAINER(proto_frame), proto_vb);
+ gtk_container_border_width(GTK_CONTAINER(proto_vb), 5);
+ gtk_widget_show(proto_vb);
+
+ proto_sw = gtk_scrolled_window_new(NULL, NULL);
+ gtk_box_pack_start(GTK_BOX(proto_vb), proto_sw, TRUE, TRUE, 0);
+ gtk_widget_show(proto_sw);
- proto_nb = gtk_notebook_new();
- gtk_container_add(GTK_CONTAINER(main_vb), proto_nb);
- /* XXX do not know why I need this to fill all space around buttons */
- WIDGET_SET_SIZE(proto_nb, DEF_WIDTH * 2/3 - 50, DEF_HEIGHT * 2/3 - 50);
+#if GTK_MAJOR_VERSION < 2
+ proto_list = gtk_clist_new_with_titles(3, titles);
+ gtk_container_add(GTK_CONTAINER(proto_sw), proto_list);
+ gtk_clist_set_selection_mode(GTK_CLIST(proto_list), GTK_SELECTION_SINGLE);
+ gtk_clist_column_titles_passive(GTK_CLIST(proto_list));
+ gtk_clist_column_titles_show(GTK_CLIST(proto_list));
+ gtk_clist_set_column_auto_resize(GTK_CLIST(proto_list), 0, FALSE);
+ gtk_clist_set_column_auto_resize(GTK_CLIST(proto_list), 1, TRUE);
+ gtk_clist_set_column_auto_resize(GTK_CLIST(proto_list), 2, TRUE);
+ width = gdk_string_width(proto_list->style->font, DISABLED);
+ gtk_clist_set_column_width(GTK_CLIST(proto_list), 0, width);
+ SIGNAL_CONNECT(proto_list, "select-row", proto_list_select_cb, NULL);
+ show_proto_selection(GTK_CLIST(proto_list));
+ gtk_widget_show(proto_list);
+#else
+ proto_store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ show_proto_selection(proto_store);
+ proto_list = tree_view_new(GTK_TREE_MODEL(proto_store));
+ gtk_tree_view_set_search_column(GTK_TREE_VIEW(proto_list), 0);
+ g_object_unref(G_OBJECT(proto_store));
+ gtk_container_add(GTK_CONTAINER(proto_sw), proto_list);
+ proto_rend = gtk_cell_renderer_text_new();
+ proto_col = gtk_tree_view_column_new_with_attributes(titles[0], proto_rend,
+ "status", 0, NULL);
+ gtk_tree_view_column_set_sort_column_id(proto_col, 0);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(proto_list), proto_col);
+ proto_rend = gtk_cell_renderer_text_new();
+ proto_col = gtk_tree_view_column_new_with_attributes(titles[1], proto_rend,
+ "abbrev", 1, NULL);
+ gtk_tree_view_column_set_sort_column_id(proto_col, 1);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(proto_list), proto_col);
+ proto_rend = gtk_cell_renderer_text_new();
+ proto_col = gtk_tree_view_column_new_with_attributes(titles[2], proto_rend,
+ "name", 2, NULL);
+ gtk_tree_view_column_set_sort_column_id(proto_col, 2);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(proto_list), proto_col);
+#endif
- /* Protocol selection panel ("enable/disable" protocols) */
- selection_vb = gtk_vbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(selection_vb), 1);
- label = gtk_label_new("Button pressed: protocol decoding is enabled");
- gtk_widget_show(label);
- gtk_box_pack_start(GTK_BOX(selection_vb), label, FALSE, FALSE, 0);
- scrolled_w = scrolled_window_new(NULL, NULL);
- gtk_container_set_border_width(GTK_CONTAINER(scrolled_w), 1);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_w),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
- gtk_box_pack_start(GTK_BOX(selection_vb), scrolled_w, TRUE, TRUE, 0);
- show_proto_selection(proto_w, scrolled_w);
- gtk_widget_show(scrolled_w);
- gtk_widget_show(selection_vb);
- label = gtk_label_new("Decoding");
- gtk_notebook_append_page(GTK_NOTEBOOK(proto_nb), selection_vb, label);
- label = gtk_label_new("Note that when a protocol is disabled, "
- "all linked sub-protocols are as well");
+ label = gtk_label_new("Disabling a protocol prevents higher "
+ "layer protocols from being displayed");
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_widget_show(label);
- gtk_box_pack_start(GTK_BOX(selection_vb), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(proto_vb), label, FALSE, FALSE, 5);
bbox = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
- gtk_box_pack_start(GTK_BOX(selection_vb), bbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(proto_vb), bbox, FALSE, FALSE, 0);
gtk_widget_show(bbox);
- /* Toggle All */
- button = gtk_button_new_with_label("Toggle All");
- SIGNAL_CONNECT(button, "clicked", toggle_all_cb, proto_w);
- gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
/* Enable All */
button = gtk_button_new_with_label("Enable All");
- SIGNAL_CONNECT(button, "clicked", enable_all_cb, proto_w);
+ SIGNAL_CONNECT(button, "clicked", enable_all_cb, proto_list);
gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
/* Disable All */
button = gtk_button_new_with_label("Disable All");
- SIGNAL_CONNECT(button, "clicked", disable_all_cb, proto_w);
+ SIGNAL_CONNECT(button, "clicked", disable_all_cb, proto_list);
gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
+ /* Invert */
+ button = gtk_button_new_with_label("Invert");
+ SIGNAL_CONNECT(button, "clicked", toggle_all_cb, proto_list);
+ gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
- /* XXX add other protocol-related panels here ... */
-
- gtk_widget_show(proto_nb);
/* Ok, Apply, Cancel Buttons */
bbox = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
- gtk_container_add(GTK_CONTAINER(main_vb), bbox);
+ gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
gtk_widget_show(bbox);
#if GTK_MAJOR_VERSION < 2
- ok_bt = gtk_button_new_with_label ("OK");
+ button = gtk_button_new_with_label ("OK");
#else
- ok_bt = gtk_button_new_from_stock(GTK_STOCK_OK);
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
#endif
- SIGNAL_CONNECT(ok_bt, "clicked", proto_ok_cb, proto_w);
- GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX (bbox), ok_bt, TRUE, TRUE, 0);
- gtk_widget_grab_default(ok_bt);
- gtk_widget_show(ok_bt);
+ SIGNAL_CONNECT(button, "clicked", proto_ok_cb, proto_w);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start(GTK_BOX (bbox), button, TRUE, TRUE, 0);
+ gtk_widget_grab_default(button);
+ gtk_widget_show(button);
#if GTK_MAJOR_VERSION < 2
- apply_bt = gtk_button_new_with_label ("Apply");
+ button = gtk_button_new_with_label ("Apply");
#else
- apply_bt = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
#endif
- SIGNAL_CONNECT(apply_bt, "clicked", proto_apply_cb, proto_w);
- GTK_WIDGET_SET_FLAGS(apply_bt, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX (bbox), apply_bt, TRUE, TRUE, 0);
- gtk_widget_show(apply_bt);
+ SIGNAL_CONNECT(button, "clicked", proto_apply_cb, proto_w);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start(GTK_BOX (bbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
#if GTK_MAJOR_VERSION < 2
- cancel_bt = gtk_button_new_with_label ("Cancel");
+ button = gtk_button_new_with_label ("Cancel");
#else
- cancel_bt = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
#endif
- SIGNAL_CONNECT(cancel_bt, "clicked", proto_cancel_cb, proto_w);
- GTK_WIDGET_SET_FLAGS(cancel_bt, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX (bbox), cancel_bt, TRUE, TRUE, 0);
- gtk_widget_show(cancel_bt);
+ SIGNAL_CONNECT(button, "clicked", proto_cancel_cb, proto_w);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start(GTK_BOX (bbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
- dlg_set_cancel(proto_w, cancel_bt);
+ dlg_set_cancel(proto_w, button);
gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(proto_w));
gtk_widget_show(proto_w);
} /* proto_cb */
+#if GTK_MAJOR_VERSION < 2
+static void
+proto_list_select_cb(GtkCList *proto_list, gint row, gint col _U_,
+ GdkEventButton *ev, gpointer gp _U_) {
+ protocol_data_t *p = gtk_clist_get_row_data(proto_list, row);
+
+ if (ev->type == GDK_2BUTTON_PRESS) { /* Double-click */
+ if (p->enabled)
+ p->enabled = FALSE;
+ else
+ p->enabled = TRUE;
+
+ gtk_clist_set_text(proto_list, row, 0, STATUS_TXT(p->enabled) );
+ }
+} /* proto_list_select_cb */
+#endif
+
+/* XXX - We need a callback for Gtk2 */
+
/* Toggle All */
static void
-toggle_all_cb(GtkWidget *button _U_, gpointer parent_w)
+toggle_all_cb(GtkWidget *button _U_, gpointer pl)
{
GSList *entry;
+#if GTK_MAJOR_VERSION < 2
+ GtkCList *proto_list = GTK_CLIST(pl);
+#endif
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
- GtkWidget *button;
protocol_data_t *p = entry->data;
- button = (GtkWidget *)OBJECT_GET_DATA(parent_w, p->abbrev);
- /* gtk_toggle_button_toggled() didn't work for me... */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
- !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
+ if (p->enabled)
+ p->enabled = FALSE;
+ else
+ p->enabled = TRUE;
+
+#if GTK_MAJOR_VERSION < 2
+ gtk_clist_set_text(proto_list, p->row, 0, STATUS_TXT(p->enabled) );
+#endif
}
}
/* Enable/Disable All Helper */
static void
-set_active_all(gpointer parent_w, gboolean new_state)
+set_active_all(GtkWidget *w, gboolean new_state)
{
+#if GTK_MAJOR_VERSION < 2
+ GtkCList *proto_list = GTK_CLIST(w);
+#endif
GSList *entry;
+#if GTK_MAJOR_VERSION < 2
+ gtk_clist_freeze(proto_list);
+#endif
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
- GtkWidget *button;
protocol_data_t *p = entry->data;
-
- button = (GtkWidget *)OBJECT_GET_DATA(parent_w, p->abbrev);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), new_state);
+
+ p->enabled = new_state;
+#if GTK_MAJOR_VERSION < 2
+ gtk_clist_set_text(proto_list, p->row, 0, STATUS_TXT(new_state) );
+#endif
}
+#if GTK_MAJOR_VERSION < 2
+ gtk_clist_thaw(proto_list);
+#endif
}
/* Enable All */
static void
-enable_all_cb(GtkWidget *button _U_, gpointer parent_w)
+enable_all_cb(GtkWidget *button _U_, gpointer pl)
{
- set_active_all(parent_w, TRUE);
+ set_active_all(pl, TRUE);
}
/* Disable All */
static void
-disable_all_cb(GtkWidget *button _U_, gpointer parent_w)
+disable_all_cb(GtkWidget *button _U_, gpointer pl)
{
- set_active_all(parent_w, FALSE);
+ set_active_all(pl, FALSE);
}
-static void proto_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
+static void
+proto_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
{
GSList *entry;
@@ -265,13 +356,15 @@ static void proto_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
XXX - that'll destroy the Protocols dialog; will that upset
a higher-level handler that says "OK, we've been asked to delete
this, so destroy it"? */
-static gboolean proto_delete_cb(GtkWidget *proto_w, gpointer dummy _U_)
+static gboolean
+proto_delete_cb(GtkWidget *proto_w, gpointer dummy _U_)
{
proto_cancel_cb(NULL, proto_w);
return FALSE;
}
-static void proto_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
+static void
+proto_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
{
gboolean redissect;
@@ -281,13 +374,15 @@ static void proto_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
redissect_packets(&cfile);
}
-static void proto_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
+static void
+proto_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
{
if (set_proto_selection(GTK_WIDGET(parent_w)))
redissect_packets(&cfile);
}
-static void proto_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
+static void
+proto_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
{
gboolean redissect;
@@ -297,18 +392,17 @@ static void proto_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
redissect_packets(&cfile);
}
-static gboolean set_proto_selection(GtkWidget *parent_w)
+static gboolean
+set_proto_selection(GtkWidget *parent_w _U_)
{
GSList *entry;
gboolean need_redissect = FALSE;
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
- GtkWidget *button;
protocol_data_t *p = entry->data;
- button = (GtkWidget *)OBJECT_GET_DATA(parent_w, p->abbrev);
- if (proto_is_protocol_enabled(p->hfinfo_index) != GTK_TOGGLE_BUTTON (button)->active) {
- proto_set_decoding(p->hfinfo_index, GTK_TOGGLE_BUTTON (button)->active);
+ if (proto_is_protocol_enabled(p->hfinfo_index) != p->enabled) {
+ proto_set_decoding(p->hfinfo_index, p->enabled);
need_redissect = TRUE;
}
}
@@ -317,7 +411,8 @@ static gboolean set_proto_selection(GtkWidget *parent_w)
} /* set_proto_selection */
-static gboolean revert_proto_selection(void)
+static gboolean
+revert_proto_selection(void)
{
GSList *entry;
gboolean need_redissect = FALSE;
@@ -328,8 +423,8 @@ static gboolean revert_proto_selection(void)
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
protocol_data_t *p = entry->data;
- if (proto_is_protocol_enabled(p->hfinfo_index) != p->was_enabled) {
- proto_set_decoding(p->hfinfo_index, p->was_enabled);
+ if (proto_is_protocol_enabled(p->hfinfo_index) != p->enabled) {
+ proto_set_decoding(p->hfinfo_index, p->enabled);
need_redissect = TRUE;
}
}
@@ -338,7 +433,8 @@ static gboolean revert_proto_selection(void)
} /* revert_proto_selection */
-gint protocol_data_compare(gconstpointer a, gconstpointer b)
+gint
+protocol_data_compare(gconstpointer a, gconstpointer b)
{
const protocol_data_t *ap = (const protocol_data_t *)a;
const protocol_data_t *bp = (const protocol_data_t *)b;
@@ -346,17 +442,22 @@ gint protocol_data_compare(gconstpointer a, gconstpointer b)
return strcmp(ap->abbrev, bp->abbrev);
}
-static void show_proto_selection(GtkWidget *main, GtkWidget *container)
+static void
+#if GTK_MAJOR_VERSION < 2
+show_proto_selection(GtkCList *proto_list)
+#else
+show_proto_selection(GtkListStore *proto_store)
+#endif
{
-
-#define NB_COL 7
-
GSList *entry;
- GtkTooltips *tooltips;
- GtkWidget *table;
- int i, t = 0, l = 0, nb_line, nb_proto = 0;
+ gint i;
void *cookie;
protocol_data_t *p;
+#if GTK_MAJOR_VERSION < 2
+ gchar *proto_text[3];
+#else
+ GtkTreeIter proto_iter;
+#endif
/* Iterate over all the protocols */
@@ -365,48 +466,36 @@ static void show_proto_selection(GtkWidget *main, GtkWidget *container)
if (proto_can_disable_protocol(i)) {
p = g_malloc(sizeof(protocol_data_t));
p->name = proto_get_protocol_name(i);
- p->abbrev = proto_get_protocol_filter_name(i);
+ p->abbrev = proto_get_protocol_short_name(i);
p->hfinfo_index = i;
- p->was_enabled = proto_is_protocol_enabled(i);
+ p->enabled = proto_is_protocol_enabled(i);
protocol_list = g_slist_insert_sorted(protocol_list,
p, protocol_data_compare);
- nb_proto ++;
}
}
- /* create a table (n x NB_COL) of buttons */
-
- nb_line = (nb_proto % NB_COL) ? nb_proto / NB_COL + 1 : nb_proto / NB_COL;
- table = gtk_table_new (nb_line, NB_COL, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE (table), 1);
- gtk_table_set_col_spacings(GTK_TABLE (table), 1);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(container), table);
- gtk_widget_show(table);
-
- tooltips = gtk_tooltips_new();
-
- nb_proto = 0;
-
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
- GtkWidget *button;
-
p = entry->data;
- /* button label is the protocol abbrev */
- button = gtk_toggle_button_new_with_label(p->abbrev);
- /* tip is the complete protocol name */
- gtk_tooltips_set_tip(tooltips, button, p->name, NULL);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),
- proto_is_protocol_enabled(p->hfinfo_index));
- OBJECT_SET_DATA(main, p->abbrev, button);
- gtk_table_attach_defaults (GTK_TABLE (table), button, l, l+1, t, t+1);
- gtk_widget_show (button);
- if (++nb_proto % NB_COL) {
- l++;
- }
- else {
- l = 0;
- t++;
- }
+
+#if GTK_MAJOR_VERSION < 2
+ /* XXX - The preferred way to do this would be to have a check box
+ * in the first column. GtkClists don't let us put arbitrary widgets
+ * in a cell, so we use the word "Disabled" instead. We should be
+ * able to use check boxes in Gtk2, however.
+ */
+ proto_text[0] = STATUS_TXT (p->enabled);
+ proto_text[1] = p->abbrev;
+ proto_text[2] = p->name;
+ p->row = gtk_clist_append(proto_list, proto_text);
+ gtk_clist_set_row_data(proto_list, p->row, p);
+#else
+ gtk_list_store_append(proto_store, &proto_iter);
+ gtk_list_store_set(proto_store, &proto_iter,
+ 0, STATUS_TXT (p->enabled),
+ 1, p->abbrev,
+ 2, p->name,
+ -1);
+#endif
}
} /* show_proto_selection */