~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimpintstore.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
3
3
 *
4
4
 * gimpintstore.c
5
 
 * Copyright (C) 2004  Sven Neumann <sven@gimp.org>
 
5
 * Copyright (C) 2004-2007  Sven Neumann <sven@gimp.org>
6
6
 *
7
7
 * This library is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU Lesser General Public
33
33
#include "libgimp/libgimp-intl.h"
34
34
 
35
35
 
36
 
static void  gimp_int_store_class_init      (GimpIntStoreClass *klass);
 
36
enum
 
37
{
 
38
  PROP_0,
 
39
  PROP_USER_DATA_TYPE
 
40
};
 
41
 
 
42
typedef struct
 
43
{
 
44
  GType  user_data_type;
 
45
} GimpIntStorePrivate;
 
46
 
 
47
 
 
48
static GObject * gimp_int_store_constructor (GType                  type,
 
49
                                             guint                  n_params,
 
50
                                             GObjectConstructParam *params);
 
51
 
37
52
static void  gimp_int_store_tree_model_init (GtkTreeModelIface *iface);
38
 
static void  gimp_int_store_init            (GimpIntStore      *store);
 
53
 
39
54
static void  gimp_int_store_finalize        (GObject           *object);
 
55
static void  gimp_int_store_set_property    (GObject           *object,
 
56
                                             guint              property_id,
 
57
                                             const GValue      *value,
 
58
                                             GParamSpec        *pspec);
 
59
static void  gimp_int_store_get_property    (GObject           *object,
 
60
                                             guint              property_id,
 
61
                                             GValue            *value,
 
62
                                             GParamSpec        *pspec);
 
63
 
40
64
static void  gimp_int_store_row_inserted    (GtkTreeModel      *model,
41
65
                                             GtkTreePath       *path,
42
66
                                             GtkTreeIter       *iter);
43
67
static void  gimp_int_store_add_empty       (GimpIntStore      *store);
44
68
 
45
69
 
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))
 
73
 
 
74
#define GIMP_INT_STORE_GET_PRIVATE(obj) \
 
75
  G_TYPE_INSTANCE_GET_PRIVATE (obj, GIMP_TYPE_INT_STORE, GimpIntStorePrivate)
 
76
 
 
77
#define parent_class gimp_int_store_parent_class
 
78
 
47
79
static GtkTreeModelIface *parent_iface = NULL;
48
80
 
49
81
 
50
 
GType
51
 
gimp_int_store_get_type (void)
52
 
{
53
 
  static GType store_type = 0;
54
 
 
55
 
  if (! store_type)
56
 
    {
57
 
      static const GTypeInfo store_info =
58
 
      {
59
 
        sizeof (GimpIntStoreClass),
60
 
        NULL,           /* base_init      */
61
 
        NULL,           /* base_finalize  */
62
 
        (GClassInitFunc) gimp_int_store_class_init,
63
 
        NULL,           /* class_finalize */
64
 
        NULL,           /* class_data     */
65
 
        sizeof (GimpIntStore),
66
 
        0,              /* n_preallocs    */
67
 
        (GInstanceInitFunc) gimp_int_store_init
68
 
      };
69
 
      static const GInterfaceInfo iface_info =
70
 
      {
71
 
        (GInterfaceInitFunc) gimp_int_store_tree_model_init,
72
 
        NULL,           /* iface_finalize */
73
 
        NULL            /* iface_data     */
74
 
      };
75
 
 
76
 
      store_type = g_type_register_static (GTK_TYPE_LIST_STORE,
77
 
                                           "GimpIntStore",
78
 
                                           &store_info, 0);
79
 
 
80
 
      g_type_add_interface_static (store_type, GTK_TYPE_TREE_MODEL,
81
 
                                   &iface_info);
82
 
    }
83
 
 
84
 
  return store_type;
85
 
}
86
 
 
87
82
static void
88
83
gimp_int_store_class_init (GimpIntStoreClass *klass)
89
84
{
90
85
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
91
86
 
92
 
  parent_class = g_type_class_peek_parent (klass);
93
 
 
94
 
  object_class->finalize = gimp_int_store_finalize;
95
 
}
96
 
 
97
 
static void
98
 
