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

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11590 in the body.
You can then email your comments to 11590 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11590; Package emacs. (Wed, 30 May 2012 16:13:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Antono Vasiljev <self <at> antono.info>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 30 May 2012 16:13:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Antono Vasiljev <self <at> antono.info>
To: "Antono Vasiljev" <self <at> antono.info>
Cc: bug-gnu-emacs <at> gnu.org, emacs-devel <at> gnu.org
Subject: [PATCH]: lisp function for gtk-application-prefer-dark-theme
Date: Wed, 30 May 2012 17:14:54 +0300
[Message part 1 (text/plain, inline)]
Antono Vasiljev <self <at> antono.info> writes:

> Hello,
>
> I would like to be able setup emacs to use dark GTK theme variant[0].
>
> GTK apps usually provide such possibliity via GSettings property
> gtk-application-prefer-dark-theme[1].  I wonder how can it be binded to
> elisp function (best file for such function).

Replying to myself with initial patch implementing

  application-prefer-dark-theme ARG

See it in action: https://vimeo.com/43078091

[0001-Implemented-lisp-function-application-prefer-dark-th.patch (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]
-- 
http://shelr.tv - plain text screencasts for unix ninjas

Set bug forwarded-to-address to 'http://lists.gnu.org/archive/html/emacs-devel/2012-05/msg00480.html'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 30 May 2012 18:44:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11590; Package emacs. (Thu, 27 Jun 2019 15:24:01 GMT) Full text and rfc822 format available.

Message #10 received at 11590 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Antono Vasiljev <self <at> antono.info>
Cc: 11590 <at> debbugs.gnu.org
Subject: Re: bug#11590: [PATCH]: lisp function for
 gtk-application-prefer-dark-theme
Date: Thu, 27 Jun 2019 17:22:56 +0200
Antono Vasiljev <self <at> antono.info> writes:

>> GTK apps usually provide such possibliity via GSettings property
>> gtk-application-prefer-dark-theme[1].  I wonder how can it be binded to
>> elisp function (best file for such function).

[...]

> +DEFUN ("application-prefer-dark-theme",
> +       Fapplication_prefer_dark_theme,
> +       Sapplication_prefer_dark_theme,
> +       0, 1, 0,
> +       doc: /* Set dark theme variant for application if supported by
> +GUI toolkit and ARG is not nil. */)

[...]

> +  g_object_set (G_OBJECT (gtk_settings),
> +                "gtk-application-prefer-dark-theme", result, NULL);

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...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11590; Package emacs. (Sat, 23 Nov 2019 14:40:04 GMT) Full text and rfc822 format available.

Message #13 received at 11590 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Antono Vasiljev <self <at> antono.info>
Cc: 11590 <at> debbugs.gnu.org
Subject: Re: 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




Removed tag(s) patch. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Mon, 04 May 2020 00:57:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11590; Package emacs. (Thu, 15 Oct 2020 15:05:02 GMT) Full text and rfc822 format available.

Message #18 received at 11590 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Antono Vasiljev <self <at> antono.info>
Cc: 11590 <at> debbugs.gnu.org
Subject: Re: bug#11590: [PATCH]: lisp function for
 gtk-application-prefer-dark-theme
Date: Thu, 15 Oct 2020 17:03:53 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> 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?

Actually, I had it kinda backwards here, and this patch doesn't seem to
be needed (any more): Emacs switches to dark mode (for the Gtk stuff
line menus and toolbars) fine now, as far as I can see.  And being able
to notify Gtk about this from Emacs (instead of the other way around)
probably doesn't make sense anyway?  So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 11590 <at> debbugs.gnu.org and Antono Vasiljev <self <at> antono.info> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 15 Oct 2020 15:05:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 13 Nov 2020 12:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 163 days ago.

Previous Next


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