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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Antono Vasiljev <self@HIDDEN>; Keywords: patch; Forwarded to http://lists.gnu.org/archive/html/emacs-devel/2012-05/msg00480.html; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 11590 <at> debbugs.gnu.org:


Received: (at 11590) by debbugs.gnu.org; 27 Jun 2019 15:23:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 27 11:23:03 2019
Received: from localhost ([127.0.0.1]:39271 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgWEp-0008Pd-8y
	for submit <at> debbugs.gnu.org; Thu, 27 Jun 2019 11:23:03 -0400
Received: from quimby.gnus.org ([80.91.231.51]:43866)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1hgWEm-0008P3-3C
 for 11590 <at> debbugs.gnu.org; Thu, 27 Jun 2019 11:23:01 -0400
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories)
 by quimby.gnus.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89)
 (envelope-from <larsi@HIDDEN>)
 id 1hgWEi-0006zq-7j; Thu, 27 Jun 2019 17:22:58 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Antono Vasiljev <self@HIDDEN>
Subject: Re: bug#11590: [PATCH]: lisp function for
 gtk-application-prefer-dark-theme
References: <87d35r9ek5.fsf@HIDDEN> <87k3ztoiw1.fsf@HIDDEN>
Date: Thu, 27 Jun 2019 17:22:56 +0200
In-Reply-To: <87k3ztoiw1.fsf@HIDDEN> (Antono Vasiljev's message of "Wed, 
 30 May 2012 17:14:54 +0300")
Message-ID: <m3r27f59yn.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Antono Vasiljev <self@HIDDEN> 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).
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11590
Cc: 11590 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Antono Vasiljev <self@HIDDEN> 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@HIDDEN:
bug#11590; Package emacs. Full text available.
Set bug forwarded-to-address to 'http://lists.gnu.org/archive/html/emacs-devel/2012-05/msg00480.html'. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 30 May 2012 16:12:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 30 12:12:59 2012
Received: from localhost ([127.0.0.1]:50482 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1SZlW6-0004bZ-Mu
	for submit <at> debbugs.gnu.org; Wed, 30 May 2012 12:12:59 -0400
Received: from eggs.gnu.org ([208.118.235.92]:33225)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <self@HIDDEN>) id 1SZjhp-0001BH-GQ
	for submit <at> debbugs.gnu.org; Wed, 30 May 2012 10:17:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <self@HIDDEN>) id 1SZjgC-0007mT-KI
	for submit <at> debbugs.gnu.org; Wed, 30 May 2012 10:15:22 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI
	autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:58253)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <self@HIDDEN>) id 1SZjgC-0007mO-Gz
	for submit <at> debbugs.gnu.org; Wed, 30 May 2012 10:15:16 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58856)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <self@HIDDEN>) id 1SZjg6-0006iQ-5G
	for bug-gnu-emacs@HIDDEN; Wed, 30 May 2012 10:15:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <self@HIDDEN>) id 1SZjg3-0007i8-Pv
	for bug-gnu-emacs@HIDDEN; Wed, 30 May 2012 10:15:09 -0400
Received: from antono.info ([50.19.243.116]:45721 helo=mail.antono.info)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <self@HIDDEN>)
	id 1SZjg3-0007cd-Lb; Wed, 30 May 2012 10:15:07 -0400
Received: by mail.antono.info (Postfix, from userid 1003)
	id E7F6763D3B; Wed, 30 May 2012 14:16:15 +0000 (UTC)
