[gimp] libgimpwidgets, app: make ABBREVIATED default GimpIntComboBox layout



commit 0830fe8923227a69880aa06f1b96c68e9dcc1799
Author: Ell <ell_se yahoo com>
Date:   Fri Dec 1 08:35:46 2017 -0500

    libgimpwidgets, app: make ABBREVIATED default GimpIntComboBox layout
    
    There's no real reason not to do it (has no visible effect if the
    model has no abbreviations to begin with), and it means less
    special casing.

 app/widgets/gimplayermodecombobox.c |    3 --
 libgimpwidgets/gimpenumcombobox.c   |   41 -----------------------------------
 libgimpwidgets/gimpintcombobox.c    |   18 ++++++++------
 libgimpwidgets/gimpwidgetsenums.h   |    5 ++-
 4 files changed, 13 insertions(+), 54 deletions(-)
---
diff --git a/app/widgets/gimplayermodecombobox.c b/app/widgets/gimplayermodecombobox.c
index 57da316..b72b769 100644
--- a/app/widgets/gimplayermodecombobox.c
+++ b/app/widgets/gimplayermodecombobox.c
@@ -147,9 +147,6 @@ gimp_layer_mode_combo_box_constructed (GObject *object)
 
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
                                  combo->priv->layer_mode);
-
-  gimp_int_combo_box_set_layout (GIMP_INT_COMBO_BOX (combo),
-                                 GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED);
 }
 
 static void
diff --git a/libgimpwidgets/gimpenumcombobox.c b/libgimpwidgets/gimpenumcombobox.c
index 73e4ef5..209e6f8 100644
--- a/libgimpwidgets/gimpenumcombobox.c
+++ b/libgimpwidgets/gimpenumcombobox.c
@@ -56,9 +56,6 @@ static void  gimp_enum_combo_box_get_property (GObject      *object,
                                                GValue       *value,
                                                GParamSpec   *pspec);
 
-static GimpIntComboBoxLayout
-        gimp_enum_combo_box_layout_from_store (GimpEnumStore *enum_store);
-
 
 G_DEFINE_TYPE (GimpEnumComboBox, gimp_enum_combo_box,
                GIMP_TYPE_INT_COMBO_BOX)
@@ -129,40 +126,6 @@ gimp_enum_combo_box_get_property (GObject    *object,
     }
 }
 
-static GimpIntComboBoxLayout
-gimp_enum_combo_box_layout_from_store (GimpEnumStore *enum_store)
-{
-  GtkTreeModel *model = GTK_TREE_MODEL (enum_store);
-  GtkTreeIter   iter;
-  gboolean      iter_valid;
-  gboolean      has_abbrev = FALSE;
-
-  for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
-       iter_valid;
-       iter_valid = gtk_tree_model_iter_next (model, &iter))
-    {
-      gchar *abbrev;
-
-      gtk_tree_model_get (model, &iter,
-                          GIMP_INT_STORE_ABBREV, &abbrev,
-                          -1);
-
-      if (abbrev)
-        {
-          has_abbrev = TRUE;
-
-          g_free (abbrev);
-
-          break;
-        }
-    }
-
-  if (has_abbrev)
-    return GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED;
-  else
-    return GIMP_INT_COMBO_BOX_LAYOUT_FULL;
-}
-
 
 /**
  * gimp_enum_combo_box_new:
@@ -194,8 +157,6 @@ gimp_enum_combo_box_new (GType enum_type)
 
   combo_box = g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
                             "model", store,
-                            "layout", gimp_enum_combo_box_layout_from_store (
-                                        GIMP_ENUM_STORE (store)),
                             NULL);
 
   g_object_unref (store);
@@ -220,8 +181,6 @@ gimp_enum_combo_box_new_with_model (GimpEnumStore *enum_store)
 
   return g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
                        "model", enum_store,
-                       "layout", gimp_enum_combo_box_layout_from_store (
-                                   enum_store),
                        NULL);
 }
 
diff --git a/libgimpwidgets/gimpintcombobox.c b/libgimpwidgets/gimpintcombobox.c
index 9c52a01..e6fd764 100644
--- a/libgimpwidgets/gimpintcombobox.c
+++ b/libgimpwidgets/gimpintcombobox.c
@@ -147,9 +147,8 @@ gimp_int_combo_box_class_init (GimpIntComboBoxClass *klass)
                                                       "Layout",
                                                       "Combo box layout",
                                                       GIMP_TYPE_INT_COMBO_BOX_LAYOUT,
-                                                      GIMP_INT_COMBO_BOX_LAYOUT_FULL,
-                                                      GIMP_PARAM_READWRITE |
-                                                      G_PARAM_CONSTRUCT));
+                                                      GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED,
+                                                      GIMP_PARAM_READWRITE));
 
   g_type_class_add_private (object_class, sizeof (GimpIntComboBoxPrivate));
 }
@@ -157,16 +156,19 @@ gimp_int_combo_box_class_init (GimpIntComboBoxClass *klass)
 static void
 gimp_int_combo_box_init (GimpIntComboBox *combo_box)
 {
-  GtkListStore *store;
+  GimpIntComboBoxPrivate *priv;
+  GtkListStore           *store;
 
-  combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
-                                                 GIMP_TYPE_INT_COMBO_BOX,
-                                                 GimpIntComboBoxPrivate);
+  combo_box->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
+                                                        GIMP_TYPE_INT_COMBO_BOX,
+                                                        GimpIntComboBoxPrivate);
 
   store = gimp_int_store_new ();
   gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
   g_object_unref (store);
 
+  priv->layout = GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED;
+
   gimp_int_combo_box_create_cells (GIMP_INT_COMBO_BOX (combo_box));
 }
 
@@ -703,7 +705,7 @@ GimpIntComboBoxLayout
 gimp_int_combo_box_get_layout (GimpIntComboBox *combo_box)
 {
   g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box),
-                        GIMP_INT_COMBO_BOX_LAYOUT_FULL);
+                        GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED);
 
   return GIMP_INT_COMBO_BOX_GET_PRIVATE (combo_box)->layout;
 }
diff --git a/libgimpwidgets/gimpwidgetsenums.h b/libgimpwidgets/gimpwidgetsenums.h
index 1b3fa15..84b679d 100644
--- a/libgimpwidgets/gimpwidgetsenums.h
+++ b/libgimpwidgets/gimpwidgetsenums.h
@@ -191,8 +191,9 @@ typedef enum
 /**
  * GimpIntComboBoxLayout:
  * @GIMP_INT_COMBO_BOX_LAYOUT_ICON_ONLY:   show icons only
- * @GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED: show abbreviated labels
- * @GIMP_INT_COMBO_BOX_LAYOUT_FULL:        show full labels
+ * @GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED: show icons and abbreviated labels,
+ *                                         when available
+ * @GIMP_INT_COMBO_BOX_LAYOUT_FULL:        show icons and full labels
  *
  * Possible layouts for #GimpIntComboBox.
  **/


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