[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11590: [PATCH]: lisp function for gtk-application-prefer-dark-theme
From: |
Lars Ingebrigtsen |
Subject: |
bug#11590: [PATCH]: lisp function for gtk-application-prefer-dark-theme |
Date: |
Sat, 23 Nov 2019 15:39:03 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Dark mode is very trendy now, so it would be nice if Emacs had support
> for telling gtk about that. But I wonder -- would it make sense to
> expose setting gtk_settings stuff more generally to the Emacs Lisp work?
> And then just have a (gtk-settings "gtk-application-prefer-dark-theme")
> call or something...
A complication here is that some settings are boolean and others aren't,
so it's not that trivial, perhaps.
Anyway, I tried to redo the patch, but when I try it on my Debian laptop
(with Gnome, as far as I know), nothing happens, which is disappointing.
Is anything more needed to get dark themes working?
diff --git a/src/xsettings.c b/src/xsettings.c
index c23a5dc72c..bcdc0a12cb 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -1024,6 +1024,36 @@ DEFUN ("tool-bar-get-system-style",
Ftool_bar_get_system_style,
return Qimage;
}
+DEFUN ("set-toolkit-dark-theme",
+ Fset_toolkit_dark_theme,
+ Sset_toolkit_dark_theme,
+ 0, 1, 0,
+ doc: /* Alter the toolkit \"dark theme\" setting.
+If ARG is a positive number, switch the dark theme on; otherwise, switch
+it off.
+
+If the GUI toolkit used does not support altering the dark theme, an
+error will be signalled. */)
+ (Lisp_Object arg)
+{
+#ifdef HAVE_GSETTINGS
+ gboolean dark = FALSE;
+ GtkSettings *settings = gtk_settings_get_for_screen
+ (gdk_display_get_default_screen
+ (gdk_display_get_default ()));
+
+ if (NUMBERP (arg) && XFLOATINT (arg) > 0)
+ dark = TRUE;
+
+ g_object_set (G_OBJECT (settings),
+ "gtk-application-prefer-dark-theme", dark, NULL);
+
+ return Qnil;
+#else
+ user_error ("The toolkit doesn't support altering \"dark theme\" settings");
+#endif
+}
+
void
syms_of_xsettings (void)
{
@@ -1066,6 +1096,10 @@ syms_of_xsettings (void)
#endif
#endif
+#ifdef HAVE_GSETTINGS
+ defsubr (&Sset_toolkit_dark_theme);
+#endif
+
current_tool_bar_style = Qnil;
DEFSYM (Qtool_bar_style, "tool-bar-style");
defsubr (&Stool_bar_get_system_style);
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#11590: [PATCH]: lisp function for gtk-application-prefer-dark-theme,
Lars Ingebrigtsen <=