42
41
#include "gimp-intl.h"
45
static void gimp_drawable_tree_view_class_init (GimpDrawableTreeViewClass *klass);
46
static void gimp_drawable_tree_view_init (GimpDrawableTreeView *view);
48
static void gimp_drawable_tree_view_view_iface_init (GimpContainerViewInterface *view_iface);
44
static void gimp_drawable_tree_view_view_iface_init (GimpContainerViewInterface *iface);
50
46
static GObject * gimp_drawable_tree_view_constructor (GType type,
52
48
GObjectConstructParam *params);
54
50
static gboolean gimp_drawable_tree_view_select_item (GimpContainerView *view,
56
gpointer insert_data);
52
gpointer insert_data);
54
static gboolean gimp_drawable_tree_view_drop_possible(GimpContainerTreeView *view,
56
GimpViewable *src_viewable,
57
GimpViewable *dest_viewable,
58
GtkTreeViewDropPosition drop_pos,
59
GtkTreeViewDropPosition *return_drop_pos,
60
GdkDragAction *return_drag_action);
61
static void gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view,
62
GimpViewable *src_viewable,
63
GimpViewable *dest_viewable,
64
GtkTreeViewDropPosition drop_pos);
65
static void gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
67
GimpViewable *dest_viewable,
68
GtkTreeViewDropPosition drop_pos);
58
70
static void gimp_drawable_tree_view_set_image (GimpItemTreeView *view,
61
73
static void gimp_drawable_tree_view_floating_selection_changed
63
75
GimpDrawableTreeView *view);
65
77
static void gimp_drawable_tree_view_new_pattern_dropped
66
78
(GtkWidget *widget,
67
81
GimpViewable *viewable,
69
83
static void gimp_drawable_tree_view_new_color_dropped
70
84
(GtkWidget *widget,
71
87
const GimpRGB *color,
75
static GimpItemTreeViewClass *parent_class = NULL;
91
G_DEFINE_TYPE_WITH_CODE (GimpDrawableTreeView, gimp_drawable_tree_view,
92
GIMP_TYPE_ITEM_TREE_VIEW,
93
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONTAINER_VIEW,
94
gimp_drawable_tree_view_view_iface_init))
96
#define parent_class gimp_drawable_tree_view_parent_class
76
98
static GimpContainerViewInterface *parent_view_iface = NULL;
80
gimp_drawable_tree_view_get_type (void)
82
static GType view_type = 0;
86
static const GTypeInfo view_info =
88
sizeof (GimpDrawableTreeViewClass),
90
NULL, /* base_finalize */
91
(GClassInitFunc) gimp_drawable_tree_view_class_init,
92
NULL, /* class_finalize */
93
NULL, /* class_data */
94
sizeof (GimpDrawableTreeView),
96
(GInstanceInitFunc) gimp_drawable_tree_view_init,
99
static const GInterfaceInfo view_iface_info =
101
(GInterfaceInitFunc) gimp_drawable_tree_view_view_iface_init,
102
NULL, /* iface_finalize */
103
NULL /* iface_data */
106
view_type = g_type_register_static (GIMP_TYPE_ITEM_TREE_VIEW,
107
"GimpDrawableTreeView",
108
&view_info, G_TYPE_FLAG_ABSTRACT);
110
g_type_add_interface_static (view_type, GIMP_TYPE_CONTAINER_VIEW,
118
102
gimp_drawable_tree_view_class_init (GimpDrawableTreeViewClass *klass)
120
GObjectClass *object_class = G_OBJECT_CLASS (klass);
121
GimpItemTreeViewClass *item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
123
parent_class = g_type_class_peek_parent (klass);
125
object_class->constructor = gimp_drawable_tree_view_constructor;
127
item_view_class->set_image = gimp_drawable_tree_view_set_image;
104
GObjectClass *object_class;
105
GimpContainerTreeViewClass *tree_view_class;
106
GimpItemTreeViewClass *item_view_class;
108
object_class = G_OBJECT_CLASS (klass);
109
tree_view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
110
item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
112
object_class->constructor = gimp_drawable_tree_view_constructor;
114
tree_view_class->drop_possible = gimp_drawable_tree_view_drop_possible;
115
tree_view_class->drop_viewable = gimp_drawable_tree_view_drop_viewable;
116
tree_view_class->drop_color = gimp_drawable_tree_view_drop_color;
118
item_view_class->set_image = gimp_drawable_tree_view_set_image;
122
gimp_drawable_tree_view_view_iface_init (GimpContainerViewInterface *iface)
124
parent_view_iface = g_type_interface_peek_parent (iface);
126
iface->select_item = gimp_drawable_tree_view_select_item;
138
137
GObjectConstructParam *params)
140
GimpItemTreeView *item_view;
139
GimpContainerTreeView *tree_view;
140
GimpItemTreeView *item_view;
143
143
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
145
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
145
146
item_view = GIMP_ITEM_TREE_VIEW (object);
147
148
gimp_dnd_viewable_dest_add (item_view->new_button, GIMP_TYPE_PATTERN,
148
gimp_drawable_tree_view_new_pattern_dropped,
149
gimp_drawable_tree_view_new_pattern_dropped,
150
151
gimp_dnd_color_dest_add (item_view->new_button,
151
152
gimp_drawable_tree_view_new_color_dropped,
155
gimp_dnd_color_dest_add (GTK_WIDGET (tree_view->view),
157
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_PATTERN,
158
gimp_drawable_tree_view_view_iface_init (GimpContainerViewInterface *view_iface)
160
parent_view_iface = g_type_interface_peek_parent (view_iface);
162
view_iface->select_item = gimp_drawable_tree_view_select_item;
166
164
/* GimpContainerView methods */
173
171
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
174
172
gboolean success = TRUE;
176
if (item_view->gimage)
174
if (item_view->image)
178
GimpViewable *floating_sel;
180
floating_sel = (GimpViewable *)
181
gimp_image_floating_sel (item_view->gimage);
183
success = (item == NULL || floating_sel == NULL || item == floating_sel);
176
GimpLayer *floating_sel = gimp_image_floating_sel (item_view->image);
178
success = (item == NULL ||
179
floating_sel == NULL ||
180
item == GIMP_VIEWABLE (floating_sel));
187
return parent_view_iface->select_item (view, item, insert_data);
184
success = parent_view_iface->select_item (view, item, insert_data);
190
/* GimpContainerTreeView methods */
193
gimp_drawable_tree_view_drop_possible (GimpContainerTreeView *tree_view,
194
GimpDndType src_type,
195
GimpViewable *src_viewable,
196
GimpViewable *dest_viewable,
197
GtkTreeViewDropPosition drop_pos,
198
GtkTreeViewDropPosition *return_drop_pos,
199
GdkDragAction *return_drag_action)
201
if (GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_possible (tree_view,
209
if (src_type == GIMP_DND_TYPE_COLOR ||
210
src_type == GIMP_DND_TYPE_PATTERN)
217
if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE)
218
*return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
220
*return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
231
gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view,
232
GimpViewable *src_viewable,
233
GimpViewable *dest_viewable,
234
GtkTreeViewDropPosition drop_pos)
236
if (dest_viewable && GIMP_IS_PATTERN (src_viewable))
238
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
239
GIMP_PATTERN_BUCKET_FILL,
240
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
241
FALSE, /* no seed fill */
242
FALSE, /* don't fill transp */
243
GIMP_SELECT_CRITERION_COMPOSITE,
244
0.0, FALSE, /* fill params */
245
0.0, 0.0, /* ignored */
246
NULL, GIMP_PATTERN (src_viewable));
247
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->image);
251
GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (view,
258
gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
259
const GimpRGB *color,
260
GimpViewable *dest_viewable,
261
GtkTreeViewDropPosition drop_pos)
265
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
267
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
268
FALSE, /* no seed fill */
269
FALSE, /* don't fill transp */
270
GIMP_SELECT_CRITERION_COMPOSITE,
271
0.0, FALSE, /* fill params */
272
0.0, 0.0, /* ignored */
274
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->image);
193
279
/* GimpItemTreeView methods */
196
282
gimp_drawable_tree_view_set_image (GimpItemTreeView *view,
200
g_signal_handlers_disconnect_by_func (view->gimage,
286
g_signal_handlers_disconnect_by_func (view->image,
201
287
gimp_drawable_tree_view_floating_selection_changed,
204
GIMP_ITEM_TREE_VIEW_CLASS (parent_class)->set_image (view, gimage);
290
GIMP_ITEM_TREE_VIEW_CLASS (parent_class)->set_image (view, image);
207
g_signal_connect (view->gimage,
208
"floating_selection_changed",
293
g_signal_connect (view->image,
294
"floating-selection-changed",
209
295
G_CALLBACK (gimp_drawable_tree_view_floating_selection_changed),
230
316
gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view,
231
319
GimpBucketFillMode fill_mode,
232
320
const GimpRGB *color,
233
321
GimpPattern *pattern)
237
gimp_image_undo_group_start (view->gimage, GIMP_UNDO_GROUP_EDIT_PASTE,
325
gimp_image_undo_group_start (view->image, GIMP_UNDO_GROUP_EDIT_PASTE,
240
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->new_item (view->gimage);
328
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->new_item (view->image);
244
GimpDrawable *drawable = GIMP_DRAWABLE (item);
245
GimpToolInfo *tool_info;
332
/* Get the bucket fill context */
246
333
GimpContext *context;
248
/* Get the bucket fill context */
249
tool_info = (GimpToolInfo *)
250
gimp_container_get_child_by_name (view->gimage->gimp->tool_info_list,
251
"gimp-bucket-fill-tool");
334
GimpToolInfo *tool_info = gimp_get_tool_info (view->image->gimp,
335
"gimp-bucket-fill-tool");
253
337
if (tool_info && tool_info->tool_options)
254
338
context = GIMP_CONTEXT (tool_info->tool_options);
256
context = view->context;
340
context = gimp_container_view_get_context (GIMP_CONTAINER_VIEW (view));
258
gimp_drawable_bucket_fill_full (drawable,
342
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (item),
260
344
gimp_context_get_paint_mode (context),
261
345
gimp_context_get_opacity (context),
262
FALSE /* no seed fill */,
263
FALSE, 0.0, FALSE, 0.0, 0.0 /* fill params */,
346
FALSE, /* no seed fill */
347
FALSE, /* don't fill transp */
348
GIMP_SELECT_CRITERION_COMPOSITE,
349
0.0, FALSE, 0.0, 0.0 /* fill params */,
267
gimp_image_undo_group_end (view->gimage);
353
gimp_image_undo_group_end (view->image);
269
gimp_image_flush (view->gimage);
355
gimp_image_flush (view->image);
273
359
gimp_drawable_tree_view_new_pattern_dropped (GtkWidget *widget,
274
362
GimpViewable *viewable,
277
gimp_drawable_tree_view_new_dropped (GIMP_ITEM_TREE_VIEW (data),
365
gimp_drawable_tree_view_new_dropped (GIMP_ITEM_TREE_VIEW (data), x, y,
278
366
GIMP_PATTERN_BUCKET_FILL,
280
368
GIMP_PATTERN (viewable));