33
33
#include "libgimp/libgimp-intl.h"
36
static void gimp_int_store_class_init (GimpIntStoreClass *klass);
45
} GimpIntStorePrivate;
48
static GObject * gimp_int_store_constructor (GType type,
50
GObjectConstructParam *params);
37
52
static void gimp_int_store_tree_model_init (GtkTreeModelIface *iface);
38
static void gimp_int_store_init (GimpIntStore *store);
39
54
static void gimp_int_store_finalize (GObject *object);
55
static void gimp_int_store_set_property (GObject *object,
59
static void gimp_int_store_get_property (GObject *object,
40
64
static void gimp_int_store_row_inserted (GtkTreeModel *model,
42
66
GtkTreeIter *iter);
43
67
static void gimp_int_store_add_empty (GimpIntStore *store);
46
static GtkListStoreClass *parent_class = NULL;
70
G_DEFINE_TYPE_WITH_CODE (GimpIntStore, gimp_int_store, GTK_TYPE_LIST_STORE,
71
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
72
gimp_int_store_tree_model_init))
74
#define GIMP_INT_STORE_GET_PRIVATE(obj) \
75
G_TYPE_INSTANCE_GET_PRIVATE (obj, GIMP_TYPE_INT_STORE, GimpIntStorePrivate)
77
#define parent_class gimp_int_store_parent_class
47
79
static GtkTreeModelIface *parent_iface = NULL;
51
gimp_int_store_get_type (void)
53
static GType store_type = 0;
57
static const GTypeInfo store_info =
59
sizeof (GimpIntStoreClass),
61
NULL, /* base_finalize */
62
(GClassInitFunc) gimp_int_store_class_init,
63
NULL, /* class_finalize */
64
NULL, /* class_data */
65
sizeof (GimpIntStore),
67
(GInstanceInitFunc) gimp_int_store_init
69
static const GInterfaceInfo iface_info =
71
(GInterfaceInitFunc) gimp_int_store_tree_model_init,
72
NULL, /* iface_finalize */
76
store_type = g_type_register_static (GTK_TYPE_LIST_STORE,
80
g_type_add_interface_static (store_type, GTK_TYPE_TREE_MODEL,
88
83
gimp_int_store_class_init (GimpIntStoreClass *klass)
90
85
GObjectClass *object_class = G_OBJECT_CLASS (klass);
92
parent_class = g_type_class_peek_parent (klass);
94
object_class->finalize = gimp_int_store_finalize;
98
gimp_int_store_tree_model_init (GtkTreeModelIface *iface)
100
parent_iface = g_type_interface_peek_parent (iface);
102
iface->row_inserted = gimp_int_store_row_inserted;
87
object_class->constructor = gimp_int_store_constructor;
88
object_class->finalize = gimp_int_store_finalize;
89
object_class->set_property = gimp_int_store_set_property;
90
object_class->get_property = gimp_int_store_get_property;
93
* GimpIntStore:user-data-type:
95
* Allows to set the #GType for the GIMP_INT_STORE_USER_DATA column.
97
* You need to set this property when constructing the store if you want
98
* to use the GIMP_INT_STORE_USER_DATA column and want to have the store
99
* handle ref-counting of your user data.
103
g_object_class_install_property (object_class,
105
g_param_spec_gtype ("user-data-type",
108
G_PARAM_CONSTRUCT_ONLY |
109
GIMP_PARAM_READWRITE));
111
g_type_class_add_private (object_class, sizeof (GimpIntStorePrivate));
106
115
gimp_int_store_init (GimpIntStore *store)
108
GType types[GIMP_INT_STORE_NUM_COLUMNS];
117
store->empty_iter = NULL;
121
gimp_int_store_constructor (GType type,
123
GObjectConstructParam *params)
127
GimpIntStorePrivate *priv;
128
GType types[GIMP_INT_STORE_NUM_COLUMNS];
130
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
132
store = GIMP_INT_STORE (object);
133
priv = GIMP_INT_STORE_GET_PRIVATE (store);
110
135
types[GIMP_INT_STORE_VALUE] = G_TYPE_INT;
111
136
types[GIMP_INT_STORE_LABEL] = G_TYPE_STRING;
112
137
types[GIMP_INT_STORE_STOCK_ID] = G_TYPE_STRING;
113
138
types[GIMP_INT_STORE_PIXBUF] = GDK_TYPE_PIXBUF;
114
types[GIMP_INT_STORE_USER_DATA] = G_TYPE_POINTER;
116
store->empty_iter = NULL;
139
types[GIMP_INT_STORE_USER_DATA] = (priv->user_data_type != G_TYPE_NONE ?
140
priv->user_data_type : G_TYPE_POINTER);
118
142
gtk_list_store_set_column_types (GTK_LIST_STORE (store),
119
143
GIMP_INT_STORE_NUM_COLUMNS, types);
121
145
gimp_int_store_add_empty (store);
151
gimp_int_store_tree_model_init (GtkTreeModelIface *iface)
153
parent_iface = g_type_interface_peek_parent (iface);
155
iface->row_inserted = gimp_int_store_row_inserted;
173
gimp_int_store_set_property (GObject *object,
178
GimpIntStorePrivate *priv = GIMP_INT_STORE_GET_PRIVATE (object);
182
case PROP_USER_DATA_TYPE:
183
priv->user_data_type = g_value_get_gtype (value);
186
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
192
gimp_int_store_get_property (GObject *object,
197
GimpIntStorePrivate *priv = GIMP_INT_STORE_GET_PRIVATE (object);
201
case PROP_USER_DATA_TYPE:
202
g_value_set_gtype (value, priv->user_data_type);
205
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
139
211
gimp_int_store_row_inserted (GtkTreeModel *model,
143
215
GimpIntStore *store = GIMP_INT_STORE (model);