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.
This commit is contained in:
Michael Natterer 2013-12-01 18:04:51 +01:00
parent 007faf2b32
commit 0e1978d273
1 changed files with 34 additions and 1 deletions

View File

@ -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 */