GNOME Bugzilla – Bug 679454
modelmenu: listen for toplevel changes on the attach widget
Last modified: 2012-07-06 15:14:51 UTC
See attached patch
Created attachment 218100 [details] [review] modelmenu: listen for toplevel changes on the attach widget Right now, when we create a GtkModelMenu for a GMenuModel, we listen to changes to the menu's attach-widget to detect when a toplevel GtkApplicationWindow becomes available to fetch actions from it. This unfortunately breaks this simple code: GtkWidget *application_window = gtk_application_window_new(); GtkWidget *menu_button = gtk_menu_button_new(); GMenuModel *menu_model = get_menu_model(); gtk_menu_button_set_menu_model(menu_button, menu_model); gtk_container_add(GTK_CONTAINER(application_window), menu_button); Since GtkMenuButton creates a GtkModelMenu and sets itself as its attach widget before it's added to a hierarchy containing a GtkApplicationWindow. Fix the bug by simply listening for changes in the window hierarchy, and creating the menu model when the attach widget is added to an application window.
Review of attachment 218100 [details] [review]: Don't you have to disconnect from the signal when detaching ?
Created attachment 218112 [details] [review] menu: notify attach-widget property when menu is detached When the menu is detached, the attach-widget property changes value to NULL, so we should notify a property change, like gtk_menu_attach_to_widget() does.
Created attachment 218113 [details] [review] modelmenu: listen for toplevel changes on the attach widget --- New patch, fixes review comments.
Review of attachment 218112 [details] [review]: clearly right, thanks
Review of attachment 218113 [details] [review]: lgtm
Attachment 218112 [details] pushed as f81bd6c - menu: notify attach-widget property when menu is detached Attachment 218113 [details] pushed as 5dbf3a5 - modelmenu: listen for toplevel changes on the attach widget