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

« back to all changes in this revision

Viewing changes to app/widgets/gimpstrokeeditor.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:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
25
25
 
26
26
#include "widgets-types.h"
27
27
 
 
28
#include "core/gimpdashpattern.h"
28
29
#include "core/gimpstrokeoptions.h"
29
30
 
 
31
#include "gimpcellrendererdashes.h"
30
32
#include "gimpdasheditor.h"
31
 
#include "gimpenumcombobox.h"
32
 
#include "gimppropwidgets.h"
33
33
#include "gimpstrokeeditor.h"
34
34
 
35
35
#include "gimp-intl.h"
42
42
  PROP_RESOLUTION
43
43
};
44
44
 
45
 
static void      gimp_stroke_editor_class_init   (GimpStrokeEditorClass *klass);
46
 
static GObject * gimp_stroke_editor_constructor  (GType                  type,
47
 
                                                  guint                  n_params,
 
45
 
 
46
static GObject * gimp_stroke_editor_constructor  (GType              type,
 
47
                                                  guint              n_params,
48
48
                                                  GObjectConstructParam *params);
49
 
static void      gimp_stroke_editor_set_property (GObject         *object,
50
 
                                                  guint            property_id,
51
 
                                                  const GValue    *value,
52
 
                                                  GParamSpec      *pspec);
53
 
static void      gimp_stroke_editor_get_property (GObject         *object,
54
 
                                                  guint            property_id,
55
 
                                                  GValue          *value,
56
 
                                                  GParamSpec      *pspec);
57
 
static void      gimp_stroke_editor_finalize     (GObject         *object);
58
 
static gboolean  gimp_stroke_editor_paint_button (GtkWidget       *widget,
59
 
                                                  GdkEventExpose  *event,
60
 
                                                  gpointer         data);
61
 
static void      gimp_stroke_editor_dash_preset  (GtkWidget       *widget,
62
 
                                                  gpointer         data);
63
 
 
64
 
 
65
 
 
66
 
static GtkVBoxClass *parent_class = NULL;
67
 
 
68
 
 
69
 
GType
70
 
gimp_stroke_editor_get_type (void)
71
 
{
72
 
  static GType view_type = 0;
73
 
 
74
 
  if (! view_type)
75
 
    {
76
 
      static const GTypeInfo view_info =
77
 
      {
78
 
        sizeof (GimpStrokeEditorClass),
79
 
        NULL,           /* base_init      */
80
 
        NULL,           /* base_finalize  */
81
 
        (GClassInitFunc) gimp_stroke_editor_class_init,
82
 
        NULL,           /* class_finalize */
83
 
        NULL,           /* class_data     */
84
 
        sizeof (GimpStrokeEditor),
85
 
        0,              /* n_preallocs    */
86
 
        NULL            /* instance_init  */
87
 
      };
88
 
 
89
 
      view_type = g_type_register_static (GTK_TYPE_VBOX,
90
 
                                          "GimpStrokeEditor",
91
 
                                          &view_info, 0);
92
 
    }
93
 
 
94
 
  return view_type;
95
 
}
 
49
static void      gimp_stroke_editor_set_property (GObject           *object,
 
50
                                                  guint              property_id,
 
51
                                                  const GValue      *value,
 
52
                                                  GParamSpec        *pspec);
 
53
static void      gimp_stroke_editor_get_property (GObject           *object,
 
54
                                                  guint              property_id,
 
55
                                                  GValue            *value,
 
56
                                                  GParamSpec        *pspec);
 
57
static void      gimp_stroke_editor_finalize     (GObject           *object);
 
58
static gboolean  gimp_stroke_editor_paint_button (GtkWidget         *widget,
 
59
                                                  GdkEventExpose    *event,
 
60
                                                  gpointer           data);
 
61
static void      gimp_stroke_editor_dash_preset  (GtkWidget         *widget,
 
62
                                                  GimpStrokeOptions *options);
 
63
 
 
64
static void      gimp_stroke_editor_combo_fill   (GimpStrokeOptions *options,
 
65
                                                  GtkComboBox       *box);
 
66
 
 
67
 
 
68
G_DEFINE_TYPE (GimpStrokeEditor, gimp_stroke_editor, GTK_TYPE_VBOX)
 
69
 
 
70
#define parent_class gimp_stroke_editor_parent_class
 
71
 
96
72
 
97
73
static void
98
74
gimp_stroke_editor_class_init (GimpStrokeEditorClass *klass)
99
75
{
100
76
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
101
77
 
102
 
  parent_class = g_type_class_peek_parent (klass);
103
 
 
104
78
  object_class->constructor  = gimp_stroke_editor_constructor;
105
79
  object_class->set_property = gimp_stroke_editor_set_property;
106
80
  object_class->get_property = gimp_stroke_editor_get_property;
109
83
  g_object_class_install_property (object_class, PROP_OPTIONS,
110
84
                                   g_param_spec_object ("options", NULL, NULL,
111
85
                                                        GIMP_TYPE_STROKE_OPTIONS,
112
 
                                                        G_PARAM_READWRITE |
 
86
                                                        GIMP_PARAM_READWRITE |
113
87
                                                        G_PARAM_CONSTRUCT_ONLY));
 
88
 
114
89
  g_object_class_install_property (object_class, PROP_RESOLUTION,
115
90
                                   g_param_spec_double ("resolution", NULL, NULL,
116
91
                                                        GIMP_MIN_RESOLUTION,
117
92
                                                        GIMP_MAX_RESOLUTION,
118
93
                                                        72.0,
119
 
                                                        G_PARAM_READWRITE |
 
94
                                                        GIMP_PARAM_READWRITE |
120
95
                                                        G_PARAM_CONSTRUCT_ONLY));
121
96
}
122
97
 
123
98
static void
 
99
gimp_stroke_editor_init (GimpStrokeEditor *editor)
 
100
{
 
101
}
 
102
 
 
103
static void
124
104
gimp_stroke_editor_set_property (GObject      *object,
125
105
                                 guint         property_id,
126
106
                                 const GValue *value,
131
111
  switch (property_id)
132
112
    {
133
113
    case PROP_OPTIONS:
 
114
      if (editor->options)
 
115
        g_object_unref (editor->options);
134
116
      editor->options = GIMP_STROKE_OPTIONS (g_value_dup_object (value));
135
117
      break;
 
118
 
136
119
    case PROP_RESOLUTION:
137
120
      editor->resolution = g_value_get_double (value);
138
121
      break;
156
139
    case PROP_OPTIONS:
157
140
      g_value_set_object (value, editor->options);
158
141
      break;
 
142
 
159
143
    case PROP_RESOLUTION:
160
144
      g_value_set_double (value, editor->resolution);
161
145
      break;
172
156
                                GObjectConstructParam  *params)
173
157
{
174
158
  GimpStrokeEditor *editor;
 
159
  GimpEnumStore    *store;
 
160
  GEnumValue       *value;
175
161
  GtkWidget        *box;
176
162
  GtkWidget        *size;
177
163
  GtkWidget        *label;
180
166
  GtkWidget        *expander;
181
167
  GtkWidget        *dash_editor;
182
168
  GtkWidget        *button;
 
169
  GtkCellRenderer  *cell;
183
170
  GObject          *object;
184
171
  gint              row = 0;
185
172
 
189
176
 
190
177
  g_assert (editor->options != NULL);
191
178
 
192
 
  gtk_box_set_spacing (GTK_BOX (editor), 6);
 
179
  gtk_box_set_spacing (GTK_BOX (editor), 12);
193
180
 
194
181
  box = gtk_hbox_new (FALSE, 6);
195
182
  gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
196
183
  gtk_widget_show (box);
197
184
 
198
 
  label = gtk_label_new (_("Line Width:"));
 
185
  label = gtk_label_new (_("Line width:"));
199
186
  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
200
187
  gtk_widget_show (label);
201
188
 
206
193
  gtk_box_pack_start (GTK_BOX (box), size, FALSE, FALSE, 0);
207
194
  gtk_widget_show (size);
208
195
 
 
196
  box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style",
 
197
                                      0, 0);
 
198
  gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
 
199
  gtk_widget_show (box);
 
200
 
209
201
  expander = gtk_expander_new_with_mnemonic (_("_Line Style"));
210
202
  gtk_box_pack_start (GTK_BOX (editor), expander, FALSE, FALSE, 0);
211
203
  gtk_widget_show (expander);
215
207
  gtk_widget_show (frame);
216
208
 
217
209
  table = gtk_table_new (5, 3, FALSE);
218
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 4);
219
 
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
220
 
  gtk_table_set_row_spacing (GTK_TABLE (table), 2, 4);
221
 
  gtk_table_set_row_spacing (GTK_TABLE (table), 4, 4);
 
210
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
 
211
  gtk_table_set_row_spacings (GTK_TABLE (table), 3);
 
212
  gtk_table_set_row_spacing (GTK_TABLE (table), 2, 6);
 
213
  gtk_table_set_row_spacing (GTK_TABLE (table), 4, 6);
222
214
  gtk_container_add (GTK_CONTAINER (frame), table);
223
215
  gtk_widget_show (table);
224
216
 
234
226
                             _("_Join style:"), 0.0, 0.5,
235
227
                             box, 2, TRUE);