Received: from libero.antono.info (unknown [178.120.49.50])
	(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
	(No client certificate requested) (Authenticated sender: antono)
	by mail.antono.info (Postfix) with ESMTPSA id F395060989;
	Wed, 30 May 2012 14:16:07 +0000 (UTC)
From: Antono Vasiljev <self@HIDDEN>
To: "Antono Vasiljev" <self@HIDDEN>
Subject: [PATCH]: lisp function for gtk-application-prefer-dark-theme
References: <87d35r9ek5.fsf@HIDDEN>
User-agent: mu4e 0.9.8.5-dev3; emacs 24.1.50.15
In-reply-to: <87d35r9ek5.fsf@HIDDEN>
Date: Wed, 30 May 2012 17:14:54 +0300
Message-ID: <87k3ztoiw1.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.118.235.17
X-Spam-Score: -6.9 (------)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 30 May 2012 12:12:56 -0400
Cc: bug-gnu-emacs@HIDDEN, emacs-devel@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

--=-=-=
Content-Type: text/plain


Antono Vasiljev <self@HIDDEN> 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


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-Implemented-lisp-function-application-prefer-dark-th.patch
Content-Description: application-prefer-dark-theme implementation

From 7679c96fb785bc682b086f08482411311d12f84a Mon Sep 17 00:00:00 2001
From: Antono Vasiljev <self@HIDDEN>
Date: Wed, 30 May 2012 16:56:42 +0300
Subject: [PATCH] Implemented lisp function application-prefer-dark-theme

* src/xsettings.c: GtkSetting and function definition
* src/xsettings.h: EXFUN macro for application-prefer-dark-theme
---
 src/xsettings.c |   32 ++++++++++++++++++++++++++++++++
 src/xsettings.h |    1 +
 2 files changed, 33 insertions(+)

diff --git a/src/xsettings.c b/src/xsettings.c
index 69ef22f..d8c01c7 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -201,6 +201,7 @@ struct xsettings
 /* The single GSettings instance, or NULL if not connected to GSettings.  */
 
 static GSettings *gsettings_client;
+static GtkSettings *gtk_settings;
 
 /* Callback called when something changed in GSettings.  */
 
@@ -824,6 +825,8 @@ init_gsettings (void)
   g_signal_connect (G_OBJECT (gsettings_client), "changed",
                     G_CALLBACK (something_changed_gsettingsCB), NULL);
 
+  gtk_settings = gtk_settings_get_default ();
+
   val = g_settings_get_value (gsettings_client, GSETTINGS_TOOL_BAR_STYLE);
   if (val)
     {
@@ -1004,6 +1007,30 @@ known style.  Otherwise return image.  */)
   return Qimage;
 }
 
+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. */)
+  (Lisp_Object arg)
+{
+  gboolean result = FALSE;
+
+#ifdef HAVE_GSETTINGS
+  if (NILP (arg) || (NUMBERP(arg) && (XINT(arg) < 0))) {
+    result = FALSE;
+  } else {
+    result = TRUE;
+  }
+
+  g_object_set (G_OBJECT (gtk_settings),
+                "gtk-application-prefer-dark-theme", result, NULL);
+#endif
+
+  return result ? Fmake_symbol (build_string ("t")) : Qnil;
+}
+
 void
 syms_of_xsettings (void)
 {
@@ -1012,6 +1039,7 @@ syms_of_xsettings (void)
   first_dpyinfo = NULL;
 #ifdef HAVE_GSETTINGS
   gsettings_client = NULL;
+  gtk_settings = NULL;
 #endif
 #ifdef HAVE_GCONF
   gconf_client = NULL;
@@ -1041,6 +1069,10 @@ If this variable is nil, Emacs ignores system font changes.  */);
 #endif
 #endif
 
+#ifdef HAVE_GSETTINGS
+  defsubr (&Sapplication_prefer_dark_theme);
+#endif
+
   current_tool_bar_style = Qnil;
   DEFSYM (Qtool_bar_style, "tool-bar-style");
   defsubr (&Stool_bar_get_system_style);
diff --git a/src/xsettings.h b/src/xsettings.h
index d6b0c09..83b5cfc 100644
--- a/src/xsettings.h
+++ b/src/xsettings.h
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define XSETTINGS_H
 
 EXFUN (Ftool_bar_get_system_style, 0);
+EXFUN (Fapplication_prefer_dark_theme, 1);
 
 extern void xsettings_initialize (struct x_display_info *dpyinfo);
 extern void xft_settings_event (struct x_display_info *dpyinfo,
-- 
1.7.9.5


--=-=-=
Content-Type: text/plain


-- 
http://shelr.tv - plain text screencasts for unix ninjas

--=-=-=--




Acknowledgement sent to Antono Vasiljev <self@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#11590; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 27 Jun 2019 15:30:02 UTC

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