[gimp/gtk3-port: 266/451] app, libgimpwidgets, themes: fix some themeing



commit 163936281db4a47d9126921cacada149f1d213f8
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 1 00:17:27 2018 +0200

    app, libgimpwidgets, themes: fix some themeing
    
    Add CSS names using gtk_widget_class_set_css_name(), remove styling in
    code and instead do it properly in CSS, so far in the System theme.
    All horribly incomplete but a start.

 app/widgets/gimpdock.c             |   71 +-----------------------------------
 app/widgets/gimphistogramview.c    |    2 +
 libgimpwidgets/gimpcolornotebook.c |    2 +
 libgimpwidgets/gimpcolorscale.c    |    9 ++---
 libgimpwidgets/gimpcolorscales.c   |    3 ++
 libgimpwidgets/gimpruler.c         |   47 ++----------------------
 themes/System/gimp.css             |   35 +++++++++++++-----
 7 files changed, 42 insertions(+), 127 deletions(-)
---
diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c
index 8b81e65..d346518 100644
--- a/app/widgets/gimpdock.c
+++ b/app/widgets/gimpdock.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpdock.c
- * Copyright (C) 2001-2005 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2001-2018 Michael Natterer <mitch gimp org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -45,9 +45,6 @@
 #include "gimp-intl.h"
 
 
-#define DEFAULT_DOCK_FONT_SCALE  PANGO_SCALE_SMALL
-
-
 enum
 {
   BOOK_ADDED,
@@ -73,8 +70,6 @@ struct _GimpDockPrivate
 
 static void       gimp_dock_dispose                (GObject      *object);
 
-static void       gimp_dock_style_updated          (GtkWidget    *widget);
-
 static gchar    * gimp_dock_real_get_description   (GimpDock     *dock,
                                                     gboolean      complete);
 static void       gimp_dock_real_book_added        (GimpDock     *dock,
@@ -140,8 +135,6 @@ gimp_dock_class_init (GimpDockClass *klass)
 
   object_class->dispose          = gimp_dock_dispose;
 
-  widget_class->style_updated    = gimp_dock_style_updated;
-
   klass->get_description         = gimp_dock_real_get_description;
   klass->set_host_geometry_hints = NULL;
   klass->book_added              = gimp_dock_real_book_added;
@@ -149,13 +142,7 @@ gimp_dock_class_init (GimpDockClass *klass)
   klass->description_invalidated = NULL;
   klass->geometry_invalidated    = NULL;
 
-  gtk_widget_class_install_style_property (widget_class,
-                                           g_param_spec_double ("font-scale",
-                                                                NULL, NULL,
-                                                                0.0,
-                                                                G_MAXDOUBLE,
-                                                                DEFAULT_DOCK_FONT_SCALE,
-                                                                GIMP_PARAM_READABLE));
+  gtk_widget_class_set_css_name (widget_class, "GimpDock");
 
   g_type_class_add_private (klass, sizeof (GimpDockPrivate));
 }
@@ -223,60 +210,6 @@ gimp_dock_dispose (GObject *object)
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
-static void
-gimp_dock_style_updated (GtkWidget *widget)
-{
-  GimpDock *dock       = GIMP_DOCK (widget);
-  gdouble   font_scale = 1.0;
-
-  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
-
-  gtk_widget_style_get (widget,
-                        "font-scale", &font_scale,
-                        NULL);
-
-  if (font_scale != 1.0)
-    {
-      PangoContext         *context;
-      PangoFontDescription *font_desc;
-      gint                  font_size;
-      gchar                *font_str;
-      gchar                *css_string;
-
-      context = gtk_widget_get_pango_context (widget);
-      font_desc = pango_context_get_font_description (context);
-      font_desc = pango_font_description_copy (font_desc);
-
-      font_size = pango_font_description_get_size (font_desc);
-      font_size = font_scale * font_size;
-      pango_font_description_set_size (font_desc, font_size);
-
-      font_str = pango_font_description_to_string (font_desc);
-      pango_font_description_free (font_desc);
-
-      css_string = g_strdup_printf ("#gimp-internal-dock-%d * {\n"
-                                    "  font: %s;\n"
-                                    "}",
-                                    dock->p->ID,
-                                    font_str);
-      g_free (font_str);
-
-      if (! dock->p->css_provider)
-        {
-          dock->p->css_provider = gtk_css_provider_new ();
-          gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (widget),
-                                                     GTK_STYLE_PROVIDER (dock->p->css_provider),
-                                                     GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-        }
-
-      gtk_css_provider_load_from_data (dock->p->css_provider,
-                                       css_string, -1, NULL);
-      g_free (css_string);
-
-      gtk_widget_reset_style (widget);
-    }
-}
-
 static gchar *
 gimp_dock_real_get_description (GimpDock *dock,
                                 gboolean  complete)
diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c
index a4e2376..a06ec85 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -189,6 +189,8 @@ gimp_histogram_view_class_init (GimpHistogramViewClass *klass)
                                                                NULL, NULL,
                                                                GDK_TYPE_RGBA,
                                                                GIMP_PARAM_READABLE));
