summaryrefslogtreecommitdiff
path: root/gtk/hostlist_table.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2010-08-30 14:23:25 +0000
committerAnders Broman <anders.broman@ericsson.com>2010-08-30 14:23:25 +0000
commit60f258b4e5f98daaafd3dd7a717760afc0703863 (patch)
treeb85fefa44ac3cc1492eb85cc03a26fb253443566 /gtk/hostlist_table.c
parente17efa574dc9e667666afb25608c509011732840 (diff)
downloadwireshark-60f258b4e5f98daaafd3dd7a717760afc0703863.tar.gz
Convert to GTKUIManager
svn path=/trunk/; revision=34014
Diffstat (limited to 'gtk/hostlist_table.c')
-rw-r--r--gtk/hostlist_table.c223
1 files changed, 223 insertions, 0 deletions
diff --git a/gtk/hostlist_table.c b/gtk/hostlist_table.c
index 0cc0fe9c94..e5fb8096bb 100644
--- a/gtk/hostlist_table.c
+++ b/gtk/hostlist_table.c
@@ -393,6 +393,8 @@ hostlist_show_popup_menu_cb(void *widg _U_, GdkEvent *event, hostlist_table *et)
return FALSE;
}
+#define HOSTLIST_TABLE_USE_GUIMANAGER 1
+#ifndef HOSTLIST_TABLE_USE_GUIMANAGER
static GtkItemFactoryEntry hostlist_list_menu_items[] =
{
/* Match */
@@ -441,10 +443,205 @@ static GtkItemFactoryEntry hostlist_list_menu_items[] =
GTK_MENU_FUNC(hostlist_select_filter_cb), CALLBACK_COLORIZE(ACTYPE_SELECTED, 0), NULL, NULL,}
};
+#else /* HOSTLIST_TABLE_USE_GUIMANAGER */
+/* Prepare to change GtkItemFactory to GtkUIManager */
+static void
+apply_as_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_SELECTED, 0));
+}
+static void
+apply_as_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_NOT_SELECTED, 0));
+}
+static void
+apply_as_and_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_AND_SELECTED, 0));
+}
+static void
+apply_as_or_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_OR_SELECTED, 0));
+}
+static void
+apply_as_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_AND_NOT_SELECTED, 0));
+}
+static void
+apply_as_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_OR_NOT_SELECTED, 0));
+}
+
+static void
+prep_as_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_SELECTED, 0));
+}
+static void
+prep_as_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_NOT_SELECTED, 0));
+}
+static void
+prep_as_and_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_AND_SELECTED, 0));
+}
+static void
+prep_as_or_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_OR_SELECTED, 0));
+}
+static void
+prep_as_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_AND_NOT_SELECTED, 0));
+}
+static void
+prep_as_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_OR_NOT_SELECTED, 0));
+}
+
+static void
+find_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_FIND_FRAME(ACTYPE_SELECTED, 0));
+}
+static void
+find_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_FIND_FRAME(ACTYPE_NOT_SELECTED, 0));
+}
+static void
+find_prev_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_FIND_PREVIOUS(ACTYPE_SELECTED, 0));
+}
+static void
+find_prev_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_FIND_PREVIOUS(ACTYPE_NOT_SELECTED, 0));
+}
+static void
+find_next_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_FIND_NEXT(ACTYPE_SELECTED, 0));
+}
+static void
+find_next_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_FIND_NEXT(ACTYPE_NOT_SELECTED, 0));
+}
+static void
+color_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_COLORIZE(ACTYPE_SELECTED, 0));
+}
+static void
+color_not_selected_cb(GtkWidget *widget, gpointer user_data)
+{
+ hostlist_select_filter_cb( widget , user_data, CALLBACK_COLORIZE(ACTYPE_SELECTED, 0));
+}
+
+static const char *ui_desc_hostlist_table_popup =
+"<ui>\n"
+" <popup name='HostlistTableFilterPopup'>\n"
+" <menu action='/Apply as Filter'>\n"
+" <menuitem action='/Apply as Filter/Selected'/>\n"
+" <menuitem action='/Apply as Filter/... not Selected'/>\n"
+" <menuitem action='/Apply as Filter/... and Selected'/>\n"
+" <menuitem action='/Apply as Filter/... or Selected'/>\n"
+" <menuitem action='/Apply as Filter/... and not Selected'/>\n"
+" <menuitem action='/Apply as Filter/... or not Selected'/>\n"
+" </menu>\n"
+" <menu action='/Prepare a Filter'>\n"
+" <menuitem action='/Prepare a Filter/Selected'/>\n"
+" <menuitem action='/Prepare a Filter/... not Selected'/>\n"
+" <menuitem action='/Prepare a Filter/... and Selected'/>\n"
+" <menuitem action='/Prepare a Filter/... or Selected'/>\n"
+" <menuitem action='/Prepare a Filter/... and not Selected'/>\n"
+" <menuitem action='/Prepare a Filter/... or not Selected'/>\n"
+" </menu>\n"
+" <menu action='/Find Frame'>\n"
+" <menu action='/Find Frame/Find Frame'>\n"
+" <menuitem action='/Find Frame/Selected'/>\n"
+" <menuitem action='/Find Frame/Not Selected'/>\n"
+" </menu>\n"
+" <menu action='/Find Frame/Find Next'>\n"
+" <menuitem action='/Find Next/Selected'/>\n"
+" <menuitem action='/Find Next/Not Selected'/>\n"
+" </menu>\n"
+" <menu action='/Find Frame/Find Previous'>\n"
+" <menuitem action='/Find Previous/Selected'/>\n"
+" <menuitem action='/Find Previous/Not Selected'/>\n"
+" </menu>\n"
+" </menu>\n"
+" <menu action='/Colorize Procedure'>\n"
+" <menuitem action='/Colorize Procedure/Colorize Host Traffic'/>\n"
+" </menu>\n"
+" </popup>\n"
+"</ui>\n";
+
+/*
+ * GtkActionEntry
+ * typedef struct {
+ * const gchar *name;
+ * const gchar *stock_id;
+ * const gchar *label;
+ * const gchar *accelerator;
+ * const gchar *tooltip;
+ * GCallback callback;
+ * } GtkActionEntry;
+ * const gchar *name; The name of the action.
+ * const gchar *stock_id; The stock id for the action, or the name of an icon from the icon theme.
+ * const gchar *label; The label for the action. This field should typically be marked for translation,
+ * see gtk_action_group_set_translation_domain().
+ * If label is NULL, the label of the stock item with id stock_id is used.
+ * const gchar *accelerator; The accelerator for the action, in the format understood by gtk_accelerator_parse().
+ * const gchar *tooltip; The tooltip for the action. This field should typically be marked for translation,
+ * see gtk_action_group_set_translation_domain().
+ * GCallback callback; The function to call when the action is activated.
+ *
+ */
+static const GtkActionEntry service_resp_t__popup_entries[] = {
+ { "/Apply as Filter", NULL, "Apply as Filter", NULL, NULL, NULL },
+ { "/Prepare a Filter", NULL, "Prepare a Filter", NULL, NULL, NULL },
+ { "/Find Frame", NULL, "Find Frame", NULL, NULL, NULL },
+ { "/Find Frame/Find Frame", NULL, "Find Frame", NULL, NULL, NULL },
+ { "/Find Frame/Find Next", NULL, "Find Next" , NULL, NULL, NULL },
+ { "/Find Frame/Find Previous", NULL, "Find Previous", NULL, NULL, NULL },
+ { "/Colorize Procedure", NULL, "Colorize Procedure", NULL, NULL, NULL },
+ { "/Apply as Filter/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(apply_as_selected_cb) },
+ { "/Apply as Filter/... not Selected", NULL, "... not Selected", NULL, "... not Selected", G_CALLBACK(apply_as_not_selected_cb) },
+ { "/Apply as Filter/... and Selected", NULL, "... and Selected", NULL, "... and Selected", G_CALLBACK(apply_as_and_selected_cb) },
+ { "/Apply as Filter/... or Selected", NULL, "... or Selected", NULL, "... or Selected", G_CALLBACK(apply_as_or_selected_cb) },
+ { "/Apply as Filter/... and not Selected", NULL, "... and not Selected", NULL, "... and not Selected", G_CALLBACK(apply_as_and_not_selected_cb) },
+ { "/Apply as Filter/... or not Selected", NULL, "... or not Selected", NULL, "... or not Selected", G_CALLBACK(apply_as_or_not_selected_cb) },
+ { "/Prepare a Filter/Selected", NULL, "Selected", NULL, "selcted", G_CALLBACK(prep_as_selected_cb) },
+ { "/Prepare a Filter/... not Selected", NULL, "... not Selected", NULL, "... not Selected", G_CALLBACK(prep_as_not_selected_cb) },
+ { "/Prepare a Filter/... and Selected", NULL, "... and Selected", NULL, "... and Selected", G_CALLBACK(prep_as_and_selected_cb) },
+ { "/Prepare a Filter/... or Selected", NULL, "... or Selected", NULL, "... or Selected", G_CALLBACK(prep_as_or_selected_cb) },
+ { "/Prepare a Filter/... and not Selected", NULL, "... and not Selected", NULL, "... and not Selected", G_CALLBACK(prep_as_and_not_selected_cb) },
+ { "/Prepare a Filter/... or not Selected", NULL, "... or not Selected", NULL, "... or not Selected", G_CALLBACK(prep_as_or_not_selected_cb) },
+ { "/Find Frame/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_selected_cb) },
+ { "/Find Frame/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_not_selected_cb) },
+ { "/Find Previous/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_prev_selected_cb) },
+ { "/Find Previous/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_prev_not_selected_cb) },
+ { "/Find Next/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_next_selected_cb) },
+ { "/Find Next/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_next_not_selected_cb) },
+ { "/Colorize Procedure/Colorize Host Traffic",NULL, "Colorize Host Traffic", NULL, "Colorize Host Traffic", G_CALLBACK(color_selected_cb) },
+};
+#endif /* HOSTLIST_TABLE_USE_GUIMANAGER */
static void
hostlist_create_popup_menu(hostlist_table *hl)
{
+#ifndef HOSTLIST_TABLE_USE_GUIMANAGER
GtkItemFactory *item_factory;
item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
@@ -453,6 +650,32 @@ hostlist_create_popup_menu(hostlist_table *hl)
hl->menu = gtk_item_factory_get_widget(item_factory, "<main>");
g_signal_connect(hl->table, "button_press_event", G_CALLBACK(hostlist_show_popup_menu_cb), hl);
+#else
+ GtkUIManager *ui_manager;
+ GtkActionGroup *action_group;
+ GError *error = NULL;
+
+ action_group = gtk_action_group_new ("HostlistTablePopupActionGroup");
+ gtk_action_group_add_actions (action_group, /* the action group */
+ service_resp_t__popup_entries, /* an array of action descriptions */
+ G_N_ELEMENTS(service_resp_t__popup_entries),/* the number of entries */
+ hl); /* data to pass to the action callbacks */
+
+ ui_manager = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (ui_manager,
+ action_group,
+ 0); /* the position at which the group will be inserted */
+ gtk_ui_manager_add_ui_from_string (ui_manager,ui_desc_hostlist_table_popup, -1, &error);
+ if (error != NULL)
+ {
+ fprintf (stderr, "Warning: building hostlist table filter popup failed: %s\n",
+ error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ hl->menu = gtk_ui_manager_get_widget(ui_manager, "/HostlistTableFilterPopup");
+ g_signal_connect(hl->table, "button_press_event", G_CALLBACK(hostlist_show_popup_menu_cb), hl);
+#endif /* HOSTLIST_TABLE_USE_GUIMANAGER */
}