1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

libgimpwidgets: GimpEnumStore made final.

This commit is contained in:
Jehan
2024-10-16 22:24:01 +02:00
parent 9ff663ccb2
commit 4a02c08bfa
2 changed files with 34 additions and 52 deletions

View File

@@ -46,14 +46,12 @@ enum
}; };
typedef struct _GimpEnumStorePrivate struct _GimpEnumStore
{ {
GimpIntStore parent_instance; GimpIntStore parent_instance;
GEnumClass *enum_class; GEnumClass *enum_class;
} GimpEnumStorePrivate; };
#define GET_PRIVATE(obj) ((GimpEnumStorePrivate *) gimp_enum_store_get_instance_private ((GimpEnumStore *) (obj)))
static void gimp_enum_store_finalize (GObject *object); static void gimp_enum_store_finalize (GObject *object);
@@ -70,7 +68,7 @@ static void gimp_enum_store_add_value (GtkListStore *store,
GEnumValue *value); GEnumValue *value);
G_DEFINE_TYPE_WITH_PRIVATE (GimpEnumStore, gimp_enum_store, GIMP_TYPE_INT_STORE) G_DEFINE_TYPE (GimpEnumStore, gimp_enum_store, GIMP_TYPE_INT_STORE)
#define parent_class gimp_enum_store_parent_class #define parent_class gimp_enum_store_parent_class
@@ -109,9 +107,9 @@ gimp_enum_store_init (GimpEnumStore *store)
static void static void
gimp_enum_store_finalize (GObject *object) gimp_enum_store_finalize (GObject *object)
{ {
GimpEnumStorePrivate *priv = GET_PRIVATE (object); GimpEnumStore *store = GIMP_ENUM_STORE (object);
g_clear_pointer (&priv->enum_class, g_type_class_unref); g_clear_pointer (&store->enum_class, g_type_class_unref);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@@ -122,13 +120,13 @@ gimp_enum_store_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpEnumStorePrivate *priv = GET_PRIVATE (object); GimpEnumStore *store = GIMP_ENUM_STORE (object);
switch (property_id) switch (property_id)
{ {
case PROP_ENUM_TYPE: case PROP_ENUM_TYPE:
g_return_if_fail (priv->enum_class == NULL); g_return_if_fail (store->enum_class == NULL);
priv->enum_class = g_type_class_ref (g_value_get_gtype (value)); store->enum_class = g_type_class_ref (g_value_get_gtype (value));
break; break;
default: default:
@@ -143,13 +141,13 @@ gimp_enum_store_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpEnumStorePrivate *priv = GET_PRIVATE (object); GimpEnumStore *store = GIMP_ENUM_STORE (object);
switch (property_id) switch (property_id)
{ {
case PROP_ENUM_TYPE: case PROP_ENUM_TYPE:
g_value_set_gtype (value, (priv->enum_class ? g_value_set_gtype (value, (store->enum_class ?
G_TYPE_FROM_CLASS (priv->enum_class) : G_TYPE_FROM_CLASS (store->enum_class) :
G_TYPE_NONE)); G_TYPE_NONE));
break; break;
@@ -163,14 +161,14 @@ static void
gimp_enum_store_add_value (GtkListStore *store, gimp_enum_store_add_value (GtkListStore *store,
GEnumValue *value) GEnumValue *value)
{ {
GimpEnumStorePrivate *priv = GET_PRIVATE (store); GimpEnumStore *enum_store = GIMP_ENUM_STORE (store);
GtkTreeIter iter = { 0, }; GtkTreeIter iter = { 0, };
const gchar *desc; const gchar *desc;
const gchar *abbrev; const gchar *abbrev;
gchar *stripped; gchar *stripped;
desc = gimp_enum_value_get_desc (priv->enum_class, value); desc = gimp_enum_value_get_desc (enum_store->enum_class, value);
abbrev = gimp_enum_value_get_abbrev (priv->enum_class, value); abbrev = gimp_enum_value_get_abbrev (enum_store->enum_class, value);
/* no mnemonics in combo boxes */ /* no mnemonics in combo boxes */
stripped = gimp_strip_uline (desc); stripped = gimp_strip_uline (desc);
@@ -236,9 +234,9 @@ gimp_enum_store_new_with_range (GType enum_type,
gint minimum, gint minimum,
gint maximum) gint maximum)
{ {
GimpEnumStorePrivate *priv; GimpEnumStore *enum_store;
GtkListStore *store; GtkListStore *store;
GEnumValue *value; GEnumValue *value;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL); g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
@@ -246,9 +244,9 @@ gimp_enum_store_new_with_range (GType enum_type,
"enum-type", enum_type, "enum-type", enum_type,
NULL); NULL);
priv = GET_PRIVATE (store); enum_store = GIMP_ENUM_STORE (store);
for (value = priv->enum_class->values; for (value = enum_store->enum_class->values;
value->value_name; value->value_name;
value++) value++)
{ {
@@ -309,10 +307,10 @@ gimp_enum_store_new_with_values_valist (GType enum_type,
gint n_values, gint n_values,
va_list args) va_list args)
{ {
GimpEnumStorePrivate *priv; GimpEnumStore *enum_store;
GtkListStore *store; GtkListStore *store;
GEnumValue *value; GEnumValue *value;
gint i; gint i;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL); g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
g_return_val_if_fail (n_values > 1, NULL); g_return_val_if_fail (n_values > 1, NULL);
@@ -321,11 +319,11 @@ gimp_enum_store_new_with_values_valist (GType enum_type,
"enum-type", enum_type, "enum-type", enum_type,
NULL); NULL);
priv = GET_PRIVATE (store); enum_store = GIMP_ENUM_STORE (store);
for (i = 0; i < n_values; i++) for (i = 0; i < n_values; i++)
{ {
value = g_enum_get_value (priv->enum_class, value = g_enum_get_value (enum_store->enum_class,
va_arg (args, gint)); va_arg (args, gint));
if (value) if (value)
@@ -351,14 +349,12 @@ void
gimp_enum_store_set_icon_prefix (GimpEnumStore *store, gimp_enum_store_set_icon_prefix (GimpEnumStore *store,
const gchar *icon_prefix) const gchar *icon_prefix)
{ {
GimpEnumStorePrivate *priv; GtkTreeModel *model;
GtkTreeModel *model; GtkTreeIter iter;
GtkTreeIter iter; gboolean iter_valid;
gboolean iter_valid;
g_return_if_fail (GIMP_IS_ENUM_STORE (store)); g_return_if_fail (GIMP_IS_ENUM_STORE (store));
priv = GET_PRIVATE (store);
model = GTK_TREE_MODEL (store); model = GTK_TREE_MODEL (store);
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter); for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
@@ -376,7 +372,7 @@ gimp_enum_store_set_icon_prefix (GimpEnumStore *store,
GIMP_INT_STORE_VALUE, &value, GIMP_INT_STORE_VALUE, &value,
-1); -1);
enum_value = g_enum_get_value (priv->enum_class, value); enum_value = g_enum_get_value (store->enum_class, value);
if (enum_value) if (enum_value)
{ {

View File

@@ -32,21 +32,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_ENUM_STORE (gimp_enum_store_get_type ()) #define GIMP_TYPE_ENUM_STORE (gimp_enum_store_get_type ())
G_DECLARE_DERIVABLE_TYPE (GimpEnumStore, gimp_enum_store, GIMP, ENUM_STORE, GimpIntStore) G_DECLARE_FINAL_TYPE (GimpEnumStore, gimp_enum_store, GIMP, ENUM_STORE, GimpIntStore)
struct _GimpEnumStoreClass
{
GimpIntStoreClass parent_class;
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GtkListStore * gimp_enum_store_new (GType enum_type); GtkListStore * gimp_enum_store_new (GType enum_type);