+
+  gtk_widget_class_set_css_name (widget_class, "GimpHistogramView");
 }
 
 static void
diff --git a/libgimpwidgets/gimpcolornotebook.c b/libgimpwidgets/gimpcolornotebook.c
index 83ca533..56d9757 100644
--- a/libgimpwidgets/gimpcolornotebook.c
+++ b/libgimpwidgets/gimpcolornotebook.c
@@ -134,6 +134,8 @@ gimp_color_notebook_class_init (GimpColorNotebookClass *klass)
   selector_class->set_model_visible     = gimp_color_notebook_set_model_visible;
   selector_class->set_config            = gimp_color_notebook_set_config;
 
+  gtk_widget_class_set_css_name (widget_class, "GimpColorNotebook");
+
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_enum ("tab-icon-size",
                                                               NULL,
diff --git a/libgimpwidgets/gimpcolorscale.c b/libgimpwidgets/gimpcolorscale.c
index 9a17978..3ceffed 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -143,8 +143,6 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
   widget_class->scroll_event         = gimp_color_scale_scroll;
   widget_class->draw                 = gimp_color_scale_draw;
 
-  gtk_widget_class_set_css_name (widget_class, "GimpColorScale");
-
   /**
    * GimpColorScale:channel:
    *
@@ -161,6 +159,8 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
                                                       GIMP_PARAM_READWRITE |
                                                       G_PARAM_CONSTRUCT));
 
+  gtk_widget_class_set_css_name (widget_class, "GimpColorScale");
+
   g_type_class_add_private (object_class, sizeof (GimpColorScalePrivate));
 
   fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
@@ -200,7 +200,7 @@ gimp_color_scale_init (GimpColorScale *scale)
                                    "  min-width:  24px;"
                                    "  min-height: 24px;"
                                    "}\n"
-                                   "GimpColorScale slider {"
+                                   "GimpColorScale contents trough slider {"
                                    "  min-width:  14px;"
                                    "  min-height: 14px;"
                                    "}",
@@ -280,7 +280,6 @@ gimp_color_scale_size_allocate (GtkWidget     *widget,
 {
   GimpColorScalePrivate *priv  = GET_PRIVATE (widget);
   GtkRange              *range = GTK_RANGE (widget);
-  GtkStyleContext       *style = gtk_widget_get_style_context (widget);
   GdkRectangle           range_rect;
   gint                   focus = 0;
   gint                   trough_border;
@@ -1053,7 +1052,7 @@ gimp_color_scale_render_stipple (GimpColorScale *scale)
   GdkRGBA                color;
   guchar                 r, g, b;
   guchar                *buf;
-  guchar                 insensitive[4];
+  guchar                 insensitive[4] = { 0, };
   guint                  x, y;
 
   if ((buf = priv->buf) == NULL)
diff --git a/libgimpwidgets/gimpcolorscales.c b/libgimpwidgets/gimpcolorscales.c
index 5d81dac..c0ca1be 100644
--- a/libgimpwidgets/gimpcolorscales.c
+++ b/libgimpwidgets/gimpcolorscales.c
@@ -196,6 +196,7 @@ static void
 gimp_color_scales_class_init (GimpColorScalesClass *klass)
 {
   GObjectClass           *object_class   = G_OBJECT_CLASS (klass);
+  GtkWidgetClass         *widget_class   = GTK_WIDGET_CLASS (klass);
   GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
 
   object_class->dispose                 = gimp_color_scales_dispose;
@@ -221,6 +222,8 @@ gimp_color_scales_class_init (GimpColorScalesClass *klass)
                                                          GIMP_PARAM_READWRITE |
                                                          G_PARAM_CONSTRUCT));
 
+  gtk_widget_class_set_css_name (widget_class, "GimpColorScales");
+
   fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
                                babl_format ("CIE LCH(ab) alpha double"));
   fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) alpha double"),
diff --git a/libgimpwidgets/gimpruler.c b/libgimpwidgets/gimpruler.c
index c66f240..b203a17 100644
--- a/libgimpwidgets/gimpruler.c
+++ b/libgimpwidgets/gimpruler.c
@@ -39,7 +39,6 @@
  **/
 
 
-#define DEFAULT_RULER_FONT_SCALE    PANGO_SCALE_SMALL
 #define MINIMUM_INCR                5
 #define IMMEDIATE_REDRAW_THRESHOLD  20
 
@@ -74,7 +73,6 @@ typedef struct
   GdkRectangle     last_pos_rect;
   guint            pos_redraw_idle_id;
   PangoLayout     *layout;
-  gdouble          font_scale;
 
   GList           *track_widgets;
 } GimpRulerPrivate;
@@ -182,8 +180,6 @@ gimp_ruler_class_init (GimpRulerClass *klass)
   widget_class->motion_notify_event  = gimp_ruler_motion_notify;
   widget_class->draw                 = gimp_ruler_draw;
 
-  g_type_class_add_private (object_class, sizeof (GimpRulerPrivate));
-
   g_object_class_install_property (object_class,
                                    PROP_ORIENTATION,
                                    g_param_spec_enum ("orientation",
@@ -242,14 +238,9 @@ gimp_ruler_class_init (GimpRulerClass *klass)
                                                         0.0,
                                                         GIMP_PARAM_READWRITE));
 
-  gtk_widget_class_install_style_property (widget_class,
-                                           g_param_spec_double ("font-scale",
-                                                                "Font Scale",
-                                                                "The size of the used font",
-                                                                0.0,
-                                                                G_MAXDOUBLE,
-                                                                DEFAULT_RULER_FONT_SCALE,
-                                                                GIMP_PARAM_READABLE));
+  gtk_widget_class_set_css_name (widget_class, "GimpRuler");
+
+  g_type_class_add_private (object_class, sizeof (GimpRulerPrivate));
 }
 
 static void
@@ -274,8 +265,6 @@ gimp_ruler_init (GimpRuler *ruler)
   priv->last_pos_rect.width  = 0;
   priv->last_pos_rect.height = 0;
   priv->pos_redraw_idle_id   = 0;
-
-  priv->font_scale          = DEFAULT_RULER_FONT_SCALE;
 }
 
 static void
@@ -959,10 +948,6 @@ gimp_ruler_style_updated (GtkWidget *widget)
 
   GTK_WIDGET_CLASS (gimp_ruler_parent_class)->style_updated (widget);
 
-  gtk_widget_style_get (widget,
-                        "font-scale", &priv->font_scale,
-                        NULL);
-
   priv->backing_store_valid = FALSE;
 
   g_clear_object (&priv->layout);
