]> Pileus Git - ~andy/gtk/blob - gtk/gtkcolorswatch.c
GtkColorSwatch: Use widget state instead of a custom 'selected'
[~andy/gtk] / gtk / gtkcolorswatch.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2012 Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "config.h"
21
22 #include "gtkcolorswatchprivate.h"
23
24 #include "gtkroundedboxprivate.h"
25 #include "gtkthemingbackgroundprivate.h"
26 #include "gtkdnd.h"
27 #include "gtkicontheme.h"
28 #include "gtkmain.h"
29 #include "gtkmenu.h"
30 #include "gtkmenuitem.h"
31 #include "gtkmenushell.h"
32 #include "gtkprivate.h"
33 #include "gtkintl.h"
34
35
36 struct _GtkColorSwatchPrivate
37 {
38   GdkRGBA color;
39   gdouble radius[4];
40   gchar *icon;
41   guint    has_color        : 1;
42   guint    contains_pointer : 1;
43   guint    use_alpha        : 1;
44 };
45
46 enum
47 {
48   PROP_ZERO,
49   PROP_RGBA,
50   PROP_SELECTED
51 };
52
53 enum
54 {
55   ACTIVATE,
56   CUSTOMIZE,
57   LAST_SIGNAL
58 };
59
60 static guint signals[LAST_SIGNAL];
61
62 G_DEFINE_TYPE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_DRAWING_AREA)
63
64 static void
65 gtk_color_swatch_init (GtkColorSwatch *swatch)
66 {
67   swatch->priv = G_TYPE_INSTANCE_GET_PRIVATE (swatch,
68                                               GTK_TYPE_COLOR_SWATCH,
69                                               GtkColorSwatchPrivate);
70
71   gtk_widget_set_can_focus (GTK_WIDGET (swatch), TRUE);
72   gtk_widget_set_events (GTK_WIDGET (swatch), GDK_BUTTON_PRESS_MASK
73                                               | GDK_BUTTON_RELEASE_MASK
74                                               | GDK_EXPOSURE_MASK
75                                               | GDK_ENTER_NOTIFY_MASK
76                                               | GDK_LEAVE_NOTIFY_MASK);
77   swatch->priv->use_alpha = TRUE;
78 }
79
80 #define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
81
82 static cairo_pattern_t *
83 get_checkered_pattern (void)
84 {
85   /* need to respect pixman's stride being a multiple of 4 */
86   static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
87                                    0x00, 0xFF, 0x00, 0x00 };
88   static cairo_surface_t *checkered = NULL;
89   cairo_pattern_t *pattern;
90
91   if (checkered == NULL)
92     checkered = cairo_image_surface_create_for_data (data,
93                                                      CAIRO_FORMAT_A8,
94                                                      2, 2, 4);
95
96   pattern = cairo_pattern_create_for_surface (checkered);
97   cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
98   cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
99
100   return pattern;
101 }
102
103 static gboolean
104 swatch_draw (GtkWidget *widget,
105              cairo_t   *cr)
106 {
107   GtkColorSwatch *swatch = (GtkColorSwatch*)widget;
108   GtkThemingBackground background;
109   gdouble width, height;
110   GtkStyleContext *context;
111   GtkStateFlags state;
112   GtkIconTheme *theme;
113   GtkIconInfo *icon_info = NULL;
114
115   theme = gtk_icon_theme_get_default ();
116   context = gtk_widget_get_style_context (widget);
117   state = gtk_widget_get_state_flags (widget);
118   width = gtk_widget_get_allocated_width (widget);
119   height = gtk_widget_get_allocated_height (widget);
120
121   cairo_save (cr);
122
123   gtk_style_context_save (context);
124   gtk_style_context_set_state (context, state);
125
126   _gtk_theming_background_init_from_context (&background, context,
127                                              0, 0, width, height,
128                                              GTK_JUNCTION_NONE);
129
130   if (swatch->priv->has_color)
131     {
132       cairo_pattern_t *pattern;
133       cairo_matrix_t matrix;
134
135       if (swatch->priv->use_alpha)
136         {
137           cairo_save (cr);
138
139           _gtk_rounded_box_path (&background.clip_box, cr);
140           cairo_clip_preserve (cr);
141
142           cairo_set_source_rgb (cr, 0.33, 0.33, 0.33);
143           cairo_fill_preserve (cr);
144
145           pattern = get_checkered_pattern ();
146           cairo_matrix_init_scale (&matrix, 0.125, 0.125);
147           cairo_pattern_set_matrix (pattern, &matrix);
148
149           cairo_set_source_rgb (cr, 0.66, 0.66, 0.66);
150           cairo_mask (cr, pattern);
151           cairo_pattern_destroy (pattern);
152
153           cairo_restore (cr);
154
155           background.bg_color = swatch->priv->color;
156         }
157       else
158         {
159           background.bg_color = swatch->priv->color;
160           background.bg_color.alpha = 1.0;
161         }
162
163       _gtk_theming_background_render (&background, cr);
164     }
165
166   gtk_render_frame (context, cr,
167                     0, 0, width, height);
168
169   if (gtk_widget_has_visible_focus (widget))
170     {
171       cairo_set_line_width (cr, 2);
172       if (swatch->priv->has_color && INTENSITY (swatch->priv->color.red, swatch->priv->color.green, swatch->priv->color.blue) < 0.5)
173         cairo_set_source_rgba (cr, 1., 1., 1., 0.4);
174       else
175         cairo_set_source_rgba (cr, 0., 0., 0., 0.4);
176       _gtk_rounded_box_shrink (&background.clip_box, 3, 3, 3, 3);
177       _gtk_rounded_box_path (&background.clip_box, cr);
178       cairo_stroke (cr);
179     }
180
181   if (swatch->priv->icon)
182     {
183       icon_info = gtk_icon_theme_lookup_icon (theme, swatch->priv->icon, 16,
184                                               GTK_ICON_LOOKUP_GENERIC_FALLBACK
185                                               | GTK_ICON_LOOKUP_USE_BUILTIN);
186     }
187   else if ((state & GTK_STATE_FLAG_SELECTED) != 0)
188     {
189       GdkRGBA bg, border;
190       GtkBorder border_width;
191       GIcon *gicon;
192
193       gtk_style_context_add_class (context, "color-active-badge");
194       gtk_style_context_get_background_color (context, state, &bg);
195       gtk_style_context_get_border_color (context, state, &border);
196       gtk_style_context_get_border (context, state, &border_width);
197
198       cairo_new_sub_path (cr);
199       cairo_arc (cr, width / 2, height / 2, 10, 0, 2 * G_PI);
200       cairo_close_path (cr);
201       gdk_cairo_set_source_rgba (cr, &bg);
202       cairo_fill_preserve (cr);
203
204       gdk_cairo_set_source_rgba (cr, &border);
205       cairo_set_line_width (cr, border_width.left);
206       cairo_stroke (cr);
207
208       gicon = g_themed_icon_new ("object-select-symbolic");
209       /* fallback for themes that don't have object-select-symbolic */
210       g_themed_icon_append_name (G_THEMED_ICON (gicon), "gtk-apply");
211
212       icon_info = gtk_icon_theme_lookup_by_gicon (theme, gicon, 16,
213                                                   GTK_ICON_LOOKUP_GENERIC_FALLBACK
214                                                   | GTK_ICON_LOOKUP_USE_BUILTIN);
215       g_object_unref (gicon);
216     }
217
218   if (icon_info != NULL)
219     {
220       GdkPixbuf *pixbuf;
221
222       pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, context,
223                                                         NULL, NULL);
224
225       if (pixbuf != NULL)
226         {
227           gtk_render_icon (context, cr, pixbuf,
228                            (width - gdk_pixbuf_get_width (pixbuf)) / 2,
229                            (height - gdk_pixbuf_get_height (pixbuf)) / 2);
230           g_object_unref (pixbuf);
231         }
232
233       gtk_icon_info_free (icon_info);
234     }
235
236   cairo_restore (cr);
237   gtk_style_context_restore (context);
238
239   return FALSE;
240 }
241
242 static void
243 drag_set_color_icon (GdkDragContext *context,
244                      const GdkRGBA  *color)
245 {
246   cairo_surface_t *surface;
247   cairo_t *cr;
248
249   surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 48, 32);
250   cr = cairo_create (surface);
251   gdk_cairo_set_source_rgba (cr, color);
252   cairo_paint (cr);
253
254   cairo_surface_set_device_offset (surface, -4, -4);
255   gtk_drag_set_icon_surface (context, surface);
256
257   cairo_destroy (cr);
258   cairo_surface_destroy (surface);
259 }
260
261 static void
262 swatch_drag_begin (GtkWidget      *widget,
263                    GdkDragContext *context)
264 {
265   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
266   GdkRGBA color;
267
268   gtk_color_swatch_get_rgba (swatch, &color);
269   drag_set_color_icon (context, &color);
270 }
271
272 static void
273 swatch_drag_data_get (GtkWidget        *widget,
274                       GdkDragContext   *context,
275                       GtkSelectionData *selection_data,
276                       guint             info,
277                       guint             time)
278 {
279   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
280   guint16 vals[4];
281   GdkRGBA color;
282
283   gtk_color_swatch_get_rgba (swatch, &color);
284
285   vals[0] = color.red * 0xffff;
286   vals[1] = color.green * 0xffff;
287   vals[2] = color.blue * 0xffff;
288   vals[3] = color.alpha * 0xffff;
289
290   gtk_selection_data_set (selection_data,
291                           gdk_atom_intern_static_string ("application/x-color"),
292                           16, (guchar *)vals, 8);
293 }
294
295 static void
296 swatch_drag_data_received (GtkWidget        *widget,
297                            GdkDragContext   *context,
298                            gint              x,
299                            gint              y,
300                            GtkSelectionData *selection_data,
301                            guint             info,
302                            guint             time)
303 {
304   gint length;
305   guint16 *vals;
306   GdkRGBA color;
307
308   length = gtk_selection_data_get_length (selection_data);
309
310   if (length < 0)
311     return;
312
313   /* We accept drops with the wrong format, since the KDE color
314    * chooser incorrectly drops application/x-color with format 8.
315    */
316   if (length != 8)
317     {
318       g_warning ("Received invalid color data\n");
319       return;
320     }
321
322   vals = (guint16 *) gtk_selection_data_get_data (selection_data);
323
324   color.red   = (gdouble)vals[0] / 0xffff;
325   color.green = (gdouble)vals[1] / 0xffff;
326   color.blue  = (gdouble)vals[2] / 0xffff;
327   color.alpha = (gdouble)vals[3] / 0xffff;
328
329   gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (widget), &color);
330 }
331
332 static void
333 swatch_get_preferred_width (GtkWidget *widget,
334                             gint      *min,
335                             gint      *nat)
336 {
337   *min = *nat = 48;
338 }
339
340 static void
341 swatch_get_preferred_height (GtkWidget *widget,
342                              gint      *min,
343                              gint      *nat)
344 {
345   *min = *nat = 32;
346 }
347
348 static gboolean
349 swatch_key_press (GtkWidget   *widget,
350                   GdkEventKey *event)
351 {
352   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
353
354   if (event->keyval == GDK_KEY_space ||
355       event->keyval == GDK_KEY_Return ||
356       event->keyval == GDK_KEY_ISO_Enter||
357       event->keyval == GDK_KEY_KP_Enter ||
358       event->keyval == GDK_KEY_KP_Space)
359     {
360       if (swatch->priv->has_color && (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED) == 0)
361         gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
362       else
363         g_signal_emit (swatch, signals[ACTIVATE], 0);
364       return TRUE;
365     }
366
367   if (GTK_WIDGET_CLASS (gtk_color_swatch_parent_class)->key_press_event (widget, event))
368     return TRUE;
369
370   return FALSE;
371 }
372
373 static gboolean
374 swatch_enter_notify (GtkWidget        *widget,
375                      GdkEventCrossing *event)
376 {
377   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
378   swatch->priv->contains_pointer = TRUE;
379   return FALSE;
380 }
381
382 static gboolean
383 swatch_leave_notify (GtkWidget        *widget,
384                      GdkEventCrossing *event)
385 {
386   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
387   swatch->priv->contains_pointer = FALSE;
388   return FALSE;
389 }
390
391 static void
392 emit_customize (GtkColorSwatch *swatch)
393 {
394   g_signal_emit (swatch, signals[CUSTOMIZE], 0);
395 }
396
397 static void
398 popup_position_func (GtkMenu   *menu,
399                      gint      *x,
400                      gint      *y,
401                      gboolean  *push_in,
402                      gpointer   user_data)
403 {
404   GtkWidget *widget;
405   GtkRequisition req;
406   gint root_x, root_y;
407   GdkScreen *screen;
408   GdkWindow *window;
409   GdkRectangle monitor;
410   gint monitor_num;
411
412   widget = GTK_WIDGET (user_data);
413   g_return_if_fail (gtk_widget_get_realized (widget));
414   window = gtk_widget_get_window (widget);
415
416   screen = gtk_widget_get_screen (widget);
417   monitor_num = gdk_screen_get_monitor_at_window (screen, window);
418   if (monitor_num < 0)
419     monitor_num = 0;
420   gtk_menu_set_monitor (menu, monitor_num);
421
422   gdk_window_get_origin (window, &root_x, &root_y);
423   gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
424
425   /* Put corner of menu centered on swatch */
426   *x = root_x + gtk_widget_get_allocated_width (widget) / 2;
427   *y = root_y + gtk_widget_get_allocated_height (widget) / 2;
428
429   /* Ensure sanity */
430   gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
431   *x = CLAMP (*x, monitor.x, MAX (monitor.x, monitor.width - req.width));
432   *y = CLAMP (*y, monitor.y, MAX (monitor.y, monitor.height - req.height));
433 }
434
435 static void
436 do_popup (GtkWidget      *swatch,
437           GdkEventButton *event)
438 {
439   GtkWidget *menu;
440   GtkWidget *item;
441
442   menu = gtk_menu_new ();
443   item = gtk_menu_item_new_with_mnemonic (_("_Customize"));
444   gtk_menu_attach_to_widget (GTK_MENU (menu), swatch, NULL);
445
446   g_signal_connect_swapped (item, "activate",
447                             G_CALLBACK (emit_customize), swatch);
448
449   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
450
451   gtk_widget_show_all (item);
452
453   if (event)
454     gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
455                     NULL, NULL, event->button, event->time);
456   else
457     gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
458                     popup_position_func, swatch,
459                     0, gtk_get_current_event_time ());
460 }
461
462 static gboolean
463 swatch_button_press (GtkWidget      *widget,
464                      GdkEventButton *event)
465 {
466   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
467
468   gtk_widget_grab_focus (widget);
469
470   if (gdk_event_triggers_context_menu ((GdkEvent *) event) &&
471       swatch->priv->has_color)
472     {
473       do_popup (widget, event);
474       return TRUE;
475     }
476   else if (event->type == GDK_2BUTTON_PRESS &&
477            event->button == GDK_BUTTON_PRIMARY)
478     {
479       g_signal_emit (swatch, signals[ACTIVATE], 0);
480       return TRUE;
481     }
482
483   return FALSE;
484 }
485
486 static gboolean
487 swatch_button_release (GtkWidget      *widget,
488                        GdkEventButton *event)
489 {
490   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
491   GtkStateFlags flags;
492
493   if (event->button == GDK_BUTTON_PRIMARY &&
494       swatch->priv->contains_pointer)
495     {
496       flags = gtk_widget_get_state_flags (widget);
497       if (!swatch->priv->has_color)
498         {
499           g_signal_emit (swatch, signals[ACTIVATE], 0);
500           return TRUE;
501         }
502       else if ((flags & GTK_STATE_FLAG_SELECTED) == 0)
503         {
504           gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
505           return TRUE;
506         }
507     }
508
509   return FALSE;
510 }
511
512 static gboolean
513 swatch_popup_menu (GtkWidget *swatch)
514 {
515   do_popup (swatch, NULL);
516   return TRUE;
517 }
518
519 /* GObject implementation {{{1 */
520
521 static void
522 swatch_get_property (GObject    *object,
523                      guint       prop_id,
524                      GValue     *value,
525                      GParamSpec *pspec)
526 {
527   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
528   GdkRGBA color;
529
530   switch (prop_id)
531     {
532     case PROP_RGBA:
533       gtk_color_swatch_get_rgba (swatch, &color);
534       g_value_set_boxed (value, &color);
535       break;
536     default:
537       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
538       break;
539     }
540 }
541
542 static void
543 swatch_set_property (GObject      *object,
544                      guint         prop_id,
545                      const GValue *value,
546                      GParamSpec   *pspec)
547 {
548   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
549
550   switch (prop_id)
551     {
552     case PROP_RGBA:
553       gtk_color_swatch_set_rgba (swatch, g_value_get_boxed (value));
554       break;
555     default:
556       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
557       break;
558     }
559 }
560
561 static void
562 swatch_finalize (GObject *object)
563 {
564   GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
565
566   g_free (swatch->priv->icon);
567
568   G_OBJECT_CLASS (gtk_color_swatch_parent_class)->finalize (object);
569 }
570
571 static void
572 gtk_color_swatch_class_init (GtkColorSwatchClass *class)
573 {
574   GtkWidgetClass *widget_class = (GtkWidgetClass *)class;
575   GObjectClass *object_class = (GObjectClass *)class;
576
577   object_class->get_property = swatch_get_property;
578   object_class->set_property = swatch_set_property;
579   object_class->finalize = swatch_finalize;
580
581   widget_class->get_preferred_width = swatch_get_preferred_width;
582   widget_class->get_preferred_height = swatch_get_preferred_height;
583   widget_class->draw = swatch_draw;
584   widget_class->drag_begin = swatch_drag_begin;
585   widget_class->drag_data_get = swatch_drag_data_get;
586   widget_class->drag_data_received = swatch_drag_data_received;
587   widget_class->key_press_event = swatch_key_press;
588   widget_class->popup_menu = swatch_popup_menu;
589   widget_class->button_press_event = swatch_button_press;
590   widget_class->button_release_event = swatch_button_release;
591   widget_class->enter_notify_event = swatch_enter_notify;
592   widget_class->leave_notify_event = swatch_leave_notify;
593
594   signals[ACTIVATE] =
595     g_signal_new ("activate",
596                   GTK_TYPE_COLOR_SWATCH,
597                   G_SIGNAL_RUN_FIRST,
598                   G_STRUCT_OFFSET (GtkColorSwatchClass, activate),
599                   NULL, NULL, NULL, G_TYPE_NONE, 0);
600
601   signals[CUSTOMIZE] =
602     g_signal_new ("customize",
603                   GTK_TYPE_COLOR_SWATCH,
604                   G_SIGNAL_RUN_FIRST,
605                   G_STRUCT_OFFSET (GtkColorSwatchClass, customize),
606                   NULL, NULL, NULL, G_TYPE_NONE, 0);
607
608   g_object_class_install_property (object_class, PROP_RGBA,
609       g_param_spec_boxed ("rgba", P_("RGBA Color"), P_("Color as RGBA"),
610                           GDK_TYPE_RGBA, GTK_PARAM_READWRITE));
611
612   g_type_class_add_private (object_class, sizeof (GtkColorSwatchPrivate));
613 }
614
615 /* Public API {{{1 */
616
617 GtkWidget *
618 gtk_color_swatch_new (void)
619 {
620   return (GtkWidget *) g_object_new (GTK_TYPE_COLOR_SWATCH, NULL);
621 }
622
623 static const GtkTargetEntry dnd_targets[] = {
624   { "application/x-color", 0 }
625 };
626
627 void
628 gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
629                            const GdkRGBA  *color)
630 {
631   GtkStyleContext *context;
632
633   context = gtk_widget_get_style_context (GTK_WIDGET (swatch));
634
635   if (!swatch->priv->has_color)
636     {
637       gtk_drag_source_set (GTK_WIDGET (swatch),
638                            GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
639                            dnd_targets, G_N_ELEMENTS (dnd_targets),
640                            GDK_ACTION_COPY | GDK_ACTION_MOVE);
641     }
642   else
643     {
644       gtk_style_context_remove_class (context, "color-light");
645       gtk_style_context_remove_class (context, "color-dark");
646     }
647
648   swatch->priv->has_color = TRUE;
649   swatch->priv->color = *color;
650
651   if (INTENSITY (swatch->priv->color.red, swatch->priv->color.green, swatch->priv->color.blue) > 0.5)
652     gtk_style_context_add_class (context, "color-light");
653   else
654     gtk_style_context_add_class (context, "color-dark");
655
656   gtk_widget_queue_draw (GTK_WIDGET (swatch));
657   g_object_notify (G_OBJECT (swatch), "rgba");
658 }
659
660 gboolean
661 gtk_color_swatch_get_rgba (GtkColorSwatch *swatch,
662                            GdkRGBA        *color)
663 {
664   if (swatch->priv->has_color)
665     {
666       color->red = swatch->priv->color.red;
667       color->green = swatch->priv->color.green;
668       color->blue = swatch->priv->color.blue;
669       color->alpha = swatch->priv->color.alpha;
670       return TRUE;
671     }
672   else
673     {
674       color->red = 1.0;
675       color->green = 1.0;
676       color->blue = 1.0;
677       color->alpha = 1.0;
678       return FALSE;
679     }
680 }
681
682 void
683 gtk_color_swatch_set_icon (GtkColorSwatch *swatch,
684                            const gchar    *icon)
685 {
686   swatch->priv->icon = g_strdup (icon);
687   gtk_widget_queue_draw (GTK_WIDGET (swatch));
688 }
689
690 void
691 gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
692                                gboolean        can_drop)
693 {
694   if (can_drop)
695     {
696       gtk_drag_dest_set (GTK_WIDGET (swatch),
697                          GTK_DEST_DEFAULT_HIGHLIGHT |
698                          GTK_DEST_DEFAULT_MOTION |
699                          GTK_DEST_DEFAULT_DROP,
700                          dnd_targets, G_N_ELEMENTS (dnd_targets),
701                          GDK_ACTION_COPY);
702     }
703   else
704     {
705       gtk_drag_dest_unset (GTK_WIDGET (swatch));
706     }
707 }
708
709 void
710 gtk_color_swatch_set_use_alpha (GtkColorSwatch *swatch,
711                                 gboolean        use_alpha)
712 {
713   swatch->priv->use_alpha = use_alpha;
714   gtk_widget_queue_draw (GTK_WIDGET (swatch));
715 }
716
717 /* vim:set foldmethod=marker: */