diff options
author | Olof-Joachim Frahm <olof@macrolet.net> | 2017-02-26 16:02:49 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2017-05-05 11:37:20 +0200 |
commit | 1681d4ad77fb8d7a6a16387cf44d5ac9b17f72a5 (patch) | |
tree | 294e79ed553d43c85f442b1cf2377cb1442a61da /gtk | |
parent | 00cd92ea71eae5d272f6f7cca58d71a29334ca4c (diff) | |
download | gtk+-1681d4ad77fb8d7a6a16387cf44d5ac9b17f72a5.tar.gz |
Move style change for popover creation.
Creating with `gtk_popover_new_from_model` should be exactly the same as
if via `gtk_popover_new` plus `gtk_popover_bind_model`.
Also remove the style if the model is unbound at any point.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkpopover.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 6c72402cb5..e392766988 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -2298,6 +2298,7 @@ gtk_popover_bind_model (GtkPopover *popover, { GtkWidget *child; GtkWidget *stack; + GtkStyleContext *style_context; g_return_if_fail (GTK_IS_POPOVER (popover)); g_return_if_fail (model == NULL || G_IS_MENU_MODEL (model)); @@ -2306,6 +2307,8 @@ gtk_popover_bind_model (GtkPopover *popover, if (child) gtk_widget_destroy (child); + style_context = gtk_widget_get_style_context (GTK_WIDGET (popover)); + if (model) { stack = gtk_stack_new (); @@ -2322,6 +2325,12 @@ gtk_popover_bind_model (GtkPopover *popover, g_signal_connect (popover, "unmap", G_CALLBACK (back_to_main), NULL); g_signal_connect (popover, "map", G_CALLBACK (back_to_main), NULL); + + gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_MENU); + } + else + { + gtk_style_context_remove_class (style_context, GTK_STYLE_CLASS_MENU); } } @@ -2350,7 +2359,6 @@ gtk_popover_new_from_model (GtkWidget *relative_to, GMenuModel *model) { GtkWidget *popover; - GtkStyleContext *style_context; g_return_val_if_fail (relative_to == NULL || GTK_IS_WIDGET (relative_to), NULL); g_return_val_if_fail (G_IS_MENU_MODEL (model), NULL); @@ -2358,9 +2366,6 @@ gtk_popover_new_from_model (GtkWidget *relative_to, popover = gtk_popover_new (relative_to); gtk_popover_bind_model (GTK_POPOVER (popover), model, NULL); - style_context = gtk_widget_get_style_context (GTK_WIDGET (popover)); - gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_MENU); - return popover; } |