From 0e1978d27346c6ba952945d48c50c0bb64ec1ca8 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 1 Dec 2013 18:04:51 +0100 Subject: [PATCH] Bug 719634 - Palette editor not working for New Palettes (cannot drop colors) Allow to drop colors also on the palette view's parent viewport, so colors can be dropped everywhere inside the scrolled window, also when the palette view is invisible because it has zero colors. Also allow dropping of palettes on the viewport to change the editor's active palette. --- app/widgets/gimppaletteeditor.c | 35 ++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/app/widgets/gimppaletteeditor.c b/app/widgets/gimppaletteeditor.c index b74013e44c..0bf8087e9d 100644 --- a/app/widgets/gimppaletteeditor.c +++ b/app/widgets/gimppaletteeditor.c @@ -88,6 +88,11 @@ static void palette_editor_drop_palette (GtkWidget *widget, gint y, GimpViewable *viewable, gpointer data); +static void palette_editor_drop_color (GtkWidget *widget, + gint x, + gint y, + const GimpRGB *color, + gpointer data); static void palette_editor_entry_clicked (GimpPaletteView *view, GimpPaletteEntry *entry, @@ -213,9 +218,18 @@ gimp_palette_editor_init (GimpPaletteEditor *editor) G_CALLBACK (palette_editor_color_dropped), editor); - gimp_dnd_viewable_dest_add (editor->view, GIMP_TYPE_PALETTE, + gimp_dnd_viewable_dest_add (editor->view, + GIMP_TYPE_PALETTE, palette_editor_drop_palette, editor); + gimp_dnd_viewable_dest_add (gtk_widget_get_parent (editor->view), + GIMP_TYPE_PALETTE, + palette_editor_drop_palette, + editor); + + gimp_dnd_color_dest_add (gtk_widget_get_parent (editor->view), + palette_editor_drop_color, + editor); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0); @@ -643,6 +657,25 @@ palette_editor_drop_palette (GtkWidget *widget, gimp_data_editor_set_data (GIMP_DATA_EDITOR (data), GIMP_DATA (viewable)); } +static void +palette_editor_drop_color (GtkWidget *widget, + gint x, + gint y, + const GimpRGB *color, + gpointer data) +{ + GimpPaletteEditor *editor = data; + + if (GIMP_DATA_EDITOR (editor)->data_editable) + { + GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); + GimpPaletteEntry *entry; + + entry = gimp_palette_add_entry (palette, -1, NULL, color); + gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view), entry); + } +} + /* palette view callbacks */