GNU bug report logs - #11590
[PATCH]: lisp function for gtk-application-prefer-dark-theme

Previous Next

Package: emacs;

Reported by: Antono Vasiljev <self <at> antono.info>

Date: Wed, 30 May 2012 16:13:03 UTC

Severity: wishlist

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Forwarded to http://lists.gnu.org/archive/html/emacs-devel/2012-05/msg00480.html

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Antono Vasiljev <self <at> antono.info>
Cc: 11590 <at> debbugs.gnu.org
Subject: bug#11590: [PATCH]: lisp function for gtk-application-prefer-dark-theme
Date: Sat, 23 Nov 2019 15:39:03 +0100
Lars Ingebrigtsen <larsi <at> 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




This bug report was last modified 4 years and 273 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.