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

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimpcellrenderercolor.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:
44
44
};
45
45
 
46
46
 
47
 
static void gimp_cell_renderer_color_class_init (GimpCellRendererColorClass *klass);
48
 
static void gimp_cell_renderer_color_init       (GimpCellRendererColor      *cell);
49
 
 
50
47
static void gimp_cell_renderer_color_get_property (GObject         *object,
51
48
                                                   guint            param_id,
52
49
                                                   GValue          *value,
71
68
                                                   GtkCellRendererState flags);
72
69
 
73
70
 
74
 
static GtkCellRendererClass *parent_class = NULL;
75
 
 
76
 
 
77
 
GType
78
 
gimp_cell_renderer_color_get_type (void)
79
 
{
80
 
  static GType cell_type = 0;
81
 
 
82
 
  if (! cell_type)
83
 
    {
84
 
      static const GTypeInfo cell_info =
85
 
      {
86
 
        sizeof (GimpCellRendererColorClass),
87
 
        NULL,           /* base_init */
88
 
        NULL,           /* base_finalize */
89
 
        (GClassInitFunc) gimp_cell_renderer_color_class_init,
90
 
        NULL,           /* class_finalize */
91
 
        NULL,           /* class_data */
92
 
        sizeof (GimpCellRendererColor),
93
 
        0,              /* n_preallocs */
94
 
        (GInstanceInitFunc) gimp_cell_renderer_color_init,
95
 
      };
96
 
 
97
 
      cell_type = g_type_register_static (GTK_TYPE_CELL_RENDERER,
98
 
                                          "GimpCellRendererColor",
99
 
                                          &cell_info, 0);
100
 
    }
101
 
 
102
 
  return cell_type;
103
 
}
 
71
G_DEFINE_TYPE (GimpCellRendererColor, gimp_cell_renderer_color,
 
72
               GTK_TYPE_CELL_RENDERER)
 
73
 
 
74
#define parent_class gimp_cell_renderer_color_parent_class
 
75
 
104
76
 
105
77
static void
106
78
gimp_cell_renderer_color_class_init (GimpCellRendererColorClass *klass)
108
80
  GObjectClass         *object_class = G_OBJECT_CLASS (klass);
109
81
  GtkCellRendererClass *cell_class   = GTK_CELL_RENDERER_CLASS (klass);
110
82
 
111
 
  parent_class = g_type_class_peek_parent (klass);
112
 
 
113
83
  object_class->get_property = gimp_cell_renderer_color_get_property;
114
84
  object_class->set_property = gimp_cell_renderer_color_set_property;
115
85
 
120
90
                                   PROP_COLOR,
121
91
                                   g_param_spec_boxed ("color", NULL, NULL,
122
92
                                                       GIMP_TYPE_RGB,
123
 
                                                       G_PARAM_READWRITE));
 
93
                                                       GIMP_PARAM_READWRITE));
124
94
  g_object_class_install_property (object_class,
125
95
                                   PROP_OPAQUE,
126
96
                                   g_param_spec_boolean ("opaque", NULL, NULL,
127
97
                                                         TRUE,
128
 
                                                         G_PARAM_READWRITE |
 
98
                                                         GIMP_PARAM_READWRITE |
129
99
                                                         G_PARAM_CONSTRUCT));
130
100
  g_object_class_install_property (object_class,
131
 
                                   PROP_SIZE,
132
 
                                   g_param_spec_int ("icon_size", NULL, NULL,
 
101
                                   PROP_SIZE,
 
102
                                   g_param_spec_int ("icon-size", NULL, NULL,
133
103
                                                     0, G_MAXINT,
134
104
                                                     DEFAULT_ICON_SIZE,
135
 
                                                     G_PARAM_READWRITE |
 
105
                                                     GIMP_PARAM_READWRITE |
136
106
                                                     G_PARAM_CONSTRUCT));
137
107
}
138
108
 
204
174
                                   gint            *height)
205
175
{
206
176
  GimpCellRendererColor *color = GIMP_CELL_RENDERER_COLOR (cell);
207
 
  GtkSettings           *settings;
208
177
  gint                   calc_width;
209
178
  gint                   calc_height;
210
179
 
211
 
  settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
212
 
 
213
 
  gtk_icon_size_lookup_for_settings (settings,
 
180
  gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (widget),
214
181
                                     color->size, &calc_width, &calc_height);
215
182
 
216
183
  if (cell_area && calc_width > 0 && calc_height > 0)
217
184
    {
218
185
      if (x_offset)
219
 
        {
220
 
          *x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
 
186
        {
 
187
          *x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
221
188
                        1.0 - cell->xalign : cell->xalign) *
222
189
                       (cell_area->width - calc_width));
223
 
          *x_offset = MAX (*x_offset, 0) + cell->xpad;
224
 
        }
 
190
          *x_offset = MAX (*x_offset, 0) + cell->xpad;
 
191
        }
225
192
      if (y_offset)
226
 
        {
227
 
          *y_offset = (cell->yalign *
 
193
        {
 
194
          *y_offset = (cell->yalign *
228
195
                       (cell_area->height - calc_height));
229
196
          *y_offset = MAX (*y_offset, 0) + cell->ypad;
230
 
        }
 
197
        }
231
198
    }
232
199
  else
233
200
    {
277
244
 
278
245
      buf = g_alloca (rowstride * (rect.height - 2));
279
246
 
280
 
      _gimp_color_area_render_buf ((color->opaque ?
 
247
      _gimp_color_area_render_buf (widget,
 
248
                                   (GTK_WIDGET_STATE (widget) ==
 
249
                                    GTK_STATE_INSENSITIVE || !cell->sensitive),
 
250
                                   (color->opaque ?
281
251
                                    GIMP_COLOR_AREA_FLAT :
282
252
                                    GIMP_COLOR_AREA_SMALL_CHECKS),
283
253
                                   buf,