236
228
 
237
 
  gimp_prop_scale_entry_new (G_OBJECT (editor->options), "miter",
 
229
  gimp_prop_scale_entry_new (G_OBJECT (editor->options), "miter-limit",
238
230
                             GTK_TABLE (table), 0, row++,
239
231
                             _("_Miter limit:"),
240
232
                             1.0, 1.0, 1,
282
274
                          NULL);
283
275
 
284
276
 
285
 
  box = gimp_enum_combo_box_new (GIMP_TYPE_DASH_PRESET);
 
277
  store = g_object_new (GIMP_TYPE_ENUM_STORE,
 
278
                        "enum-type",      GIMP_TYPE_DASH_PRESET,
 
279
                        "user-data-type", GIMP_TYPE_DASH_PATTERN,
 
280
                        NULL);
 
281
 
 
282
  for (value = store->enum_class->values; value->value_name; value++)
 
283
    {
 
284
      GtkTreeIter  iter;
 
285
      const gchar *desc;
 
286
 
 
287
      desc = gimp_enum_value_get_desc (store->enum_class, value);
 
288
 
 
289
      gtk_list_store_append (GTK_LIST_STORE (store), &iter);
 
290
      gtk_list_store_set (GTK_LIST_STORE (store), &iter,
 
291
                          GIMP_INT_STORE_VALUE, value->value,
 
292
                          GIMP_INT_STORE_LABEL, desc,
 
293
                          -1);
 
294
    }
 
295
 
 
296
  box = gimp_enum_combo_box_new_with_model (store);
 
297
  g_object_unref (store);
 
298
 
286
299
  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (box), GIMP_DASH_CUSTOM);