gimp_int_store_tree_model_init (GtkTreeModelIface *iface)
99
 
{
100
 
  parent_iface = g_type_interface_peek_parent (iface);
101
 
 
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;
 
91
 
 
92
  /**
 
93
   * GimpIntStore:user-data-type:
 
94
   *
 
95
   * Allows to set the #GType for the GIMP_INT_STORE_USER_DATA column.
 
96
   *
 
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.
 
100
   *
 
101
   * Since: GIMP 2.4
 
102
   */
 
103
  g_object_class_install_property (object_class,
 
104
                                   PROP_USER_DATA_TYPE,
 
105
                                   g_param_spec_gtype ("user-data-type",
 
106
                                                       NULL, NULL,
 
107
                                                       G_TYPE_NONE,
 
108
                                                       G_PARAM_CONSTRUCT_ONLY |
 
109
                                                       GIMP_PARAM_READWRITE));
 
110
 
 
111
  g_type_class_add_private (object_class, sizeof (GimpIntStorePrivate));
103
112
}
104
113
 
105
114
static void
106
115
gimp_int_store_init (GimpIntStore *store)
107
116
{
108
 
  GType types[GIMP_INT_STORE_NUM_COLUMNS];
 
117
  store->empty_iter = NULL;
 
118
}
 
119
 
 
120
static GObject *
 
121
gimp_int_store_constructor (GType                  type,
 
122
                            guint                  n_params,
 
123
                            GObjectConstructParam *params)
 
124
{
 
125
  GObject             *object;
 
126
  GimpIntStore        *store;
 
127
  GimpIntStorePrivate *priv;
 
128
  GType                types[GIMP_INT_STORE_NUM_COLUMNS];
 
129
 
 
130
  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
131
 
 
132
  store = GIMP_INT_STORE (object);
 
133
  priv = GIMP_INT_STORE_GET_PRIVATE (store);
109
134
 
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;
115
 
 
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);
117
141
 
118
142
  gtk_list_store_set_column_types (GTK_LIST_STORE (store),
119
143
                                   GIMP_INT_STORE_NUM_COLUMNS, types);
120
144
 
121
145
  gimp_int_store_add_empty (store);
 
146
 
 
147
  return object;
 
148
}
 
149
 
 
150
static void
 
151
gimp_int_store_tree_model_init (GtkTreeModelIface *iface)
 
152
{
 
153
  parent_iface = g_type_interface_peek_parent (iface);
 
154
 
 
155
  iface->row_inserted = gimp_int_store_row_inserted;
122
156
}
123
157
 
124
158
static void
136
170
}
137
171
 
138
172
static void
 
173
gimp_int_store_set_property (GObject      *object,
 
174
                             guint         property_id,
 
175
                             const GValue *value,
 
176
                             GParamSpec   *pspec)
 
177
{
 
178
  GimpIntStorePrivate *priv = GIMP_INT_STORE_GET_PRIVATE (object);
 
179
 
 
180
  switch (property_id)
 
181
    {
 
182
    case PROP_USER_DATA_TYPE:
 
183
      priv->user_data_type = g_value_get_gtype (value);
 
184
      break;
 
185
    default:
 
186
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
187
      break;
 
188
    }
 
189
}
 
190
 
 
191
static void
 
192
gimp_int_store_get_property (GObject    *object,
 
193
                             guint       property_id,
 
194
                             GValue     *value,
 
195
                             GParamSpec *pspec)
 
196
{
 
197
  GimpIntStorePrivate *priv = GIMP_INT_STORE_GET_PRIVATE (object);
 
198
 
 
199
  switch (property_id)
 
200
    {
 
201
    case PROP_USER_DATA_TYPE:
 
202
      g_value_set_gtype (value, priv->user_data_type);
 
203
      break;
 
204
    default:
 
205
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
206
      break;
 
207
    }
 
208
}
 
209
 
 
210
static void
139
211
gimp_int_store_row_inserted (GtkTreeModel *model,
140
 
                             GtkTreePath  *path,
141
 
                             GtkTreeIter  *iter)
 
212
                             GtkTreePath  *path,
 
213
                             GtkTreeIter  *iter)
142
214
{
143
215
  GimpIntStore *store = GIMP_INT_STORE (model);
144
216