From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Antono Vasiljev Newsgroups: gmane.emacs.devel,gmane.emacs.bugs Subject: [PATCH]: lisp function for gtk-application-prefer-dark-theme Date: Wed, 30 May 2012 17:14:54 +0300 Message-ID: <87k3ztoiw1.fsf@antono.info> References: <87d35r9ek5.fsf@antono.info> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1338387340 22971 80.91.229.3 (30 May 2012 14:15:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 30 May 2012 14:15:40 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org, emacs-devel@gnu.org To: "Antono Vasiljev" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 30 16:15:37 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SZjgS-0001nr-Br for ged-emacs-devel@m.gmane.org; Wed, 30 May 2012 16:15:32 +0200 Original-Received: from localhost ([::1]:49973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZjgS-0007ix-13 for ged-emacs-devel@m.gmane.org; Wed, 30 May 2012 10:15:32 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZjgI-0007J6-85 for emacs-devel@gnu.org; Wed, 30 May 2012 10:15:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SZjgC-0007m2-4H for emacs-devel@gnu.org; Wed, 30 May 2012 10:15:21 -0400 Original-Received: from antono.info ([50.19.243.116]:45721 helo=mail.antono.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZjg3-0007cd-Lb; Wed, 30 May 2012 10:15:07 -0400 Original-Received: by mail.antono.info (Postfix, from userid 1003) id E7F6763D3B; Wed, 30 May 2012 14:16:15 +0000 (UTC) Original-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) User-agent: mu4e 0.9.8.5-dev3; emacs 24.1.50.15 In-reply-to: <87d35r9ek5.fsf@antono.info> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 50.19.243.116 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:150687 gmane.emacs.bugs:60514 Archived-At: --=-=-= Content-Type: text/plain Antono Vasiljev 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 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 . */ #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 --=-=-=--