287
300
  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
288
 
                             _("Dash preset:"), 0.0, 0.5,
289
 
                             box, 2, TRUE);
 
301
                             _("Dash _preset:"), 0.0, 0.5,
 
302
                             box, 2, FALSE);
 
303
 
 
304
  cell = g_object_new (GIMP_TYPE_CELL_RENDERER_DASHES,
 
305
                       "xpad", 2,
 
306
                       NULL);
 
307
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (box), cell, FALSE);
 
308
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (box), cell,
 
309
                                 "pattern", GIMP_INT_STORE_USER_DATA);
 
310
 
 
311
  gimp_stroke_editor_combo_fill (editor->options, GTK_COMBO_BOX (box));
290
312
 
291
313
  g_signal_connect (box, "changed",
292
314
                    G_CALLBACK (gimp_stroke_editor_dash_preset),
293
315
                    editor->options);
294
 
  g_signal_connect_object (editor->options, "dash_info_changed",
 
316
  g_signal_connect_object (editor->options, "dash-info-changed",
295
317
                           G_CALLBACK (gimp_int_combo_box_set_active),
296
318
                           box, G_CONNECT_SWAPPED);
297
319
 
298
320
 
299
321
  button = gimp_prop_check_button_new (G_OBJECT (editor->options), "antialias",
300
322
                                       _("_Antialiasing"));
301
 
  gtk_table_attach (GTK_TABLE (table), button, 0, 2, row, row + 1,
 
323
  gtk_table_attach (GTK_TABLE (table), button, 0, 3, row, row + 1,
302
324
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
303
325
  gtk_widget_show (button);
304
326
  row++;
305
327
 
306
 
  box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style",
307
 
                                      0, 0);
308
 
  gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
309
 
  gtk_widget_show (box);
310
 
 
311
328
  return object;
312
329
}
313
330
 
356
373
}
357
374
 
