Commit 476351d0 authored by Morten Welinder's avatar Morten Welinder

Introspection fixes

parent 53c161e3
......@@ -257,10 +257,10 @@ fixed_context_menu (StfDialogData *pagedata, GdkEventButton *event,
sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_NARROW);
select_column (pagedata, col);
gnm_create_popup_menu (popup_elements, &fixed_context_menu_handler,
pagedata, 0,
sensitivity_filter,
(GdkEvent*)event);
gnm_create_popup_menu (popup_elements,
&fixed_context_menu_handler, pagedata, NULL,
0, sensitivity_filter,
(GdkEvent*)event);
}
static gint
......
......@@ -599,14 +599,28 @@ gnm_gtk_builder_load (char const *uifile, char const *domain, GOCmdContext *cc)
}
static void
popup_item_activate (GtkWidget *item, gpointer *user_data)
popup_item_activate (GtkWidget *item, GnmPopupMenuElement const *elem)
{
GnmPopupMenuElement const *elem =
g_object_get_data (G_OBJECT (item), "descriptor");
GnmPopupMenuHandler handler =
g_object_get_data (G_OBJECT (item), "handler");
g_return_if_fail (elem != NULL);
GtkWidget *menu;
GnmPopupMenuHandler handler;
gpointer user_data;
// Go to top-level menu. This shouldn't be that hard.
menu = item;
while (TRUE) {
if (GTK_IS_MENU_ITEM (menu))
menu = gtk_widget_get_parent (menu);
else if (GTK_IS_MENU (menu)) {
GtkWidget *a = gtk_menu_get_attach_widget (GTK_MENU (menu));
if (a)
menu = a;
else
break;
} else
break;
}
handler = g_object_get_data (G_OBJECT (menu), "handler");
user_data = g_object_get_data (G_OBJECT (menu), "user-data");
g_return_if_fail (handler != NULL);
handler (elem, user_data);
......@@ -615,24 +629,28 @@ popup_item_activate (GtkWidget *item, gpointer *user_data)
/**
* gnm_create_popup_menu:
* @elements:
* @handler: (scope async):
* @handler: (scope notified):
* @user_data: user data to pass to @handler.
* @notify: destroy notification for @user_data
* @display_filter:
* @sensitive_filter:
* @event:
**/
void
gnm_create_popup_menu (GnmPopupMenuElement const *elements,
GnmPopupMenuHandler handler,
gpointer user_data,
int display_filter, int sensitive_filter,
GdkEvent *event)
GnmPopupMenuHandler handler,
gpointer user_data,
GDestroyNotify notify,
int display_filter, int sensitive_filter,
GdkEvent *event)
{
char const *trans;
GSList *menu_stack = NULL;
GtkWidget *menu, *item;
menu = gtk_menu_new ();
g_object_set_data (G_OBJECT (menu), "handler", (gpointer)handler);
g_object_set_data_full (G_OBJECT (menu), "user-data", user_data, notify);
for (; NULL != elements->name ; elements++) {
char const * const name = elements->name;
char const * const pix_name = elements->pixmap;
......@@ -677,12 +695,9 @@ gnm_create_popup_menu (GnmPopupMenuElement const *elements,
if (elements->index > 0) {
g_signal_connect (G_OBJECT (item),
"activate",
G_CALLBACK (&popup_item_activate), user_data);
g_object_set_data (
G_OBJECT (item), "descriptor", (gpointer)(elements));
g_object_set_data (
G_OBJECT (item), "handler", (gpointer)handler);
"activate",
G_CALLBACK (popup_item_activate),
(gpointer)elements);
}
if (NULL != item) {
gtk_widget_show (item);
......
......@@ -59,11 +59,12 @@ typedef void (*GnmPopupMenuHandler) (GnmPopupMenuElement const *e,
gpointer user_data);
void gnm_create_popup_menu (GnmPopupMenuElement const *elements,
GnmPopupMenuHandler handler,
gpointer user_data,
int display_filter,
int sensitive_filter,
GdkEvent *event);
GnmPopupMenuHandler handler,
gpointer user_data,
GDestroyNotify notify,
int display_filter,
int sensitive_filter,
GdkEvent *event);
#define gnm_filter_modifiers(a) ((a) & (GDK_MODIFIER_MASK & (~(GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD5_MASK))))
......
......@@ -847,8 +847,8 @@ item_cursor_popup_menu (GnmItemCursor *ic, GdkEvent *event)
};
gnm_create_popup_menu (popup_elements,
&context_menu_hander, ic,
0, 0, event);
&context_menu_hander, ic, NULL,
0, 0, event);
}
static void
......
......@@ -2532,9 +2532,9 @@ scg_context_menu (SheetControlGUI *scg, GdkEvent *event,
}
gnm_create_popup_menu (popup_elements, &context_menu_handler,
scg, display_filter,
sensitivity_filter, event);
gnm_create_popup_menu (popup_elements,
&context_menu_handler, scg, NULL,
display_filter, sensitivity_filter, event);
}
static gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment