From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#11590: [PATCH]: lisp function for gtk-application-prefer-dark-theme Date: Sat, 23 Nov 2019 15:39:03 +0100 Message-ID: <87sgmelks8.fsf@gnus.org> References: <87d35r9ek5.fsf@antono.info> <87k3ztoiw1.fsf@antono.info> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="145503"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 11590@debbugs.gnu.org To: Antono Vasiljev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 23 15:40:25 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iYWaH-000bja-AY for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Nov 2019 15:40:25 +0100 Original-Received: from localhost ([::1]:59242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iYWaG-0001eJ-5c for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Nov 2019 09:40:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48339) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iYWa3-0001Ss-KA for bug-gnu-emacs@gnu.org; Sat, 23 Nov 2019 09:40:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iYWa2-0007BT-D4 for bug-gnu-emacs@gnu.org; Sat, 23 Nov 2019 09:40:11 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iYWa2-0007BO-8V for bug-gnu-emacs@gnu.org; Sat, 23 Nov 2019 09:40:10 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iYWZw-0001aO-Az for bug-gnu-emacs@gnu.org; Sat, 23 Nov 2019 09:40:10 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Nov 2019 14:40:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11590 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 11590-submit@debbugs.gnu.org id=B11590.15745199766026 (code B ref 11590); Sat, 23 Nov 2019 14:40:04 +0000 Original-Received: (at 11590) by debbugs.gnu.org; 23 Nov 2019 14:39:36 +0000 Original-Received: from localhost ([127.0.0.1]:56039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYWZR-0001Z2-Qe for submit@debbugs.gnu.org; Sat, 23 Nov 2019 09:39:34 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:36990) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYWZ7-0001YT-M6 for 11590@debbugs.gnu.org; Sat, 23 Nov 2019 09:39:16 -0500 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iYWYx-0006DU-Qb; Sat, 23 Nov 2019 15:39:06 +0100 In-Reply-To: (Lars Ingebrigtsen's message of "Thu, 27 Jun 2019 17:22:56 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:172304 Archived-At: Lars Ingebrigtsen 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