this ain't working (gtkmenu popup still)

From: Date: Sat, 10 Sep 2005 00:49:35 +0000
Subject: this ain't working (gtkmenu popup still)
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-1617@lists.php.net to get a copy of this message
Heya Andrei, following our off-list discussion the other day over GtkMenu::popup()... When I made the changes you suggested, it prevented the menu positioning callback from ever being called :-( Turns out that you can't have optional parameters alongside php_gtk_parse_varargs(). It also crashes PHP when you try, but that's by-the-by. The only way I can find at present for it to not crash is to put 'user args' into an array. But then it just picks up the first argument (and n_args at that point == 3 for some reason I can't fathom). If I force n_args == 1 in call_user_function_ex() it all works nicely without crashing, so long as there's only one argument. GTK expects that argument, if given, to consist of a single widget. It seems (tho' I may have read this thing wrong) that the idea is to make the menu appear somewhere other than where you clicked. The way it's used is only described in one place: gdkwindow.c, where set_user_data is manifested: /** * gdk_window_set_user_data: * @window: a #GdkWindow * @user_data: user data * * For most purposes this function is deprecated in favor of * g_object_set_data(). However, for historical reasons GTK+ stores * the #GtkWidget that owns a #GdkWindow as user data on the * #GdkWindow. So, custom widget implementations should use * this function for that. If GTK+ receives an event for a #GdkWindow, * and the user data for the window is non-%NULL, GTK+ will assume the * user data is a #GtkWidget, and forward the event to that widget. * **/ void gdk_window_set_user_data (GdkWindow *window, gpointer user_data) { g_return_if_fail (window != NULL); ((GdkWindowObject*)window)->user_data = user_data; } /** * gdk_window_get_user_data: * @window: a #GdkWindow * @data: return location for user data * * Retrieves the user data for @window, which is normally the widget * that @window belongs to. See gdk_window_set_user_data(). * **/ void gdk_window_get_user_data (GdkWindow *window, gpointer *data) { g_return_if_fail (window != NULL); *data = ((GdkWindowObject*)window)->user_data; } static void menu_grab_transfer_window_destroy (GtkMenu *menu) { GdkWindow *window = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-window"); if (window) { gdk_window_set_user_data (window, NULL); gdk_window_destroy (window); g_object_set_data (G_OBJECT (menu), "gtk-menu-transfer-window", NULL); } } So what do I do now? My instinct, I have to say, is to forget it completely and just not allow the option. But I should also say I'm currently able to allow a single user parameter to be passed to the 'position' function by adding it to the end of the optional popup() args - it's just that it needs to be in an array to work, anything else upsets it. Clues or 'forget it then' would be good :) - Steph

« previous php.gtk.dev (#1617) next »