diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-10-26 16:23:31 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-10-29 06:49:59 -0400 |
commit | ef22be9bb7bd50f177218ea9bb5f94d3a9298738 (patch) | |
tree | efce88ece899eab376fa4d7805701c837247fe11 /gtk/gtkmenusectionbox.c | |
parent | 4da281d20b7a6086ee353d176566e2fa0967280a (diff) | |
download | gtk+-ef22be9bb7bd50f177218ea9bb5f94d3a9298738.tar.gz |
Drop GtkModelButton:has-submenu
Replace the has-submenu property with checking menu-name != NULL.
Diffstat (limited to 'gtk/gtkmenusectionbox.c')
-rw-r--r-- | gtk/gtkmenusectionbox.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c index 59a8484481..9c1a5538cc 100644 --- a/gtk/gtkmenusectionbox.c +++ b/gtk/gtkmenusectionbox.c @@ -56,13 +56,14 @@ typedef struct G_DEFINE_TYPE (GtkMenuSectionBox, gtk_menu_section_box, GTK_TYPE_BOX) -void gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box, - MenuData *data); -void gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item, - GtkMenuSectionBox *toplevel, - GtkWidget *focus); -GtkWidget * gtk_menu_section_box_new_section (GtkMenuTrackerItem *item, - GtkMenuSectionBox *parent); +static void gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box, + MenuData *data); +static void gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item, + GtkMenuSectionBox *toplevel, + GtkWidget *focus, + const gchar *name); +static GtkWidget * gtk_menu_section_box_new_section (GtkMenuTrackerItem *item, + GtkMenuSectionBox *parent); static void gtk_menu_section_box_sync_item (GtkWidget *widget, @@ -86,7 +87,7 @@ gtk_menu_section_box_sync_item (GtkWidget *widget, * rule 5: never show separators directly above or below an iconic box * (rule 6: these rules don't apply exactly the same way for subsections) */ -void +static void gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box, MenuData *data) { @@ -234,16 +235,12 @@ close_submenu (GtkWidget *button, gpointer data) { GtkMenuTrackerItem *item = data; - GtkWidget *stack; - GtkWidget *parent; GtkWidget *focus; if (gtk_menu_tracker_item_get_should_request_show (item)) gtk_menu_tracker_item_request_submenu_shown (item, FALSE); focus = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "focus")); - get_ancestors (focus, GTK_TYPE_STACK, &stack, &parent); - gtk_stack_set_visible_child (GTK_STACK (stack), parent); gtk_widget_grab_focus (focus); } @@ -252,16 +249,12 @@ open_submenu (GtkWidget *button, gpointer data) { GtkMenuTrackerItem *item = data; - GtkWidget *stack; - GtkWidget *child; GtkWidget *focus; if (gtk_menu_tracker_item_get_should_request_show (item)) gtk_menu_tracker_item_request_submenu_shown (item, TRUE); focus = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "focus")); - get_ancestors (focus, GTK_TYPE_STACK, &stack, &child); - gtk_stack_set_visible_child (GTK_STACK (stack), child); gtk_widget_grab_focus (focus); } @@ -279,17 +272,25 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item, } else if (gtk_menu_tracker_item_get_has_link (item, G_MENU_LINK_SUBMENU)) { - widget = g_object_new (GTK_TYPE_MODEL_BUTTON, "has-submenu", TRUE, NULL); + GtkWidget *stack = NULL; + GtkWidget *parent = NULL; + gchar *name; + + widget = g_object_new (GTK_TYPE_MODEL_BUTTON, + "menu-name", gtk_menu_tracker_item_get_label (item), + NULL); g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE); g_object_bind_property (item, "icon", widget, "icon", G_BINDING_SYNC_CREATE); g_object_bind_property (item, "sensitive", widget, "sensitive", G_BINDING_SYNC_CREATE); - gtk_menu_section_box_new_submenu (item, box->toplevel, widget); - gtk_widget_show (widget); + + get_ancestors (GTK_WIDGET (box->toplevel), GTK_TYPE_STACK, &stack, &parent); + gtk_container_child_get (GTK_CONTAINER (stack), parent, "name", &name, NULL); + gtk_menu_section_box_new_submenu (item, box->toplevel, widget, name); + g_free (name); } else { widget = gtk_model_button_new (); - g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE); if (box->iconic) @@ -388,10 +389,11 @@ gtk_menu_section_box_new_toplevel (GtkStack *stack, gtk_widget_show (GTK_WIDGET (box)); } -void +static void gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item, GtkMenuSectionBox *toplevel, - GtkWidget *focus) + GtkWidget *focus, + const gchar *name) { GtkMenuSectionBox *box; GtkWidget *button; @@ -399,10 +401,11 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item, box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, "margin", 10, NULL); button = g_object_new (GTK_TYPE_MODEL_BUTTON, - "has-submenu", TRUE, + "menu-name", name, "inverted", TRUE, "centered", TRUE, NULL); + g_object_bind_property (item, "label", button, "text", G_BINDING_SYNC_CREATE); g_object_bind_property (item, "icon", button, "icon", G_BINDING_SYNC_CREATE); @@ -425,7 +428,7 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item, box); } -GtkWidget * +static GtkWidget * gtk_menu_section_box_new_section (GtkMenuTrackerItem *item, GtkMenuSectionBox *parent) { |