Commit 7e4b6d8a authored by David Hewitt's avatar David Hewitt

Add setting to select whether to force dialogs to always use CSD

parent 5b360f21
Pipeline #57242 passed with stage
in 8 minutes and 8 seconds
......@@ -69,6 +69,7 @@ static const struct {
{"Gtk/RecentFilesMaxAge", "gtk-recent-files-max-age"},
{"Gtk/RecentFilesEnabled", "gtk-recent-files-enabled"},
{"Gtk/KeynavUseCaret", "gtk-keynav-use-caret"},
{"Gtk/DialogsAlwaysCSD", "gtk-dialogs-always-csd"},
/* These are here in order to be recognized, but are not sent to
gtk as they are handled internally by gdk: */
......
......@@ -457,6 +457,8 @@ gtk_dialog_constructed (GObject *object)
{
GtkDialog *dialog = GTK_DIALOG (object);
GtkDialogPrivate *priv = dialog->priv;
GtkSettings *settings;
gboolean always_csd;
G_OBJECT_CLASS (gtk_dialog_parent_class)->constructed (object);
......@@ -464,6 +466,9 @@ gtk_dialog_constructed (GObject *object)
if (priv->use_header_bar == -1)
priv->use_header_bar = FALSE;
settings = gtk_widget_get_settings (GTK_WIDGET (dialog));
g_object_get (settings, "gtk-dialogs-always-csd", &always_csd, NULL);
if (priv->use_header_bar)
{
GList *children, *l;
......@@ -494,6 +499,13 @@ gtk_dialog_constructed (GObject *object)
g_signal_connect (priv->action_area, "add", G_CALLBACK (add_cb), dialog);
}
else if (always_csd)
{
g_object_set (priv->headerbar, "has-subtitle", FALSE, NULL);
GtkStyleContext *context = gtk_widget_get_style_context (priv->headerbar);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TITLEBAR);
gtk_style_context_add_class (context, "default-decoration");
}
else
{
gtk_window_set_titlebar (GTK_WINDOW (dialog), NULL);
......
......@@ -224,7 +224,8 @@ enum {
PROP_ENABLE_PRIMARY_PASTE,
PROP_RECENT_FILES_ENABLED,
PROP_LONG_PRESS_TIME,
PROP_KEYNAV_USE_CARET
PROP_KEYNAV_USE_CARET,
PROP_DIALOGS_ALWAYS_CSD
};
/* --- prototypes --- */
......@@ -1767,6 +1768,23 @@ gtk_settings_class_init (GtkSettingsClass *class)
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_KEYNAV_USE_CARET);
/**
* GtkSettings:gtk-dialogs-always-csd:
*
* Whether GTK+ should make all dialogs use client side decorations
* even when gtk-dialogs-use-header is set to false
*
* Since: 3.22
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-dialogs-always-csd",
P_("Whether to always use CSD in dialogs"),
P_("Whether to always use CSD in dialogs"),
FALSE,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_DIALOGS_ALWAYS_CSD);
}
static void
......
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