[gimp] Bug 770424 - Themes: insensitive menu item are not readable



commit 337dba62fddbb538ca6de6a05cf7935653535942
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Thu Nov 30 15:40:28 2017 +0100

    Bug 770424 - Themes: insensitive menu item are not readable
    
    Comment by Jehan after review:
    "Quick and dirty hack" but a working one. Since the bug will likely
    disappear with the GTK+3 port (to be verified) which uses another theme
    system, let's just do it this way.

 app/gui/themes.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/app/gui/themes.c b/app/gui/themes.c
index db06605..6be00dc 100644
--- a/app/gui/themes.c
+++ b/app/gui/themes.c
@@ -20,6 +20,9 @@
 #include <stdlib.h>
 
 #include <gegl.h>
+#ifdef GDK_DISABLE_DEPRECATED
+#undef GDK_DISABLE_DEPRECATED
+#endif
 #include <gtk/gtk.h>
 
 #include "libgimpbase/gimpbase.h"
@@ -55,6 +58,61 @@ static void   themes_theme_change_notify (GimpGuiConfig          *config,
 static GHashTable *themes_hash = NULL;
 
 
+static void
+draw_layout (GtkStyle        *style,
+            GdkWindow       *window,
+            GtkStateType     state_type,
+            gboolean         use_text,
+            GdkRectangle    *area,
+            GtkWidget       *widget,
+            const gchar     *detail,
+            gint             x,
+            gint             y,
+            PangoLayout     *layout)
+{
+  GdkGC *gc;
+
+  gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
+
+  if (area)
+    gdk_gc_set_clip_rectangle (gc, area);
+
+  if (state_type == GTK_STATE_INSENSITIVE)
+    {
+      GdkGCValues orig;
+      GdkColor fore;
+      GdkGC *copy = gdk_gc_new (window);
+      guint16 r, g, b;
+
+      gdk_gc_copy (copy, gc);
+
+      gdk_gc_get_values (gc, &orig);
+
+      r = 0x40 + (((orig.foreground.pixel >> 16) & 0xff) >> 1);
+      g = 0x40 + (((orig.foreground.pixel >>  8) & 0xff) >> 1);
+      b = 0x40 + (((orig.foreground.pixel >>  0) & 0xff) >> 1);
+
+      fore.pixel = (r << 16) | (g << 8) | b;
+      fore.red   = r * 257;
+      fore.green = g * 257;
+      fore.blue  = b * 257;
+
+      gdk_gc_set_foreground (copy, &fore);
+
+      gdk_draw_layout (window, copy, x, y, layout);
+
+      g_object_unref (copy);
+    }
+  else
+    {
+      gdk_draw_layout (window, gc, x, y, layout);
+    }
+
+  if (area)
+    gdk_gc_set_clip_rectangle (gc, NULL);
+}
+
+
 /*  public functions  */
 
 void
@@ -65,6 +123,8 @@ themes_init (Gimp *gimp)
 
   g_return_if_fail (GIMP_IS_GIMP (gimp));
 
+  GTK_STYLE_CLASS (g_type_class_ref (g_type_from_name ("PixbufStyle")))->draw_layout = draw_layout;
+
   config = GIMP_GUI_CONFIG (gimp->config);
 
   themes_hash = g_hash_table_new_full (g_str_hash,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]