99
105
static GtkWidget * gimp_dnd_get_viewable_icon (GtkWidget *widget,
100
106
GCallback get_viewable_func,
101
107
gpointer get_viewable_data);
108
static GtkWidget * gimp_dnd_get_component_icon (GtkWidget *widget,
109
GCallback get_comp_func,
110
gpointer get_comp_data);
102
111
static GtkWidget * gimp_dnd_get_color_icon (GtkWidget *widget,
103
112
GCallback get_color_func,
104
113
gpointer get_color_data);
106
115
static void gimp_dnd_get_uri_list_data (GtkWidget *widget,
116
GdkDragContext *context,
107
117
GCallback get_uri_list_func,
108
118
gpointer get_uri_list_data,
109
GtkSelectionData *selection,
119
GtkSelectionData *selection);
111
120
static gboolean gimp_dnd_set_uri_list_data (GtkWidget *widget,
112
123
GCallback set_uri_list_func,
113
124
gpointer set_uri_list_data,
114
125
GtkSelectionData *selection);
127
static void gimp_dnd_get_xds_data (GtkWidget *widget,
128
GdkDragContext *context,
129
GCallback get_image_func,
130
gpointer get_image_data,
131
GtkSelectionData *selection);
116
133
static void gimp_dnd_get_color_data (GtkWidget *widget,
134
GdkDragContext *context,
117
135
GCallback get_color_func,
118
136
gpointer get_color_data,
119
GtkSelectionData *selection,
137
GtkSelectionData *selection);
121
138
static gboolean gimp_dnd_set_color_data (GtkWidget *widget,
122
141
GCallback set_color_func,
123
142
gpointer set_color_data,
124
143
GtkSelectionData *selection);
126
145
static void gimp_dnd_get_stream_data (GtkWidget *widget,
146
GdkDragContext *context,
127
147
GCallback get_stream_func,
128
148
gpointer get_stream_data,
129
GtkSelectionData *selection,
149
GtkSelectionData *selection);
131
150
static gboolean gimp_dnd_set_stream_data (GtkWidget *widget,
132
153
GCallback set_stream_func,
133
154
gpointer set_stream_data,
134
155
GtkSelectionData *selection);
157
static void gimp_dnd_get_pixbuf_data (GtkWidget *widget,
158
GdkDragContext *context,
159
GCallback get_pixbuf_func,
160
gpointer get_pixbuf_data,
161
GtkSelectionData *selection);
162
static gboolean gimp_dnd_set_pixbuf_data (GtkWidget *widget,
165
GCallback set_pixbuf_func,
166
gpointer set_pixbuf_data,
167
GtkSelectionData *selection);
168
static void gimp_dnd_get_component_data (GtkWidget *widget,
169
GdkDragContext *context,
170
GCallback get_comp_func,
171
gpointer get_comp_data,
172
GtkSelectionData *selection);
173
static gboolean gimp_dnd_set_component_data (GtkWidget *widget,
176
GCallback set_comp_func,
177
gpointer set_comp_data,
178
GtkSelectionData *selection);
136
180
static void gimp_dnd_get_image_data (GtkWidget *widget,
181
GdkDragContext *context,
137
182
GCallback get_image_func,
138
183
gpointer get_image_data,
139
GtkSelectionData *selection,
184
GtkSelectionData *selection);
141
185
static gboolean gimp_dnd_set_image_data (GtkWidget *widget,
142
188
GCallback set_image_func,
143
189
gpointer set_image_data,
144
190
GtkSelectionData *selection);
146
192
static void gimp_dnd_get_item_data (GtkWidget *widget,
193
GdkDragContext *context,
147
194
GCallback get_item_func,
148
195
gpointer get_item_data,
149
GtkSelectionData *selection,
196
GtkSelectionData *selection);
151
197
static gboolean gimp_dnd_set_item_data (GtkWidget *widget,
152
200
GCallback set_item_func,
153
201
gpointer set_item_data,
154
202
GtkSelectionData *selection);
156
static void gimp_dnd_get_data_data (GtkWidget *widget,
157
GCallback get_data_func,
158
gpointer get_data_data,
159
GtkSelectionData *selection,
204
static void gimp_dnd_get_object_data (GtkWidget *widget,
205
GdkDragContext *context,
206
GCallback get_object_func,
207
gpointer get_object_data,
208
GtkSelectionData *selection);
162
210
static gboolean gimp_dnd_set_brush_data (GtkWidget *widget,
163
213
GCallback set_brush_func,
164
214
gpointer set_brush_data,
165
215
GtkSelectionData *selection);
166
216
static gboolean gimp_dnd_set_pattern_data (GtkWidget *widget,
167
219
GCallback set_pattern_func,
168
220
gpointer set_pattern_data,
169
221
GtkSelectionData *selection);
170
222
static gboolean gimp_dnd_set_gradient_data (GtkWidget *widget,
171
225
GCallback set_gradient_func,
172
226
gpointer set_gradient_data,
173
227
GtkSelectionData *selection);
174
228
static gboolean gimp_dnd_set_palette_data (GtkWidget *widget,
175
231
GCallback set_palette_func,
176
232
gpointer set_palette_data,
177
233
GtkSelectionData *selection);
178
234
static gboolean gimp_dnd_set_font_data (GtkWidget *widget,
179
237
GCallback set_font_func,
180
238
gpointer set_font_data,
181
239
GtkSelectionData *selection);
182
240
static gboolean gimp_dnd_set_buffer_data (GtkWidget *widget,
183
243
GCallback set_buffer_func,
184
244
gpointer set_buffer_data,
185
245
GtkSelectionData *selection);
186
246
static gboolean gimp_dnd_set_imagefile_data (GtkWidget *widget,
187
249
GCallback set_imagefile_func,
188
250
gpointer set_imagefile_data,
189
251
GtkSelectionData *selection);
190
252
static gboolean gimp_dnd_set_template_data (GtkWidget *widget,
191
255
GCallback set_template_func,
192
256
gpointer set_template_data,
193
257
GtkSelectionData *selection);
194
static gboolean gimp_dnd_set_tool_data (GtkWidget *widget,
195
GCallback set_tool_func,
196
gpointer set_tool_data,
258
static gboolean gimp_dnd_set_tool_info_data (GtkWidget *widget,
261
GCallback set_tool_info_func,
262
gpointer set_tool_info_data,
197
263
GtkSelectionData *selection);
201
static GimpDndDataDef dnd_data_defs[] =
267
static const GimpDndDataDef dnd_data_defs[] =
1143
/******************************/
1144
/* Direct Save Protocol (XDS) */
1145
/******************************/
1148
gimp_dnd_get_xds_data (GtkWidget *widget,
1149
GdkDragContext *context,
1150
GCallback get_image_func,
1151
gpointer get_image_data,
1152
GtkSelectionData *selection)
1155
GimpContext *gimp_context;
1157
image = (GimpImage *)
1158
(* (GimpDndDragViewableFunc) get_image_func) (widget, &gimp_context,
1162
gimp_dnd_xds_save_image (context, image, selection);
1166
gimp_dnd_xds_drag_begin (GtkWidget *widget,
1167
GdkDragContext *context)
1169
const GimpDndDataDef *dnd_data = dnd_data_defs + GIMP_DND_TYPE_XDS;
1170
GCallback get_data_func;
1171
gpointer get_data_data;
1173
get_data_func = g_object_get_data (G_OBJECT (widget),
1174
dnd_data->get_data_func_name);
1175
get_data_data = g_object_get_data (G_OBJECT (widget),
1176
dnd_data->get_data_data_name);
1181
GimpContext *gimp_context;
1183
image = (GimpImage *)
1184
(* (GimpDndDragViewableFunc) get_data_func) (widget, &gimp_context,
1187
gimp_dnd_xds_source_set (context, image);
1192
gimp_dnd_xds_drag_end (GtkWidget *widget,
1193
GdkDragContext *context)
1195
gimp_dnd_xds_source_set (context, NULL);
1199
gimp_dnd_xds_source_add (GtkWidget *widget,
1200
GimpDndDragViewableFunc get_image_func,
1205
g_return_if_fail (GTK_IS_WIDGET (widget));
1207
gimp_dnd_data_source_add (GIMP_DND_TYPE_XDS, widget,
1208
G_CALLBACK (get_image_func),
1211
handler = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
1212
"gimp-dnd-xds-drag-begin"));
1216
handler = g_signal_connect (widget, "drag-begin",
1217
G_CALLBACK (gimp_dnd_xds_drag_begin),
1219
g_object_set_data (G_OBJECT (widget), "gimp-dnd-xds-drag-begin",
1220
GUINT_TO_POINTER (handler));
1223
handler = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
1224
"gimp-dnd-xds-drag-end"));
1228
handler = g_signal_connect (widget, "drag-end",
1229
G_CALLBACK (gimp_dnd_xds_drag_end),
1231
g_object_set_data (G_OBJECT (widget), "gimp-dnd-xds-drag-end",
1232
GUINT_TO_POINTER (handler));
1237
gimp_dnd_xds_source_remove (GtkWidget *widget)
1241
g_return_if_fail (GTK_IS_WIDGET (widget));
1243
handler = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
1244
"gimp-dnd-xds-drag-begin"));
1247
g_signal_handler_disconnect (widget, handler);
1248
g_object_set_data (G_OBJECT (widget), "gimp-dnd-xds-drag-begin", NULL);
1251
handler = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
1252
"gimp-dnd-xds-drag-end"));
1255
g_signal_handler_disconnect (widget, handler);
1256
g_object_set_data (G_OBJECT (widget), "gimp-dnd-xds-drag-end", NULL);
1259
gimp_dnd_data_source_remove (GIMP_DND_TYPE_XDS, widget);
1035
1263
/*************************/
1036
1264
/* color dnd functions */
1037
1265
/*************************/
1047
1275
(* (GimpDndDragColorFunc) get_color_func) (widget, &color, get_color_data);
1049
color_area = gimp_color_area_new (&color, TRUE, 0);
1050
gtk_widget_set_size_request (color_area, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
1277
color_area = gimp_color_area_new (&color, GIMP_COLOR_AREA_SMALL_CHECKS, 0);
1278
gtk_widget_set_size_request (color_area,
1279
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
1052
1281
return color_area;
1056
1285
gimp_dnd_get_color_data (GtkWidget *widget,
1286
GdkDragContext *context,
1057
1287
GCallback get_color_func,
1058
1288
gpointer get_color_data,
1059
GtkSelectionData *selection,
1289
GtkSelectionData *selection)
1064
1293
(* (GimpDndDragColorFunc) get_color_func) (widget, &color, get_color_data);
1066
gimp_selection_data_set_color (selection, atom, &color);
1295
gimp_selection_data_set_color (selection, &color);
1069
1298
static gboolean
1070
1299
gimp_dnd_set_color_data (GtkWidget *widget,
1071
1302
GCallback set_color_func,
1072
1303
gpointer set_color_data,
1073
1304
GtkSelectionData *selection)
1454
/**************************/
1455
/* pixbuf dnd functions */
1456
/**************************/
1459
gimp_dnd_get_pixbuf_data (GtkWidget *widget,
1460
GdkDragContext *context,
1461
GCallback get_pixbuf_func,
1462
gpointer get_pixbuf_data,
1463
GtkSelectionData *selection)
1467
pixbuf = (* (GimpDndDragPixbufFunc) get_pixbuf_func) (widget,
1472
gimp_set_busy (the_dnd_gimp);
1474
gtk_selection_data_set_pixbuf (selection, pixbuf);
1475
g_object_unref (pixbuf);
1477
gimp_unset_busy (the_dnd_gimp);
1482
gimp_dnd_set_pixbuf_data (GtkWidget *widget,
1485
GCallback set_pixbuf_func,
1486
gpointer set_pixbuf_data,
1487
GtkSelectionData *selection)
1491
gimp_set_busy (the_dnd_gimp);
1493
pixbuf = gtk_selection_data_get_pixbuf (selection);
1495
gimp_unset_busy (the_dnd_gimp);
1500
(* (GimpDndDropPixbufFunc) set_pixbuf_func) (widget, x, y,
1504
g_object_unref (pixbuf);
1510
gimp_dnd_pixbuf_source_add (GtkWidget *widget,
1511
GimpDndDragPixbufFunc get_pixbuf_func,
1514
GtkTargetList *target_list;
1516
g_return_if_fail (GTK_IS_WIDGET (widget));
1518
gimp_dnd_data_source_add (GIMP_DND_TYPE_PIXBUF, widget,
1519
G_CALLBACK (get_pixbuf_func),
1522
target_list = gtk_drag_source_get_target_list (widget);
1525
gtk_target_list_ref (target_list);
1527
target_list = gtk_target_list_new (NULL, 0);
1529
gimp_pixbuf_targets_add (target_list, GIMP_DND_TYPE_PIXBUF, TRUE);
1531
gtk_drag_source_set_target_list (widget, target_list);
1532
gtk_target_list_unref (target_list);
1536
gimp_dnd_pixbuf_source_remove (GtkWidget *widget)
1538
GtkTargetList *target_list;
1540
g_return_if_fail (GTK_IS_WIDGET (widget));
1542
gimp_dnd_data_source_remove (GIMP_DND_TYPE_PIXBUF, widget);
1544
target_list = gtk_drag_source_get_target_list (widget);
1547
gimp_pixbuf_targets_remove (target_list);
1551
gimp_dnd_pixbuf_dest_add (GtkWidget *widget,
1552
GimpDndDropPixbufFunc set_pixbuf_func,
1555
GtkTargetList *target_list;
1557
g_return_if_fail (GTK_IS_WIDGET (widget));
1559
gimp_dnd_data_dest_add (GIMP_DND_TYPE_PIXBUF, widget,
1560
G_CALLBACK (set_pixbuf_func),
1563
target_list = gtk_drag_dest_get_target_list (widget);
1566
gtk_target_list_ref (target_list);
1568
target_list = gtk_target_list_new (NULL, 0);
1570
gimp_pixbuf_targets_add (target_list, GIMP_DND_TYPE_PIXBUF, FALSE);
1572
gtk_drag_dest_set_target_list (widget, target_list);
1573
gtk_target_list_unref (target_list);
1577
gimp_dnd_pixbuf_dest_remove (GtkWidget *widget)
1579
GtkTargetList *target_list;
1581
g_return_if_fail (GTK_IS_WIDGET (widget));
1583
gimp_dnd_data_dest_remove (GIMP_DND_TYPE_PIXBUF, widget);
1585
target_list = gtk_drag_dest_get_target_list (widget);
1588
gimp_pixbuf_targets_remove (target_list);
1592
/*****************************/
1593
/* component dnd functions */
1594
/*****************************/
1597
gimp_dnd_get_component_icon (GtkWidget *widget,
1598
GCallback get_comp_func,
1599
gpointer get_comp_data)
1603
GimpContext *context;
1604
GimpChannelType channel;
1606
image = (* (GimpDndDragComponentFunc) get_comp_func) (widget, &context,
1613
view = gimp_view_new (context, GIMP_VIEWABLE (image),
1614
DRAG_PREVIEW_SIZE, 0, TRUE);
1616
GIMP_VIEW_RENDERER_IMAGE (GIMP_VIEW (view)->renderer)->channel = channel;
1622
gimp_dnd_get_component_data (GtkWidget *widget,
1623
GdkDragContext *context,
1624
GCallback get_comp_func,
1625
gpointer get_comp_data,
1626
GtkSelectionData *selection)
1629
GimpContext *gimp_context;
1630
GimpChannelType channel = 0;
1632
image = (* (GimpDndDragComponentFunc) get_comp_func) (widget, &gimp_context,
1637
gimp_selection_data_set_component (selection, image, channel);
1641
gimp_dnd_set_component_data (GtkWidget *widget,
1644
GCallback set_comp_func,
1645
gpointer set_comp_data,
1646
GtkSelectionData *selection)
1649
GimpChannelType channel = 0;
1651
image = gimp_selection_data_get_component (selection, the_dnd_gimp,
1657
(* (GimpDndDropComponentFunc) set_comp_func) (widget, x, y,
1665
gimp_dnd_component_source_add (GtkWidget *widget,
1666
GimpDndDragComponentFunc get_comp_func,
1669
g_return_if_fail (GTK_IS_WIDGET (widget));
1671
gimp_dnd_data_source_add (GIMP_DND_TYPE_COMPONENT, widget,
1672
G_CALLBACK (get_comp_func),
1677
gimp_dnd_component_source_remove (GtkWidget *widget)
1679
g_return_if_fail (GTK_IS_WIDGET (widget));
1681
gimp_dnd_data_source_remove (GIMP_DND_TYPE_COMPONENT, widget);
1685
gimp_dnd_component_dest_add (GtkWidget *widget,
1686
GimpDndDropComponentFunc set_comp_func,
1689
g_return_if_fail (GTK_IS_WIDGET (widget));
1691
gimp_dnd_data_dest_add (GIMP_DND_TYPE_COMPONENT, widget,
1692
G_CALLBACK (set_comp_func),
1697
gimp_dnd_component_dest_remove (GtkWidget *widget)
1699
g_return_if_fail (GTK_IS_WIDGET (widget));
1701
gimp_dnd_data_dest_remove (GIMP_DND_TYPE_COMPONENT, widget);
1221
1705
/*******************************************/
1222
1706
/* GimpViewable (by GType) dnd functions */
1223
1707
/*******************************************/
1227
1711
GCallback get_viewable_func,
1228
1712
gpointer get_viewable_data)
1714
GimpViewable *viewable;
1715
GimpContext *context;
1230
1716
GtkWidget *view;
1231
GimpViewable *viewable;
1233
viewable = (* (GimpDndDragViewableFunc) get_viewable_func) (widget,
1719
viewable = (* (GimpDndDragViewableFunc) get_viewable_func) (widget, &context,
1234
1720
get_viewable_data);
1236
1722
if (! viewable)
1239
view = gimp_view_new (viewable, DRAG_PREVIEW_SIZE, 0, TRUE);
1725
view = gimp_view_new (context, viewable,
1726
DRAG_PREVIEW_SIZE, 0, TRUE);
1728
desc = gimp_viewable_get_description (viewable, NULL);
1735
hbox = gtk_hbox_new (FALSE, 3);
1736
gtk_container_set_border_width (GTK_CONTAINER (hbox), 3);
1737
gtk_box_pack_start (GTK_BOX (hbox), view, FALSE, FALSE, 0);
1738
gtk_widget_show (view);
1740
label = g_object_new (GTK_TYPE_LABEL,
1745
"max-width-chars", 30,
1746
"ellipsize", PANGO_ELLIPSIZE_END,
1751
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1752
gtk_widget_show (label);
1460
1977
if (! get_data_func)
1463
return (GimpViewable *) (* get_data_func) (widget, get_data_data);
1980
return (GimpViewable *) (* get_data_func) (widget, &context, get_data_data);
1468
/*************************/
1469
/* image dnd functions */
1470
/*************************/
1985
/*****************************/
1986
/* GimpImage dnd functions */
1987
/*****************************/
1473
1990
gimp_dnd_get_image_data (GtkWidget *widget,
1991
GdkDragContext *context,
1474
1992
GCallback get_image_func,
1475
1993
gpointer get_image_data,
1476
GtkSelectionData *selection,
1994
GtkSelectionData *selection)
1481
gimage = (GimpImage *)
1482
(* (GimpDndDragViewableFunc) get_image_func) (widget, get_image_data);
1485
gimp_selection_data_set_image (selection, atom, gimage);
1997
GimpContext *gimp_context;
1999
image = (GimpImage *)
2000
(* (GimpDndDragViewableFunc) get_image_func) (widget, &gimp_context,
2004
gimp_selection_data_set_image (selection, image);
1488
2007
static gboolean
1489
2008
gimp_dnd_set_image_data (GtkWidget *widget,
1490
2011
GCallback set_image_func,
1491
2012
gpointer set_image_data,
1492
2013
GtkSelectionData *selection)
1494
GimpImage *gimage = gimp_selection_data_get_image (selection, the_dnd_gimp);
2015
GimpImage *image = gimp_selection_data_get_image (selection, the_dnd_gimp);
1499
(* (GimpDndDropViewableFunc) set_image_func) (widget,
1500
GIMP_VIEWABLE (gimage),
2020
(* (GimpDndDropViewableFunc) set_image_func) (widget, x, y,
2021
GIMP_VIEWABLE (image),
1501
2022
set_image_data);
1507
/************************/
1508
/* item dnd functions */
1509
/************************/
2028
/****************************/
2029
/* GimpItem dnd functions */
2030
/****************************/
1512
2033
gimp_dnd_get_item_data (GtkWidget *widget,
2034
GdkDragContext *context,
1513
2035
GCallback get_item_func,
1514
2036
gpointer get_item_data,
1515
GtkSelectionData *selection,
2037
GtkSelectionData *selection)
2040
GimpContext *gimp_context;
1520
2042
item = (GimpItem *)
1521
(* (GimpDndDragViewableFunc) get_item_func) (widget, get_item_data);
2043
(* (GimpDndDragViewableFunc) get_item_func) (widget, &gimp_context,
1524
gimp_selection_data_set_item (selection, atom, item);
2047
gimp_selection_data_set_item (selection, item);
1527
2050
static gboolean
1528
2051
gimp_dnd_set_item_data (GtkWidget *widget,
1529
2054
GCallback set_item_func,
1530
2055
gpointer set_item_data,
1531
2056
GtkSelectionData *selection)
1546
/****************************/
1547
/* GimpData dnd functions */
1548
/****************************/
2071
/******************************/
2072
/* GimpObject dnd functions */
2073
/******************************/
1551
gimp_dnd_get_data_data (GtkWidget *widget,
1552
GCallback get_data_func,
1553
gpointer get_data_data,
1554
GtkSelectionData *selection,
2076
gimp_dnd_get_object_data (GtkWidget *widget,
2077
GdkDragContext *context,
2078
GCallback get_object_func,
2079
gpointer get_object_data,
2080
GtkSelectionData *selection)
1560
(* (GimpDndDragViewableFunc) get_data_func) (widget, get_data_data);
1563
gimp_selection_data_set_viewable (selection, atom, GIMP_VIEWABLE (data));
2083
GimpContext *gimp_context;
2085
object = (GimpObject *)
2086
(* (GimpDndDragViewableFunc) get_object_func) (widget, &gimp_context,
2089
if (GIMP_IS_OBJECT (object))
2090
gimp_selection_data_set_object (selection, object);
1567
/*************************/
1568
/* brush dnd functions */
1569
/*************************/
2094
/*****************************/
2095
/* GimpBrush dnd functions */
2096
/*****************************/
1571
2098
static gboolean
1572
2099
gimp_dnd_set_brush_data (GtkWidget *widget,
1573
2102
GCallback set_brush_func,
1574
2103
gpointer set_brush_data,
1575
2104
GtkSelectionData *selection)