Commit 8cf774d6 authored by Olof-Joachim Frahm's avatar Olof-Joachim Frahm Committed by Daniel Boles

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.
parent 91f83011
...@@ -2469,6 +2469,7 @@ gtk_popover_bind_model (GtkPopover *popover, ...@@ -2469,6 +2469,7 @@ gtk_popover_bind_model (GtkPopover *popover,
{ {
GtkWidget *child; GtkWidget *child;
GtkWidget *stack; GtkWidget *stack;
GtkStyleContext *style_context;
g_return_if_fail (GTK_IS_POPOVER (popover)); g_return_if_fail (GTK_IS_POPOVER (popover));
g_return_if_fail (model == NULL || G_IS_MENU_MODEL (model)); g_return_if_fail (model == NULL || G_IS_MENU_MODEL (model));
...@@ -2477,6 +2478,8 @@ gtk_popover_bind_model (GtkPopover *popover, ...@@ -2477,6 +2478,8 @@ gtk_popover_bind_model (GtkPopover *popover,
if (child) if (child)
gtk_widget_destroy (child); gtk_widget_destroy (child);
style_context = gtk_widget_get_style_context (GTK_WIDGET (popover));
if (model) if (model)
{ {
stack = gtk_stack_new (); stack = gtk_stack_new ();
...@@ -2494,6 +2497,12 @@ gtk_popover_bind_model (GtkPopover *popover, ...@@ -2494,6 +2497,12 @@ gtk_popover_bind_model (GtkPopover *popover,
g_signal_connect (popover, "unmap", G_CALLBACK (back_to_main), NULL); g_signal_connect (popover, "unmap", G_CALLBACK (back_to_main), NULL);
g_signal_connect (popover, "map", 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);
} }
} }
...@@ -2522,7 +2531,6 @@ gtk_popover_new_from_model (GtkWidget *relative_to, ...@@ -2522,7 +2531,6 @@ gtk_popover_new_from_model (GtkWidget *relative_to,
GMenuModel *model) GMenuModel *model)
{ {
GtkWidget *popover; GtkWidget *popover;
GtkStyleContext *style_context;
g_return_val_if_fail (relative_to == NULL || GTK_IS_WIDGET (relative_to), NULL); 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); g_return_val_if_fail (G_IS_MENU_MODEL (model), NULL);
...@@ -2530,9 +2538,6 @@ gtk_popover_new_from_model (GtkWidget *relative_to, ...@@ -2530,9 +2538,6 @@ gtk_popover_new_from_model (GtkWidget *relative_to,
popover = gtk_popover_new (relative_to); popover = gtk_popover_new (relative_to);
gtk_popover_bind_model (GTK_POPOVER (popover), model, NULL); 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; return popover;
} }
......
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