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

« back to all changes in this revision

Viewing changes to app/widgets/gimpvectorstreeview.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
 * gimpvectorstreeview.c
46
46
#include "gimp-intl.h"
47
47
 
48
48
 
49
 
static void    gimp_vectors_tree_view_class_init (GimpVectorsTreeViewClass *klass);
50
 
static void    gimp_vectors_tree_view_init       (GimpVectorsTreeView      *view);
51
 
 
52
 
static void    gimp_vectors_tree_view_view_iface_init (GimpContainerViewInterface *view_iface);
 
49
static void    gimp_vectors_tree_view_view_iface_init (GimpContainerViewInterface *iface);
53
50
 
54
51
static GObject * gimp_vectors_tree_view_constructor   (GType                  type,
55
52
                                                       guint                  n_params,
67
64
                                                       gpointer               data);
68
65
 
69
66
 
70
 
static GimpItemTreeViewClass      *parent_class      = NULL;
 
67
G_DEFINE_TYPE_WITH_CODE (GimpVectorsTreeView, gimp_vectors_tree_view,
 
68
                         GIMP_TYPE_ITEM_TREE_VIEW,
 
69
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONTAINER_VIEW,
 
70
                                                gimp_vectors_tree_view_view_iface_init))
 
71
 
 
72
#define parent_class gimp_vectors_tree_view_parent_class
 
73
 
71
74
static GimpContainerViewInterface *parent_view_iface = NULL;
72
75
 
73
76
 
74
 
GType
75
 
gimp_vectors_tree_view_get_type (void)
76
 
{
77
 
  static GType view_type = 0;
78
 
 
79
 
  if (! view_type)
80
 
    {
81
 
      static const GTypeInfo view_info =
82
 
      {
83
 
        sizeof (GimpVectorsTreeViewClass),
84
 
        NULL,           /* base_init */
85
 
        NULL,           /* base_finalize */
86
 
        (GClassInitFunc) gimp_vectors_tree_view_class_init,
87
 
        NULL,           /* class_finalize */
88
 
        NULL,           /* class_data */
89
 
        sizeof (GimpVectorsTreeView),
90
 
        0,              /* n_preallocs */
91
 
        (GInstanceInitFunc) gimp_vectors_tree_view_init,
92
 
      };
93
 
 
94
 
      static const GInterfaceInfo view_iface_info =
95
 
      {
96
 
        (GInterfaceInitFunc) gimp_vectors_tree_view_view_iface_init,
97
 
        NULL,           /* iface_finalize */
98
 
        NULL            /* iface_data     */
99
 
      };
100
 
 
101
 
      view_type = g_type_register_static (GIMP_TYPE_ITEM_TREE_VIEW,
102
 
                                          "GimpVectorsTreeView",
103
 
                                          &view_info, 0);
104
 
 
105
 
      g_type_add_interface_static (view_type, GIMP_TYPE_CONTAINER_VIEW,
106
 
                                   &view_iface_info);
107
 
    }
108
 
 
109
 
  return view_type;
110
 
}
111
 
 
112
77
static void
113
78
gimp_vectors_tree_view_class_init (GimpVectorsTreeViewClass *klass)
114
79
{
115
 
  GObjectClass               *object_class;
116
 
  GimpContainerTreeViewClass *view_class;
117
 
  GimpItemTreeViewClass      *item_view_class;
118
 
 
119
 
  object_class    = G_OBJECT_CLASS (klass);
120
 
  view_class      = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
121
 
  item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
122
 
 
123
 
  parent_class = g_type_class_peek_parent (klass);
124
 
 
125
 
  object_class->constructor        = gimp_vectors_tree_view_constructor;
126
 
 
127
 
  view_class->drop_svg             = gimp_vectors_tree_view_drop_svg;
128
 
 
129
 
  item_view_class->item_type       = GIMP_TYPE_VECTORS;
130
 
  item_view_class->signal_name     = "active-vectors-changed";
131
 
 
132
 
  item_view_class->get_container   = gimp_image_get_vectors;
133
 
  item_view_class->get_active_item = (GimpGetItemFunc) gimp_image_get_active_vectors;
134
 
  item_view_class->set_active_item = (GimpSetItemFunc) gimp_image_set_active_vectors;
135
 
  item_view_class->reorder_item    = (GimpReorderItemFunc) gimp_image_position_vectors;
136
 
  item_view_class->add_item        = (GimpAddItemFunc) gimp_image_add_vectors;
137
 
  item_view_class->remove_item     = (GimpRemoveItemFunc) gimp_image_remove_vectors;
138
 
  item_view_class->new_item        = gimp_vectors_tree_view_item_new;
139
 
 
140
 
  item_view_class->action_group        = "vectors";
141
 
  item_view_class->activate_action     = "vectors-path-tool";
142
 
  item_view_class->edit_action         = "vectors-edit-attributes";
143
 
  item_view_class->new_action          = "vectors-new";
144
 
  item_view_class->new_default_action  = "vectors-new-last-values";
145
 
  item_view_class->raise_action        = "vectors-raise";
146
 
  item_view_class->raise_top_action    = "vectors-raise-to-top";
147
 
  item_view_class->lower_action        = "vectors-lower";
148
 
  item_view_class->lower_bottom_action = "vectors-lower-to-bottom";
149
 
  item_view_class->duplicate_action    = "vectors-duplicate";
150
 
  item_view_class->delete_action       = "vectors-delete";
151
 
  item_view_class->reorder_desc        = _("Reorder path");
 
80
  GObjectClass               *object_class = G_OBJECT_CLASS (klass);
 
81
  GimpContainerTreeViewClass *view_class   = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
 
82
  GimpItemTreeViewClass      *iv_class     = GIMP_ITEM_TREE_VIEW_CLASS (klass);
 
83
 
 
84
  object_class->constructor = gimp_vectors_tree_view_constructor;
 
85
 
 
86
  view_class->drop_svg      = gimp_vectors_tree_view_drop_svg;
 
87
 
 
88
  iv_class->item_type       = GIMP_TYPE_VECTORS;
 
89
  iv_class->signal_name     = "active-vectors-changed";
 
90
 
 
91
  iv_class->get_container   = gimp_image_get_vectors;
 
92
  iv_class->get_active_item = (GimpGetItemFunc) gimp_image_get_active_vectors;
 
93
  iv_class->set_active_item = (GimpSetItemFunc) gimp_image_set_active_vectors;
 
94
  iv_class->reorder_item    = (GimpReorderItemFunc) gimp_image_position_vectors;
 
95
  iv_class->add_item        = (GimpAddItemFunc) gimp_image_add_vectors;
 
96
  iv_class->remove_item     = (GimpRemoveItemFunc) gimp_image_remove_vectors;
 
97
  iv_class->new_item        = gimp_vectors_tree_view_item_new;
 
98
 
 
99
  iv_class->action_group        = "vectors";
 
100
  iv_class->activate_action     = "vectors-path-tool";
 
101
  iv_class->edit_action         = "vectors-edit-attributes";
 
102
  iv_class->new_action          = "vectors-new";
 
103
  iv_class->new_default_action  = "vectors-new-last-values";
 
104
  iv_class->raise_action        = "vectors-raise";
 
105
  iv_class->raise_top_action    = "vectors-raise-to-top";
 
106
  iv_class->lower_action        = "vectors-lower";
 
107
  iv_class->lower_bottom_action = "vectors-lower-to-bottom";
 
108
  iv_class->duplicate_action    = "vectors-duplicate";
 
109
  iv_class->delete_action       = "vectors-delete";
 
110
  iv_class->reorder_desc        = _("Reorder path");
 
111
}
 
112
 
 
113
static void
 
114
gimp_vectors_tree_view_view_iface_init (GimpContainerViewInterface *iface)
 
115
{
 
116
  parent_view_iface = g_type_interface_peek_parent (iface);
 
117
 
 
118
  iface->set_container = gimp_vectors_tree_view_set_container;
152
119
}
153
120
 
154
121
static void
156
123
{
157
124
}
158
125
 
159
 
static void
160
 
gimp_vectors_tree_view_view_iface_init (GimpContainerViewInterface *view_iface)
161
 
{
162
 
  parent_view_iface = g_type_interface_peek_parent (view_iface);
163
 
 
164
 
  view_iface->set_container = gimp_vectors_tree_view_set_container;
165
 
}
166
 
 
167
126
static GObject *
168
127
gimp_vectors_tree_view_constructor (GType                  type,
169
128
                                    guint                  n_params,
194
153
                                   GDK_SHIFT_MASK | GDK_CONTROL_MASK,
195
154
                                   NULL);
196
155
  gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (editor),
197
 
                                  GTK_BUTTON (view->toselection_button),
198
 
                                  GIMP_TYPE_VECTORS);
 
156
                                  GTK_BUTTON (view->toselection_button),
 
157
                                  GIMP_TYPE_VECTORS);
199
158
  gtk_box_reorder_child (GTK_BOX (editor->button_box),
200
 
                         view->toselection_button, 5);
 
159
                         view->toselection_button, 5);
201
160
 
202
161
  view->tovectors_button =
203
162
    gimp_editor_add_action_button (editor, "vectors",
206
165
                                   GDK_SHIFT_MASK,
207
166
                                   NULL);
208
167
  gtk_box_reorder_child (GTK_BOX (editor->button_box),
209
 
                         view->tovectors_button, 6);
 
168
                         view->tovectors_button, 6);
210
169
 
211
170
  view->stroke_button =
212
171
    gimp_editor_add_action_button (editor, "vectors",
215
174
                                   GDK_SHIFT_MASK,
216
175
                                   NULL);
217
176
  gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (editor),
218
 
                                  GTK_BUTTON (view->stroke_button),
219
 
                                  GIMP_TYPE_VECTORS);
 
177
                                  GTK_BUTTON (view->stroke_button),
 
178
                                  GIMP_TYPE_VECTORS);
220
179
  gtk_box_reorder_child (GTK_BOX (editor->button_box),
221
 
                         view->stroke_button, 7);
 
180
                         view->stroke_button, 7);
222
181
 
223
182
  gimp_dnd_svg_dest_add (GTK_WIDGET (tree_view->view), NULL, view);
224
183
 
256
215
                                 GimpViewable            *dest_viewable,
257
216
                                 GtkTreeViewDropPosition  drop_pos)
258
217
{
259
 
  GimpItemTreeView *view   = GIMP_ITEM_TREE_VIEW (tree_view);
260
 
  GimpImage        *gimage = view->gimage;
261
 
  GError           *error  = NULL;
262
 
  gint              index;
 
218
  GimpItemTreeView *view  = GIMP_ITEM_TREE_VIEW (tree_view);
 
219
  GimpImage        *image = view->image;
 
220
  gint              index = -1;
 
221
  GError           *error = NULL;
263
222
 
264
 
  if (gimage->gimp->be_verbose)
 
223
  if (image->gimp->be_verbose)
265
224
    g_print ("%s: SVG dropped (len = %d)\n", G_STRFUNC, (gint) svg_data_len);
266
225
 
267
 
  index = gimp_image_get_vectors_index (gimage, GIMP_VECTORS (dest_viewable));
268
 
 
269
 
  if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
270
 
    index++;
271
 
 
272
 
  if (! gimp_vectors_import_buffer (gimage, svg_data, svg_data_len,
273
 
                                    TRUE, TRUE, index, &error))
274
 
    {
275
 
      g_message (error->message);
 
226
  if (dest_viewable)
 
227
    {
 
228
      index = gimp_image_get_vectors_index (image,
 
229
                                            GIMP_VECTORS (dest_viewable));
 
230
 
 
231
      if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
 
232
        index++;
 
233
    }
 
234
 
 
235
  if (! gimp_vectors_import_buffer (image, svg_data, svg_data_len,
 
236
                                    TRUE, TRUE, index, NULL, &error))
 
237
    {
 
238
      gimp_message (image->gimp, G_OBJECT (tree_view), GIMP_MESSAGE_ERROR,
 
239
                    "%s", error->message);
276
240
      g_clear_error (&error);
277
241
    }
278
242
  else
279
243
    {
280
 
      gimp_image_flush (gimage);
 
244
      gimp_image_flush (image);
281
245
    }
282
246
}
283
247
 
298
262
                                 gsize     *svg_data_len,
299
263
                                 gpointer   data)
300
264
{
301
 
  GimpItemTreeView *view   = GIMP_ITEM_TREE_VIEW (data);
302
 
  GimpImage        *gimage = view->gimage;
 
265
  GimpItemTreeView *view  = GIMP_ITEM_TREE_VIEW (data);
 
266
  GimpImage        *image = view->image;
303
267
  GimpItem         *item;
304
268
  gchar            *svg_data = NULL;
305
269
 
306
 
  item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
 
270
  item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
307
271
 
308
272
  *svg_data_len = 0;
309
273
 
310
274
  if (item)
311
275
    {
312
 
      svg_data = gimp_vectors_export_string (gimage, GIMP_VECTORS (item));
 
276
      svg_data = gimp_vectors_export_string (image, GIMP_VECTORS (item));
313
277
 
314
278
      if (svg_data)
315
 
        *svg_data_len = strlen (svg_data) + 1;
 
279
        *svg_data_len = strlen (svg_data);
316
280
    }
317
281
 
318
282
  return (guchar *) svg_data;