Last active
February 4, 2019 20:37
-
-
Save davidmhewitt/1cbb7329701ba766051c12959c804621 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adds a setting to be used by XSETTINGS overrides to configuring forcing | |
GtkDialogs to always use CSD. This is useful in the case where | |
dialogs-use-header is set to false but CSD is still desirable for styling | |
purposes. | |
David Hewitt <davidmhewitt@gmail.com> | |
--- a/gdk/x11/gdksettings.c | |
+++ b/gdk/x11/gdksettings.c | |
@@ -69,6 +69,7 @@ | |
{"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: */ | |
--- a/gtk/gtkdialog.c | |
+++ b/gtk/gtkdialog.c | |
@@ -457,6 +457,8 @@ | |
{ | |
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 @@ | |
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 @@ | |
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); | |
--- a/gtk/gtksettings.c | |
+++ b/gtk/gtksettings.c | |
@@ -224,7 +224,8 @@ | |
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_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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment