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

« back to all changes in this revision

Viewing changes to app/widgets/gimpgrideditor.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 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * GimpGridEditor
28
28
 
29
29
#include "widgets-types.h"
30
30
 
 
31
#include "core/gimpcontext.h"
31
32
#include "core/gimpgrid.h"
32
33
#include "core/gimpmarshal.h"
33
34
 
 
35
#include "gimpcolorpanel.h"
 
36
#include "gimpgrideditor.h"
34
37
#include "gimppropwidgets.h"
35
 
#include "gimpgrideditor.h"
36
38
 
37
39
#include "gimp-intl.h"
38
40
 
40
42
#define GRID_EDITOR_DEFAULT_RESOLUTION   72.0
41
43
 
42
44
#define GRID_EDITOR_COLOR_BUTTON_WIDTH   60
43
 
#define GRID_EDITOR_COLOR_BUTTON_HEIGHT  20
 
45
#define GRID_EDITOR_COLOR_BUTTON_HEIGHT  24
44
46
 
45
47
 
46
48
enum
47
49
{
48
50
  PROP_0,
49
51
  PROP_GRID,
 
52
  PROP_CONTEXT,
50
53
  PROP_XRESOLUTION,
51
54
  PROP_YRESOLUTION
52
55
};
53
56
 
54
57
 
55
 
static void      gimp_grid_editor_class_init   (GimpGridEditorClass   *klass);
56
58
static GObject * gimp_grid_editor_constructor  (GType                  type,
57
59
                                                guint                  n_params,
58
60
                                                GObjectConstructParam *params);
67
69
static void      gimp_grid_editor_finalize     (GObject               *object);
68
70
 
69
71
 
70
 
static GtkVBoxClass *parent_class = NULL;
71
 
 
72
 
 
73
 
GType
74
 
gimp_grid_editor_get_type (void)
75
 
{
76
 
  static GType view_type = 0;
77
 
 
78
 
  if (! view_type)
79
 
    {
80
 
      static const GTypeInfo view_info =
81
 
      {
82
 
        sizeof (GimpGridEditorClass),
83
 
        NULL,           /* base_init      */
84
 
        NULL,           /* base_finalize  */
85
 
        (GClassInitFunc) gimp_grid_editor_class_init,
86
 
        NULL,           /* class_finalize */
87
 
        NULL,           /* class_data     */
88
 
        sizeof (GimpGridEditor),
89
 
        0,              /* n_preallocs    */
90
 
        NULL            /* instance_init  */
91
 
      };
92
 
 
93
 
      view_type = g_type_register_static (GTK_TYPE_VBOX,
94
 
                                          "GimpGridEditor",
95
 
                                          &view_info, 0);
96
 
    }
97
 
 
98
 
  return view_type;
99
 
}
 
72
G_DEFINE_TYPE (GimpGridEditor, gimp_grid_editor, GTK_TYPE_VBOX)
 
73
 
 
74
#define parent_class gimp_grid_editor_parent_class
 
75
 
100
76
 
101
77
static void
102
78
gimp_grid_editor_class_init (GimpGridEditorClass *klass)
103
79
{
104
80
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
105
81
 
106
 
  parent_class = g_type_class_peek_parent (klass);
107
 
 
108
82
  object_class->constructor  = gimp_grid_editor_constructor;
109
83
  object_class->set_property = gimp_grid_editor_set_property;
110
84
  object_class->get_property = gimp_grid_editor_get_property;
113
87
  g_object_class_install_property (object_class, PROP_GRID,
114
88
                                   g_param_spec_object ("grid", NULL, NULL,
115
89
                                                        GIMP_TYPE_GRID,
116
 
                                                        G_PARAM_READWRITE |
 
90
                                                        GIMP_PARAM_READWRITE |
 
91
                                                        G_PARAM_CONSTRUCT_ONLY));
 
92
  g_object_class_install_property (object_class, PROP_CONTEXT,
 
93
                                   g_param_spec_object ("context", NULL, NULL,
 
94
                                                        GIMP_TYPE_CONTEXT,
 
95
                                                        GIMP_PARAM_READWRITE |
117
96
                                                        G_PARAM_CONSTRUCT_ONLY));
118
97
  g_object_class_install_property (object_class, PROP_XRESOLUTION,
119
98
                                   g_param_spec_double ("xresolution", NULL, NULL,
120
99
                                                        GIMP_MIN_RESOLUTION,
121
100
                                                        GIMP_MAX_RESOLUTION,
122
101
                                                        GRID_EDITOR_DEFAULT_RESOLUTION,
123
 
                                                        G_PARAM_READWRITE |
 
102
                                                        GIMP_PARAM_READWRITE |
124
103
                                                        G_PARAM_CONSTRUCT_ONLY));
125
104
  g_object_class_install_property (object_class, PROP_YRESOLUTION,
126
105
                                   g_param_spec_double ("yresolution", NULL, NULL,
127
106
                                                        GIMP_MIN_RESOLUTION,
128
107
                                                        GIMP_MAX_RESOLUTION,
129
108
                                                        GRID_EDITOR_DEFAULT_RESOLUTION,
130
 
                                                        G_PARAM_READWRITE |
 
109
                                                        GIMP_PARAM_READWRITE |
131
110
                                                        G_PARAM_CONSTRUCT_ONLY));
132
111
}
133
112
 