@@ -1390,30 +1375,6 @@ gimp_ruler_make_pixmap (GimpRuler *ruler)
 }
 
 static PangoLayout *
-gimp_ruler_create_layout (GtkWidget   *widget,
-                          const gchar *text)
-{
-  GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (widget);
-  PangoLayout      *layout;
-  PangoAttrList    *attrs;
-  PangoAttribute   *attr;
-
-  layout = gtk_widget_create_pango_layout (widget, text);
-
-  attrs = pango_attr_list_new ();
-
-  attr = pango_attr_scale_new (priv->font_scale);
-  attr->start_index = 0;
-  attr->end_index   = -1;
-  pango_attr_list_insert (attrs, attr);
-
-  pango_layout_set_attributes (layout, attrs);
-  pango_attr_list_unref (attrs);
-
-  return layout;
-}
-
-static PangoLayout *
 gimp_ruler_get_layout (GtkWidget   *widget,
                        const gchar *text)
 {
@@ -1425,7 +1386,7 @@ gimp_ruler_get_layout (GtkWidget   *widget,
       return priv->layout;
     }
 
-  priv->layout = gimp_ruler_create_layout (widget, text);
+  priv->layout = gtk_widget_create_pango_layout (widget, text);
 
   return priv->layout;
 }
diff --git a/themes/System/gimp.css b/themes/System/gimp.css
index 83779e1..a71c19a 100644
--- a/themes/System/gimp.css
+++ b/themes/System/gimp.css
@@ -22,7 +22,6 @@
 
     -GtkPaned-handle-size:             6;
     -GimpDockWindow-default-height:    300;
-    -GimpDock-font-scale:              0.8333;
     -GimpMenuDock-minimal-width:       200;
     -GimpDockWindow-menu-preview-size: button;
     -GimpToolPalette-tool-icon-size:   button;
@@ -49,29 +48,44 @@ GimpColorNotebook tab {
     padding: 0 0 0 0;
 }
 
-GimpDockbook tab {
+GimpColorScales spinbutton button {
     padding: 0 0 0 0;
 }
 
-GimpDockbook GtkButton {
-//    -GtkWidget-focus-padding: 0;
+GimpColorScales spinbutton entry {
+    min-height: 0;
+}
+
+GimpDock {
+    font-size: smaller;
+}
+
+GimpDock notebook tab {
+    padding: 0 0 0 0;
+}
+
+GimpDock spinbutton button {
+    padding: 0 0 0 0;
+}
+
+GimpDock spinbutton entry {
+    min-height: 0;
 }
 
 GimpDockable {
     -GimpFrame-label-bold:       0;
     -GimpFrame-label-spacing:    2;
-//    -GtkWidget-focus-line-width: 1;
-//    -GtkWidget-focus-padding:    0;
+/*    -GtkWidget-focus-line-width: 1; */
+/*    -GtkWidget-focus-padding:    0; */
 }
 
 GimpDisplayShell {
-    -GimpRuler-font-scale:          0.8333;
     -GimpUnitComboBox-label-scale:  0.8333;
     -GimpScaleComboBox-label-scale: 0.8333;
     -GtkComboBox-arrow-size:        8;
     -GtkButton-inner-border:        0 0 0 0;
-//    -GtkWidget-focus-line_width:    0;
-//    -GtkWidget-focus-padding:       0;
+/*    -GtkWidget-focus-line_width:    0; */
+/*    -GtkWidget-focus-padding:       0; */
 }
 
 GimpColorFrame {
@@ -95,9 +109,10 @@ GimpHistogramView:selected {
 }
 
 GimpOverlayFrame {
-//    -GtkButton-focus-line-width: 1;
+/*    -GtkButton-focus-line-width: 1; */
 }
 
 GimpRuler {
+    font-size: smaller;
     background-color: @bg_color;
 }


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