summaryrefslogtreecommitdiff
path: root/gtk/gtkheaderbar.c
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2019-05-12 09:58:22 +0000
committerFlorian Müllner <fmuellner@gnome.org>2019-05-12 20:09:03 +0000
commit66c8a996f9bbb60e15171650e80e4bb886886490 (patch)
treeb9a3124d6d703c8bd191b33d829b4f219cb6b3c8 /gtk/gtkheaderbar.c
parent1318d3748afba9ef8c476f05cca0516f885faeb7 (diff)
downloadgtk+-66c8a996f9bbb60e15171650e80e4bb886886490.tar.gz
dialog: Use default decoration for non-custom headerbars
There are two ways GTK can add a headerbar to a dialog: - the dialog is constructed with the :use-header-bar property - all windows should use client-side decorations In the first case, the headerbar is added by GtkDialog with no dedicated style class, and in the latter by GtkWindow with the "default-decoration" style. As a result, dialogs with plain titlebars can end up with clearly distinct and inconsistent styles. To address this, allow headerbars to track whether they should use the "default-decoration" style and enable it for dialogs. https://gitlab.gnome.org/GNOME/gtk/merge_requests/836
Diffstat (limited to 'gtk/gtkheaderbar.c')
-rw-r--r--gtk/gtkheaderbar.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index dcdcb4f4fd..aca524df10 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -85,6 +85,7 @@ struct _GtkHeaderBarPrivate
gboolean show_title_buttons;
gchar *decoration_layout;
gboolean decoration_layout_set;
+ gboolean track_default_decoration;
GtkWidget *titlebar_start_box;
GtkWidget *titlebar_end_box;
@@ -499,6 +500,30 @@ _gtk_header_bar_shows_app_menu (GtkHeaderBar *bar)
return priv->show_title_buttons && priv->shows_app_menu;
}
+static void
+update_default_decoration (GtkHeaderBar *bar)
+{
+ GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (bar));
+
+ if (priv->children != NULL || priv->custom_title != NULL)
+ gtk_style_context_remove_class (context, "default-decoration");
+ else
+ gtk_style_context_add_class (context, "default-decoration");
+}
+
+void
+_gtk_header_bar_track_default_decoration (GtkHeaderBar *bar)
+{
+ GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
+
+ priv->track_default_decoration = TRUE;
+
+ update_default_decoration (bar);
+}
+
/* As an intended side effect, this function allows @child
* to be the title/label box */
static void
@@ -1543,6 +1568,9 @@ gtk_header_bar_pack (GtkHeaderBar *bar,
g_signal_connect (widget, "notify::visible", G_CALLBACK (notify_child_cb), bar);
_gtk_header_bar_update_separator_visibility (bar);
+
+ if (priv->track_default_decoration)
+ update_default_decoration (bar);
}
static void
@@ -1595,6 +1623,9 @@ gtk_header_bar_remove (GtkContainer *container,
g_free (child);
gtk_widget_queue_resize (GTK_WIDGET (container));
_gtk_header_bar_update_separator_visibility (bar);
+
+ if (priv->track_default_decoration)
+ update_default_decoration (bar);
}
}