134
113
static void
 
114
gimp_grid_editor_init (GimpGridEditor *editor)
 
115
{
 
116
}
 
117
 
 
118
static void
135
119
gimp_grid_editor_set_property (GObject      *object,
136
120
                               guint         property_id,
137
121
                               const GValue *value,
144
128
    case PROP_GRID:
145
129
      editor->grid = GIMP_GRID (g_value_dup_object (value));
146
130
      break;
 
131
    case PROP_CONTEXT:
 
132
      editor->context = GIMP_CONTEXT (g_value_dup_object (value));
 
133
      break;
147
134
    case PROP_XRESOLUTION:
148
135
      editor->xresolution = g_value_get_double (value);
149
136
      break;
169
156
    case PROP_GRID:
170
157
      g_value_set_object (value, editor->grid);
171
158
      break;
 
159
    case PROP_CONTEXT:
 
160
      g_value_set_object (value, editor->context);
 
161
      break;
172
162
    case PROP_XRESOLUTION:
173
163
      g_value_set_double (value, editor->xresolution);
174
164
      break;
216
206
                                        GIMP_GRID_DOTS,
217
207
                                        GIMP_GRID_SOLID);
218
208
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
219
 
                             _("Line _Style:"), 0.0, 0.5,
 
209
                             _("Line _style:"), 0.0, 0.5,
220
210
                             style, 1, FALSE);
221
211
 
222
212
  color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "fgcolor",
224
214
                                             GRID_EDITOR_COLOR_BUTTON_WIDTH,
225
215
                                             GRID_EDITOR_COLOR_BUTTON_HEIGHT,
226
216
                                             GIMP_COLOR_AREA_FLAT);
 
217
  gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
 
218
                                editor->context);
227
219
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
228
220
                             _("_Foreground color:"), 0.0, 0.5,
229
221
                             color_button, 1, TRUE);
233
225
                                             GRID_EDITOR_COLOR_BUTTON_WIDTH,
234
226
                                             GRID_EDITOR_COLOR_BUTTON_HEIGHT,
235
227
                                             GIMP_COLOR_AREA_FLAT);
 
228
  gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
 
229
                                editor->context);
236
230
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
237
231
                             _("_Background color:"), 0.0, 0.5,
238
232
                             color_button, 1, TRUE);
260
254
  gtk_table_set_row_spacings (GTK_TABLE (sizeentry), 2);
261
255
 
262
256
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
263
 
                                _("Width"), 0, 1, 0.0);
264
 
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
265
 
                                _("Height"), 0, 2, 0.0);
266
 
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
267
 
                                _("Pixels"), 1, 4, 0.0);
 
257
                                _("Width"), 0, 1, 0.0);
 
258
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
 
259
                                _("Height"), 0, 2, 0.0);
 
260
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
 
261
                                _("Pixels"), 1, 4, 0.0);
268
262
 
269
263
  gtk_box_pack_start (GTK_BOX (hbox), sizeentry, FALSE, FALSE, 0);
270
264
  gtk_widget_show (sizeentry);
292
286
  gtk_table_set_row_spacings (GTK_TABLE (sizeentry), 2);
293
287
 
294
288
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
295
 
                                _("Width"), 0, 1, 0.0);
296
 
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
297
 
                                _("Height"), 0, 2, 0.0);
298
 
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
299
 
                                _("Pixels"), 1, 4, 0.0);
 
289
                                _("Width"), 0, 1, 0.0);
 
290
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
 
291
                                _("Height"), 0, 2, 0.0);
 
292
  gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
 
293
                                _("Pixels"), 1, 4, 0.0);
300
294
 
301
295
  gtk_box_pack_start (GTK_BOX (hbox), sizeentry, FALSE, FALSE, 0);
302
296
  gtk_widget_show (sizeentry);
317
311
      editor->grid = NULL;
318
312
    }
319
313
 
 
314
  if (editor->context)
 
315
    {
 
316
      g_object_unref (editor->context);
 
317
      editor->context = NULL;
 
318
    }
 
319
 
320
320
  G_OBJECT_CLASS (parent_class)->finalize (object);
321
321
}
322
322
 
323
323
GtkWidget *
324
 
gimp_grid_editor_new (GimpGrid *grid,
325
 
                      gdouble   xresolution,
326
 
                      gdouble   yresolution)
 
324
gimp_grid_editor_new (GimpGrid    *grid,
 
325
                      GimpContext *context,
 
326
                      gdouble      xresolution,
 
327
                      gdouble      yresolution)
327
328
{
328
329
  g_return_val_if_fail (GIMP_IS_GRID (grid), NULL);
329
330
 
330
331
  return g_object_new (GIMP_TYPE_GRID_EDITOR,
331
332
                       "grid",        grid,
 
333
                       "context",     context,
332
334
                       "xresolution", xresolution,
333
335
                       "yresolution", yresolution,
334
336
                       NULL);