[gimp/gtk3-port: 437/454] Undeprecate/improve GimpScaleComboBox and GimpUnitComboBox



commit 4b4df4859f2c1631e6e1be876bee1de6708f04f9
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 12 15:34:41 2018 +0200

    Undeprecate/improve GimpScaleComboBox and GimpUnitComboBox
    
    Remove label-scale style properties and gtk_widget_modify_font()
    hacks and theme them using CSS.

 app/display/gimpscalecombobox.c   |   52 ++----------------------------------
 libgimpwidgets/gimpunitcombobox.c |   20 ++------------
 themes/System/gimp.css            |    9 ++++--
 3 files changed, 12 insertions(+), 69 deletions(-)
---
diff --git a/app/display/gimpscalecombobox.c b/app/display/gimpscalecombobox.c
index 55befdf..ae328a6 100644
--- a/app/display/gimpscalecombobox.c
+++ b/app/display/gimpscalecombobox.c
@@ -56,8 +56,6 @@ enum
 static void      gimp_scale_combo_box_constructed     (GObject           *object);
 static void      gimp_scale_combo_box_finalize        (GObject           *object);
 
-static void      gimp_scale_combo_box_style_updated   (GtkWidget         *widget);
-
 static void      gimp_scale_combo_box_changed         (GimpScaleComboBox *combo_box);
 static void      gimp_scale_combo_box_entry_activate  (GtkWidget         *entry,
                                                        GimpScaleComboBox *combo_box);
@@ -82,8 +80,7 @@ static guint scale_combo_box_signals[LAST_SIGNAL] = { 0 };
 static void
 gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass)
 {
-  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
-  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   scale_combo_box_signals[ENTRY_ACTIVATED] =
     g_signal_new ("entry-activated",
@@ -94,20 +91,8 @@ gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass)
                   gimp_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
-  object_class->constructed   = gimp_scale_combo_box_constructed;
-  object_class->finalize      = gimp_scale_combo_box_finalize;
-
-  widget_class->style_updated = gimp_scale_combo_box_style_updated;
-
-  klass->entry_activated      = NULL;
-
-  gtk_widget_class_install_style_property (widget_class,
-                                           g_param_spec_double ("label-scale",
-                                                                NULL, NULL,
-                                                                0.0,
-                                                                G_MAXDOUBLE,
-                                                                1.0,
-                                                                GIMP_PARAM_READABLE));
+  object_class->constructed = gimp_scale_combo_box_constructed;
+  object_class->finalize    = gimp_scale_combo_box_finalize;
 }
 
 static void
@@ -209,37 +194,6 @@ gimp_scale_combo_box_finalize (GObject *object)
 }
 
 static void
-gimp_scale_combo_box_style_updated (GtkWidget *widget)
-{
-  GtkWidget *entry;
-
-  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
-
-  entry = gtk_bin_get_child (GTK_BIN (widget));
-
-  if (entry)
-    {
-      PangoContext         *context;
-      PangoFontDescription *font_desc;
-      gint                  font_size;
-      gdouble               scale;
-
-      gtk_widget_style_get (widget, "label-scale", &scale, NULL);
-
-      context = gtk_widget_get_pango_context (entry);
-      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);
-      pango_font_description_set_size (font_desc, scale * font_size);
-
-      gtk_widget_override_font (entry, font_desc);
-
-      pango_font_description_free (font_desc);
-    }
-}
-
-static void
 gimp_scale_combo_box_changed (GimpScaleComboBox *combo_box)
 {
   GtkTreeIter iter;
diff --git a/libgimpwidgets/gimpunitcombobox.c b/libgimpwidgets/gimpunitcombobox.c
index bf4bdbc..a4f0ab4 100644
--- a/libgimpwidgets/gimpunitcombobox.c
+++ b/libgimpwidgets/gimpunitcombobox.c
@@ -55,15 +55,6 @@ gimp_unit_combo_box_class_init (GimpUnitComboBoxClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   widget_class->style_updated = gimp_unit_combo_box_style_updated;
-
-  gtk_widget_class_install_style_property (widget_class,
-                                           g_param_spec_double ("label-scale",
-                                                                "Label Scale",
-                                                                "The scale for the text cell renderer",
-                                                                0.0,
-                                                                G_MAXDOUBLE,
-                                                                1.0,
-                                                                GIMP_PARAM_READABLE));
 }
 
 static void
@@ -88,23 +79,18 @@ gimp_unit_combo_box_style_updated (GtkWidget *widget)
 {
   GtkCellLayout   *layout;
   GtkCellRenderer *cell;
-  gdouble          scale;
-
-  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
-
-  gtk_widget_style_get (widget, "label-scale", &scale, NULL);
 
   /*  hackedehack ...  */
   layout = GTK_CELL_LAYOUT (gtk_bin_get_child (GTK_BIN (widget)));
   gtk_cell_layout_clear (layout);
 
-  cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
-                       "scale", scale,
-                       NULL);
+  cell = gtk_cell_renderer_text_new ();
   gtk_cell_layout_pack_start (layout, cell, TRUE);
   gtk_cell_layout_set_attributes (layout, cell,
                                   "text",  GIMP_UNIT_STORE_UNIT_SHORT_FORMAT,
                                   NULL);
+
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 }
 
 static void
diff --git a/themes/System/gimp.css b/themes/System/gimp.css
index 9afa16e..9fa7401 100644
--- a/themes/System/gimp.css
+++ b/themes/System/gimp.css
@@ -83,9 +83,12 @@ GimpDockable {
     -GimpFrame-label-spacing:    2;
 }
 
-GimpDisplayShell {
-    -GimpUnitComboBox-label-scale:  0.8333;
-    -GimpScaleComboBox-label-scale: 0.8333;
+GimpDisplayShell combobox entry {
+    font-size: smaller;
+}
+
+GimpDisplayShell combobox button {
+    font-size: smaller;
 }
 
 GimpColorFrame {


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