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.
This commit is contained in:
Ell 2017-12-01 08:35:46 -05:00
parent ed2fe2d2d1
commit 0830fe8923
4 changed files with 13 additions and 54 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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,9 +156,10 @@ gimp_int_combo_box_class_init (GimpIntComboBoxClass *klass)
static void
gimp_int_combo_box_init (GimpIntComboBox *combo_box)
{
GimpIntComboBoxPrivate *priv;
GtkListStore *store;
combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
combo_box->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
GIMP_TYPE_INT_COMBO_BOX,
GimpIntComboBoxPrivate);
@ -167,6 +167,8 @@ gimp_int_combo_box_init (GimpIntComboBox *combo_box)
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;
}

View File

@ -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.
**/