all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: martin rudalics <rudalics@gmx.at>, 28189@debbugs.gnu.org
Subject: bug#28189: 26.0.50; Emacs uses deprecated function gtk_window_parse_geometry
Date: Tue, 19 Sep 2017 16:38:47 +0000	[thread overview]
Message-ID: <CAArVCkQ8Ys-s7MNi0q5K++3K=x1wbHzq-p_hJHHggTWMWZt8Kg@mail.gmail.com> (raw)
In-Reply-To: <CAArVCkQ-Z3akKxaC3w91JQrAR4UX+bCmFpfk-KOBVdcpGSLMkQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 702 bytes --]

Philipp Stephani <p.stephani2@gmail.com> schrieb am Di., 19. Sep. 2017 um
17:35 Uhr:

> martin rudalics <rudalics@gmx.at> schrieb am So., 3. Sep. 2017 um
> 13:49 Uhr:
>
>>
>>  > The underlying issue here is that GTK no longer seems to have a
>> concept of
>>  > a "background color", but Emacs still assumes that concept exists.
>>
>> I understand.  But can't we catch that in a less intimidating way?
>>
>
> If you only talk about code restructuring, then sure. But if we want to
> emulate (instead of just disable) background colors, then some more work is
> needed.
>
>

At least setting the background color should be doable in a non-deprecated
way using a custom CSS provider, see attached patch.

[-- Attachment #1.2: Type: text/html, Size: 1547 bytes --]

[-- Attachment #2: 0001-GTK-Use-a-style-provider-instead-of-deprecated-functio.txt --]
[-- Type: text/plain, Size: 1858 bytes --]

From 3d933f46ec74e4b76c34feb7aa52fc8db7f3bd88 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sun, 27 Aug 2017 12:42:56 +0200
Subject: [PATCH] GTK+: Use a style provider instead of deprecated function

* src/gtkutil.c (xg_set_widget_bg): Use a CSS style provider instead
of the deprecated gtk_widget_override_background_color.
---
 src/gtkutil.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gtkutil.c b/src/gtkutil.c
index 9dc74d4a56..4ea04befcf 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1050,16 +1050,23 @@ static void
 xg_set_widget_bg (struct frame *f, GtkWidget *w, unsigned long pixel)
 {
 #ifdef HAVE_GTK3
-  GdkRGBA bg;
   XColor xbg;
   xbg.pixel = pixel;
   if (XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &xbg))
     {
-      bg.red = (double)xbg.red/65535.0;
-      bg.green = (double)xbg.green/65535.0;
-      bg.blue = (double)xbg.blue/65535.0;
-      bg.alpha = 1.0;
-      gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &bg);
+      const char format[] = "* { background-color: #%02x%02x%02x; }";
+      /* The format is always longer than the resulting string.  */
+      char buffer[sizeof format];
+      int n = snprintf(buffer, sizeof buffer, format,
+                       xbg.red >> 8, xbg.green >> 8, xbg.blue >> 8);
+      eassert(n > 0);
+      eassert (n < sizeof buffer);
+      GtkCssProvider *provider = gtk_css_provider_new ();
+      gtk_css_provider_load_from_data (provider, buffer, -1, NULL);
+      gtk_style_context_add_provider (gtk_widget_get_style_context(w),
+                                      GTK_STYLE_PROVIDER (provider),
+                                      GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+      g_object_unref (provider);
     }
 #else
   GdkColor bg;
-- 
2.14.1.690.gbb1197296e-goog


  reply	other threads:[~2017-09-19 16:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 20:22 bug#28189: 26.0.50; Emacs uses deprecated function gtk_window_parse_geometry Philipp
2017-08-23  8:46 ` martin rudalics
2017-08-23 10:38   ` Philipp Stephani
2017-08-23 13:19     ` martin rudalics
2017-08-23 23:26       ` Philipp Stephani
2017-08-24  9:37         ` martin rudalics
2017-08-25  9:28         ` Philipp Stephani
2017-08-26  9:29           ` martin rudalics
2017-08-27 13:34             ` Philipp Stephani
2017-09-03 11:49               ` martin rudalics
2017-09-19 15:35                 ` Philipp Stephani
2017-09-19 16:38                   ` Philipp Stephani [this message]
2017-09-23 11:22               ` Philipp Stephani
2017-09-23 13:21                 ` martin rudalics
2017-09-23 13:28                   ` Eli Zaretskii
2017-09-23 16:32                     ` Philipp Stephani
2017-09-23 16:48                       ` Eli Zaretskii
2017-09-23 18:28                     ` martin rudalics
2017-09-23 18:31                       ` Eli Zaretskii
2017-09-23 16:36                   ` Philipp Stephani
2017-09-23 18:29                     ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAArVCkQ8Ys-s7MNi0q5K++3K=x1wbHzq-p_hJHHggTWMWZt8Kg@mail.gmail.com' \
    --to=p.stephani2@gmail.com \
    --cc=28189@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.