358
375
static void
359
 
gimp_stroke_editor_dash_preset (GtkWidget *widget,
360
 
                                gpointer   data)
 
376
gimp_stroke_editor_dash_preset (GtkWidget         *widget,
 
377
                                GimpStrokeOptions *options)
361
378
{
362
379
  gint value;
363
380
 
364
 
  if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
365
 
    gimp_stroke_options_set_dash_preset (GIMP_STROKE_OPTIONS (data), value);
 
381
  if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
 
382
      value != GIMP_DASH_CUSTOM)
 
383
    {
 
384
      gimp_stroke_options_set_dash_pattern (options, value, NULL);
 
385
    }
 
386
}
 
387
 
 
388
static void
 
389
gimp_stroke_editor_combo_update (GtkTreeModel      *model,
 
390
                                 GParamSpec        *pspec,
 
391
                                 GimpStrokeOptions *options)
 
392
{
 
393
  GtkTreeIter iter;
 
394
 
 
395
  if (gimp_int_store_lookup_by_value (model, GIMP_DASH_CUSTOM, &iter))
 
396
    {
 
397
      gtk_list_store_set (GTK_LIST_STORE (model), &iter,
 
398
                          GIMP_INT_STORE_USER_DATA, options->dash_info,
 
399
                          -1);
 
400
    }
 
401
}
 
402
 
 
403
static void
 
404
gimp_stroke_editor_combo_fill (GimpStrokeOptions *options,
 
405
                               GtkComboBox       *box)
 
406
{
 
407
  GtkTreeModel *model = gtk_combo_box_get_model (box);
 
408
  GtkTreeIter   iter;
 
409
  gboolean      iter_valid;
 
410
 
 
411
  for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
 
412
       iter_valid;
 
413
       iter_valid = gtk_tree_model_iter_next (model, &iter))
 
414
    {
 
415
      gint value;
 
416
 
 
417
      gtk_tree_model_get (model, &iter,
 
418
                          GIMP_INT_STORE_VALUE, &value,
 
419
                          -1);
 
420
 
 
421
      if (value == GIMP_DASH_CUSTOM)
 
422
        {
 
423
          gtk_list_store_set (GTK_LIST_STORE (model), &iter,
 
424
                              GIMP_INT_STORE_USER_DATA, options->dash_info,
 
425
                              -1);
 
426
 
 
427
          g_signal_connect_object (options, "notify::dash-info",
 
428
                                   G_CALLBACK (gimp_stroke_editor_combo_update),
 
429
                                   model, G_CONNECT_SWAPPED);
 
430
        }
 
431
      else
 
432
        {
 
433
          GArray *pattern = gimp_dash_pattern_new_from_preset (value);
 
434
 
 
435
          gtk_list_store_set (GTK_LIST_STORE (model), &iter,
 
436
                              GIMP_INT_STORE_USER_DATA, pattern,
 
437
                              -1);
 
438
          gimp_dash_pattern_free (pattern);
 
439
        }
 
440
    }
366
441
}