mirror of https://github.com/GNOME/gimp.git
Allow to drop stuff onto empty layers, channels and paths dialogs to
2005-01-17 Michael Natterer <mitch@gimp.org> Allow to drop stuff onto empty layers, channels and paths dialogs to create new items: * app/widgets/gimpcontainertreeview.h (struct GimpContainerTreeView): added "gboolean dnd_drop_to_empty". * app/widgets/gimpcontainertreeview-dnd.c: if "dnd_drop_to_empty" is TRUE, dispatch drops to empty views and to the empty area below all items. * app/widgets/gimpitemtreeview.c (gimp_item_tree_view_init): set "dnd_drop_to_empty" to TRUE. * app/widgets/gimpitemtreeview.c * app/widgets/gimpchanneltreeview.c * app/widgets/gimpdrawabletreeview.c * app/widgets/gimplayertreeview.c * app/widgets/gimpvectorstreeview.c: made all drop functions work with "dest_viewable" being NULL and changed drop_possible() implementations accordingly. Cleaned up the whole DND code a bit. * app/widgets/gimplayertreeview.c: removed color and pattern drop code... * app/widgets/gimpdrawabletreeview.c: and added it here so colors and patterns can be dropped to the channels dialog too.
This commit is contained in:
parent
1225e2a6c8
commit
0429d04908
29
ChangeLog
29
ChangeLog
|
@ -1,3 +1,32 @@
|
|||
2005-01-17 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Allow to drop stuff onto empty layers, channels and paths dialogs
|
||||
to create new items:
|
||||
|
||||
* app/widgets/gimpcontainertreeview.h (struct GimpContainerTreeView):
|
||||
added "gboolean dnd_drop_to_empty".
|
||||
|
||||
* app/widgets/gimpcontainertreeview-dnd.c: if "dnd_drop_to_empty"
|
||||
is TRUE, dispatch drops to empty views and to the empty area below
|
||||
all items.
|
||||
|
||||
* app/widgets/gimpitemtreeview.c (gimp_item_tree_view_init): set
|
||||
"dnd_drop_to_empty" to TRUE.
|
||||
|
||||
* app/widgets/gimpitemtreeview.c
|
||||
* app/widgets/gimpchanneltreeview.c
|
||||
* app/widgets/gimpdrawabletreeview.c
|
||||
* app/widgets/gimplayertreeview.c
|
||||
* app/widgets/gimpvectorstreeview.c: made all drop functions work
|
||||
with "dest_viewable" being NULL and changed drop_possible()
|
||||
implementations accordingly. Cleaned up the whole DND code a bit.
|
||||
|
||||
* app/widgets/gimplayertreeview.c: removed color and pattern
|
||||
drop code...
|
||||
|
||||
* app/widgets/gimpdrawabletreeview.c: and added it here so colors
|
||||
and patterns can be dropped to the channels dialog too.
|
||||
|
||||
2005-01-16 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tools/gimppaintoptions-gui.c (pressure_options_gui): added a
|
||||
|
|
|
@ -243,41 +243,40 @@ gimp_channel_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
|
|||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
GimpContainerView *container_view = GIMP_CONTAINER_VIEW (tree_view);
|
||||
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpItemTreeViewClass *item_view_class;
|
||||
GimpContainer *container;
|
||||
|
||||
container = gimp_container_view_get_container (container_view);
|
||||
|
||||
item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (item_view);
|
||||
|
||||
if (item_view->gimage != gimp_item_get_image (GIMP_ITEM (src_viewable)) ||
|
||||
G_TYPE_FROM_INSTANCE (src_viewable) != item_view_class->item_type)
|
||||
if (GIMP_IS_DRAWABLE (src_viewable) &&
|
||||
(item_view->gimage != gimp_item_get_image (GIMP_ITEM (src_viewable)) ||
|
||||
G_TYPE_FROM_INSTANCE (src_viewable) != item_view_class->item_type))
|
||||
{
|
||||
GimpItem *new_item;
|
||||
gint dest_index;
|
||||
gint index = -1;
|
||||
|
||||
dest_index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (dest_viewable));
|
||||
if (dest_viewable)
|
||||
{
|
||||
index = gimp_image_get_channel_index (item_view->gimage,
|
||||
GIMP_CHANNEL (dest_viewable));
|
||||
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
dest_index++;
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
}
|
||||
|
||||
new_item = gimp_item_convert (GIMP_ITEM (src_viewable),
|
||||
item_view->gimage,
|
||||
item_view_class->item_type, FALSE);
|
||||
|
||||
item_view_class->add_item (item_view->gimage, new_item, dest_index);
|
||||
item_view_class->add_item (item_view->gimage, new_item, index);
|
||||
gimp_image_flush (item_view->gimage);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (tree_view,
|
||||
src_viewable,
|
||||
dest_viewable,
|
||||
drop_pos);
|
||||
}
|
||||
|
||||
GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (tree_view,
|
||||
src_viewable,
|
||||
dest_viewable,
|
||||
drop_pos);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -287,39 +286,40 @@ gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view,
|
|||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpImage *dest_image = view->gimage;
|
||||
GimpChannel *new_channel;
|
||||
gint index;
|
||||
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpItem *new_item;
|
||||
gint index = -1;
|
||||
const gchar *desc;
|
||||
gchar *name;
|
||||
|
||||
index = gimp_image_get_channel_index (dest_image,
|
||||
GIMP_CHANNEL (dest_viewable));
|
||||
if (dest_viewable)
|
||||
{
|
||||
index = gimp_image_get_channel_index (item_view->gimage,
|
||||
GIMP_CHANNEL (dest_viewable));
|
||||
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
}
|
||||
|
||||
gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,
|
||||
NULL, NULL, &desc, NULL);
|
||||
name = g_strdup_printf (_("%s Channel Copy"), desc);
|
||||
|
||||
new_channel = gimp_channel_new_from_component (src_image, component,
|
||||
name, NULL);
|
||||
new_item = GIMP_ITEM (gimp_channel_new_from_component (src_image, component,
|
||||
name, NULL));
|
||||
|
||||
/* copied components are invisible by default so subsequent copies
|
||||
* of components don't affect each other
|
||||
*/
|
||||
gimp_item_set_visible (GIMP_ITEM (new_channel), FALSE, FALSE);
|
||||
gimp_item_set_visible (new_item, FALSE, FALSE);
|
||||
|
||||
g_free (name);
|
||||
|
||||
if (src_image != dest_image)
|
||||
GIMP_ITEM_GET_CLASS (new_channel)->convert (GIMP_ITEM (new_channel),
|
||||
dest_image);
|
||||
if (src_image != item_view->gimage)
|
||||
GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, item_view->gimage);
|
||||
|
||||
gimp_image_add_channel (dest_image, new_channel, index);
|
||||
gimp_image_flush (dest_image);
|
||||
gimp_image_add_channel (item_view->gimage, GIMP_CHANNEL (new_item), index);
|
||||
gimp_image_flush (item_view->gimage);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,11 +49,14 @@ gimp_container_tree_view_drop_status (GimpContainerTreeView *tree_view,
|
|||
GimpViewable **return_dest,
|
||||
GtkTreeViewDropPosition *return_pos)
|
||||
{
|
||||
GimpViewable *src_viewable = NULL;
|
||||
GtkTreePath *path;
|
||||
GtkTargetList *target_list;
|
||||
GdkAtom target_atom;
|
||||
GimpDndType src_type;
|
||||
GimpViewable *src_viewable = NULL;
|
||||
GimpViewable *dest_viewable = NULL;
|
||||
GtkTreePath *path = NULL;
|
||||
GtkTargetList *target_list;
|
||||
GdkAtom target_atom;
|
||||
GimpDndType src_type;
|
||||
GtkTreeViewDropPosition drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
|
||||
GdkDragAction drag_action = 0;
|
||||
|
||||
if (! gimp_container_view_get_reorderable (GIMP_CONTAINER_VIEW (tree_view)))
|
||||
goto drop_impossible;
|
||||
|
@ -77,9 +80,7 @@ gimp_container_tree_view_drop_status (GimpContainerTreeView *tree_view,
|
|||
|
||||
default:
|
||||
{
|
||||
GtkWidget *src_widget;
|
||||
|
||||
src_widget = gtk_drag_get_source_widget (context);
|
||||
GtkWidget *src_widget = gtk_drag_get_source_widget (context);
|
||||
|
||||
if (! src_widget)
|
||||
goto drop_impossible;
|
||||
|
@ -95,12 +96,9 @@ gimp_container_tree_view_drop_status (GimpContainerTreeView *tree_view,
|
|||
if (gtk_tree_view_get_path_at_pos (tree_view->view, x, y,
|
||||
&path, NULL, NULL, NULL))
|
||||
{
|
||||
GimpViewRenderer *renderer;
|
||||
GimpViewable *dest_viewable;
|
||||
GtkTreeIter iter;
|
||||
GdkRectangle cell_area;
|
||||
GtkTreeViewDropPosition drop_pos;
|
||||
GdkDragAction drag_action;
|
||||
GimpViewRenderer *renderer;
|
||||
GtkTreeIter iter;
|
||||
GdkRectangle cell_area;
|
||||
|
||||
gtk_tree_model_get_iter (tree_view->model, &iter, path);
|
||||
|
||||
|
@ -122,7 +120,10 @@ gimp_container_tree_view_drop_status (GimpContainerTreeView *tree_view,
|
|||
{
|
||||
drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
|
||||
}
|
||||
}
|
||||
|
||||
if (dest_viewable || tree_view->dnd_drop_to_empty)
|
||||
{
|
||||
if (GIMP_CONTAINER_TREE_VIEW_GET_CLASS (tree_view)->drop_possible (tree_view,
|
||||
src_type,
|
||||
src_viewable,
|
||||
|
@ -456,10 +457,19 @@ gimp_container_tree_view_real_drop_possible (GimpContainerTreeView *tree_view,
|
|||
if (src_viewable == dest_viewable)
|
||||
return FALSE;
|
||||
|
||||
src_index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (src_viewable));
|
||||
dest_index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (dest_viewable));
|
||||
src_index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (src_viewable));
|
||||
|
||||
if (src_index == -1)
|
||||
return FALSE;
|
||||
|
||||
if (dest_viewable)
|
||||
{
|
||||
dest_index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (dest_viewable));
|
||||
if (dest_index == -1)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (src_index == -1 || dest_index == -1)
|
||||
return FALSE;
|
||||
|
|
|
@ -61,6 +61,7 @@ struct _GimpContainerTreeView
|
|||
|
||||
GQuark invalidate_preview_handler_id;
|
||||
|
||||
gboolean dnd_drop_to_empty;
|
||||
Gimp *dnd_gimp; /* eek */
|
||||
GimpViewable *dnd_viewable;
|
||||
|
||||
|
|
|
@ -55,6 +55,22 @@ static gboolean gimp_drawable_tree_view_select_item (GimpContainerView *view,
|
|||
GimpViewable *item,
|
||||
gpointer insert_data);
|
||||
|
||||
static gboolean gimp_drawable_tree_view_drop_possible(GimpContainerTreeView *view,
|
||||
GimpDndType src_type,
|
||||
GimpViewable *src_viewable,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos,
|
||||
GtkTreeViewDropPosition *return_drop_pos,
|
||||
GdkDragAction *return_drag_action);
|
||||
static void gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view,
|
||||
GimpViewable *src_viewable,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos);
|
||||
static void gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
|
||||
const GimpRGB *color,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos);
|
||||
|
||||
static void gimp_drawable_tree_view_set_image (GimpItemTreeView *view,
|
||||
GimpImage *gimage);
|
||||
|
||||
|
@ -121,14 +137,23 @@ gimp_drawable_tree_view_get_type (void)
|
|||
static void
|
||||
gimp_drawable_tree_view_class_init (GimpDrawableTreeViewClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpItemTreeViewClass *item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
|
||||
GObjectClass *object_class;
|
||||
GimpContainerTreeViewClass *tree_view_class;
|
||||
GimpItemTreeViewClass *item_view_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tree_view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
|
||||
item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->constructor = gimp_drawable_tree_view_constructor;
|
||||
object_class->constructor = gimp_drawable_tree_view_constructor;
|
||||
|
||||
item_view_class->set_image = gimp_drawable_tree_view_set_image;
|
||||
tree_view_class->drop_possible = gimp_drawable_tree_view_drop_possible;
|
||||
tree_view_class->drop_viewable = gimp_drawable_tree_view_drop_viewable;
|
||||
tree_view_class->drop_color = gimp_drawable_tree_view_drop_color;
|
||||
|
||||
item_view_class->set_image = gimp_drawable_tree_view_set_image;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -141,11 +166,13 @@ gimp_drawable_tree_view_constructor (GType type,
|
|||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GimpItemTreeView *item_view;
|
||||
GObject *object;
|
||||
GimpContainerTreeView *tree_view;
|
||||
GimpItemTreeView *item_view;
|
||||
GObject *object;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
|
||||
item_view = GIMP_ITEM_TREE_VIEW (object);
|
||||
|
||||
gimp_dnd_viewable_dest_add (item_view->new_button, GIMP_TYPE_PATTERN,
|
||||
|
@ -155,6 +182,11 @@ gimp_drawable_tree_view_constructor (GType type,
|
|||
gimp_drawable_tree_view_new_color_dropped,
|
||||
item_view);
|
||||
|
||||
gimp_dnd_color_dest_add (GTK_WIDGET (tree_view->view),
|
||||
NULL, tree_view);
|
||||
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_PATTERN,
|
||||
NULL, tree_view);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -194,6 +226,91 @@ gimp_drawable_tree_view_select_item (GimpContainerView *view,
|
|||
}
|
||||
|
||||
|
||||
/* GimpContainerTreeView methods */
|
||||
|
||||
static gboolean
|
||||
gimp_drawable_tree_view_drop_possible (GimpContainerTreeView *tree_view,
|
||||
GimpDndType src_type,
|
||||
GimpViewable *src_viewable,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos,
|
||||
GtkTreeViewDropPosition *return_drop_pos,
|
||||
GdkDragAction *return_drag_action)
|
||||
{
|
||||
if (GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_possible (tree_view,
|
||||
src_type,
|
||||
src_viewable,
|
||||
dest_viewable,
|
||||
drop_pos,
|
||||
return_drop_pos,
|
||||
return_drag_action))
|
||||
{
|
||||
if (src_type == GIMP_DND_TYPE_COLOR ||
|
||||
src_type == GIMP_DND_TYPE_PATTERN)
|
||||
{
|
||||
if (! dest_viewable)
|
||||
return FALSE;
|
||||
|
||||
if (return_drop_pos)
|
||||
{
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE)
|
||||
*return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
|
||||
else
|
||||
*return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view,
|
||||
GimpViewable *src_viewable,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
if (dest_viewable && GIMP_IS_PATTERN (src_viewable))
|
||||
{
|
||||
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
|
||||
GIMP_PATTERN_BUCKET_FILL,
|
||||
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
|
||||
FALSE, /* no seed fill */
|
||||
FALSE, 0.0, FALSE, /* fill params */
|
||||
0.0, 0.0, /* ignored */
|
||||
NULL, GIMP_PATTERN (src_viewable));
|
||||
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->gimage);
|
||||
return;
|
||||
}
|
||||
|
||||
GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (view,
|
||||
src_viewable,
|
||||
dest_viewable,
|
||||
drop_pos);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
|
||||
const GimpRGB *color,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
if (dest_viewable)
|
||||
{
|
||||
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
|
||||
GIMP_FG_BUCKET_FILL,
|
||||
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
|
||||
FALSE, /* no seed fill */
|
||||
FALSE, 0.0, FALSE, /* fill params */
|
||||
0.0, 0.0, /* ignored */
|
||||
color, NULL);
|
||||
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->gimage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* GimpItemTreeView methods */
|
||||
|
||||
static void
|
||||
|
|
|
@ -280,6 +280,8 @@ gimp_item_tree_view_init (GimpItemTreeView *view,
|
|||
tree_view->model_columns[tree_view->n_model_columns] = G_TYPE_BOOLEAN;
|
||||
tree_view->n_model_columns++;
|
||||
|
||||
tree_view->dnd_drop_to_empty = TRUE;
|
||||
|
||||
view->context = NULL;
|
||||
view->gimage = NULL;
|
||||
|
||||
|
@ -714,8 +716,9 @@ gimp_item_tree_view_drop_possible (GimpContainerTreeView *tree_view,
|
|||
GdkDragAction *return_drag_action)
|
||||
{
|
||||
if (GIMP_IS_ITEM (src_viewable) &&
|
||||
gimp_item_get_image (GIMP_ITEM (src_viewable)) !=
|
||||
gimp_item_get_image (GIMP_ITEM (dest_viewable)))
|
||||
(dest_viewable == NULL ||
|
||||
gimp_item_get_image (GIMP_ITEM (src_viewable)) !=
|
||||
gimp_item_get_image (GIMP_ITEM (dest_viewable))))
|
||||
{
|
||||
if (return_drop_pos)
|
||||
*return_drop_pos = drop_pos;
|
||||
|
@ -745,12 +748,13 @@ gimp_item_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
|
|||
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpItemTreeViewClass *item_view_class;
|
||||
GimpContainer *container;
|
||||
gint dest_index;
|
||||
gint dest_index = -1;
|
||||
|
||||
container = gimp_container_view_get_container (container_view);
|
||||
|
||||
dest_index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (dest_viewable));
|
||||
if (dest_viewable)
|
||||
dest_index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (dest_viewable));
|
||||
|
||||
item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (item_view);
|
||||
|
||||
|
@ -764,7 +768,7 @@ gimp_item_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
|
|||
if (g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable), item_type))
|
||||
item_type = G_TYPE_FROM_INSTANCE (src_viewable);
|
||||
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
if (dest_viewable && drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
dest_index++;
|
||||
|
||||
new_item = gimp_item_convert (GIMP_ITEM (src_viewable),
|
||||
|
@ -772,7 +776,7 @@ gimp_item_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
|
|||
|
||||
item_view_class->add_item (item_view->gimage, new_item, dest_index);
|
||||
}
|
||||
else
|
||||
else if (dest_viewable)
|
||||
{
|
||||
gint src_index;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpdrawable-bucket-fill.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplayermask.h"
|
||||
#include "core/gimplayer-floating-sel.h"
|
||||
|
@ -40,7 +39,6 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-undo.h"
|
||||
#include "core/gimpitemundo.h"
|
||||
#include "core/gimppattern.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
||||
|
@ -91,10 +89,6 @@ static gboolean gimp_layer_tree_view_drop_possible(GimpContainerTreeView *view,
|
|||
GtkTreeViewDropPosition drop_pos,
|
||||
GtkTreeViewDropPosition *return_drop_pos,
|
||||
GdkDragAction *return_drag_action);
|
||||
static void gimp_layer_tree_view_drop_viewable (GimpContainerTreeView *view,
|
||||
GimpViewable *src_viewable,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos);
|
||||
static void gimp_layer_tree_view_drop_color (GimpContainerTreeView *view,
|
||||
const GimpRGB *color,
|
||||
GimpViewable *dest_viewable,
|
||||
|
@ -227,7 +221,6 @@ gimp_layer_tree_view_class_init (GimpLayerTreeViewClass *klass)
|
|||
widget_class->style_set = gimp_layer_tree_view_style_set;
|
||||
|
||||
tree_view_class->drop_possible = gimp_layer_tree_view_drop_possible;
|
||||
tree_view_class->drop_viewable = gimp_layer_tree_view_drop_viewable;
|
||||
tree_view_class->drop_color = gimp_layer_tree_view_drop_color;
|
||||
tree_view_class->drop_uri_list = gimp_layer_tree_view_drop_uri_list;
|
||||
tree_view_class->drop_component = gimp_layer_tree_view_drop_component;
|
||||
|
@ -414,12 +407,8 @@ gimp_layer_tree_view_constructor (GType type,
|
|||
|
||||
gimp_dnd_uri_list_dest_add (GTK_WIDGET (tree_view->view),
|
||||
NULL, tree_view);
|
||||
gimp_dnd_color_dest_add (GTK_WIDGET (tree_view->view),
|
||||
NULL, tree_view);
|
||||
gimp_dnd_component_dest_add (GTK_WIDGET (tree_view->view),
|
||||
NULL, tree_view);
|
||||
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_PATTERN,
|
||||
NULL, tree_view);
|
||||
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_CHANNEL,
|
||||
NULL, tree_view);
|
||||
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_LAYER_MASK,
|
||||
|
@ -671,73 +660,36 @@ gimp_layer_tree_view_drop_possible (GimpContainerTreeView *tree_view,
|
|||
GIMP_IS_DRAWABLE (src_viewable))
|
||||
{
|
||||
GimpLayer *dest_layer = GIMP_LAYER (dest_viewable);
|
||||
GimpImage *dest_image = gimp_item_get_image (GIMP_ITEM (dest_layer));
|
||||
GimpImage *dest_image = GIMP_ITEM_TREE_VIEW (tree_view)->gimage;
|
||||
|
||||
if (gimp_image_floating_sel (dest_image))
|
||||
return FALSE;
|
||||
|
||||
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (dest_layer)) &&
|
||||
drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
return FALSE;
|
||||
|
||||
if (GIMP_IS_LAYER (src_viewable))
|
||||
if (dest_layer)
|
||||
{
|
||||
GimpLayer *src_layer = GIMP_LAYER (src_viewable);
|
||||
GimpImage *src_image = gimp_item_get_image (GIMP_ITEM (src_layer));
|
||||
|
||||
if (src_image == dest_image &&
|
||||
! gimp_drawable_has_alpha (GIMP_DRAWABLE (src_layer)))
|
||||
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (dest_layer)) &&
|
||||
drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
return FALSE;
|
||||
|
||||
if (GIMP_IS_LAYER (src_viewable))
|
||||
{
|
||||
GimpLayer *src_layer = GIMP_LAYER (src_viewable);
|
||||
GimpImage *src_image = gimp_item_get_image (GIMP_ITEM (src_layer));
|
||||
|
||||
if (src_image == dest_image &&
|
||||
! gimp_drawable_has_alpha (GIMP_DRAWABLE (src_layer)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_possible (tree_view,
|
||||
src_type,
|
||||
src_viewable,
|
||||
dest_viewable,
|
||||
drop_pos,
|
||||
return_drop_pos,
|
||||
return_drag_action))
|
||||
{
|
||||
if (return_drop_pos &&
|
||||
(src_type == GIMP_DND_TYPE_COLOR ||
|
||||
src_type == GIMP_DND_TYPE_PATTERN))
|
||||
{
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE)
|
||||
*return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
|
||||
else
|
||||
*return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_tree_view_drop_viewable (GimpContainerTreeView *view,
|
||||
GimpViewable *src_viewable,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
if (GIMP_IS_PATTERN (src_viewable))
|
||||
{
|
||||
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
|
||||
GIMP_PATTERN_BUCKET_FILL,
|
||||
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
|
||||
FALSE, /* no seed fill */
|
||||
FALSE, 0.0, FALSE, /* fill params */
|
||||
0.0, 0.0, /* ignored */
|
||||
NULL, GIMP_PATTERN (src_viewable));
|
||||
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->gimage);
|
||||
return;
|
||||
}
|
||||
|
||||
GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (view,
|
||||
src_viewable,
|
||||
dest_viewable,
|
||||
drop_pos);
|
||||
return GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_possible (tree_view,
|
||||
src_type,
|
||||
src_viewable,
|
||||
dest_viewable,
|
||||
drop_pos,
|
||||
return_drop_pos,
|
||||
return_drag_action);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -751,19 +703,13 @@ gimp_layer_tree_view_drop_color (GimpContainerTreeView *view,
|
|||
gimp_text_layer_set (GIMP_TEXT_LAYER (dest_viewable), NULL,
|
||||
"color", color,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
|
||||
GIMP_FG_BUCKET_FILL,
|
||||
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
|
||||
FALSE, /* no seed fill */
|
||||
FALSE, 0.0, FALSE, /* fill params */
|
||||
0.0, 0.0, /* ignored */
|
||||
color, NULL);
|
||||
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->gimage);
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->gimage);
|
||||
GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_color (view, color,
|
||||
dest_viewable,
|
||||
drop_pos);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -774,13 +720,16 @@ gimp_layer_tree_view_drop_uri_list (GimpContainerTreeView *view,
|
|||
{
|
||||
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
|
||||
GimpImage *gimage = item_view->gimage;
|
||||
gint index = -1;
|
||||
GList *list;
|
||||
gint index;
|
||||
|
||||
index = gimp_image_get_layer_index (gimage, GIMP_LAYER (dest_viewable));
|
||||
if (dest_viewable)
|
||||
{
|
||||
index = gimp_image_get_layer_index (gimage, GIMP_LAYER (dest_viewable));
|
||||
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
}
|
||||
|
||||
for (list = uri_list; list; list = g_list_next (list))
|
||||
{
|
||||
|
@ -832,34 +781,37 @@ gimp_layer_tree_view_drop_component (GimpContainerTreeView *tree_view,
|
|||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpImage *dest_image = view->gimage;
|
||||
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpChannel *channel;
|
||||
GimpLayer *layer;
|
||||
gint index;
|
||||
GimpItem *new_item;
|
||||
gint index = -1;
|
||||
const gchar *desc;
|
||||
gchar *name;
|
||||
|
||||
index = gimp_image_get_layer_index (dest_image, GIMP_LAYER (dest_viewable));
|
||||
if (dest_viewable)
|
||||
{
|
||||
index = gimp_image_get_layer_index (item_view->gimage,
|
||||
GIMP_LAYER (dest_viewable));
|
||||
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
}
|
||||
|
||||
channel = gimp_channel_new_from_component (src_image, component, NULL, NULL);
|
||||
|
||||
layer = GIMP_LAYER (gimp_item_convert (GIMP_ITEM (channel), dest_image,
|
||||
GIMP_TYPE_LAYER, TRUE));
|
||||
new_item = gimp_item_convert (GIMP_ITEM (channel), item_view->gimage,
|
||||
GIMP_TYPE_LAYER, TRUE);
|
||||
|
||||
g_object_unref (channel);
|
||||
|
||||
gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,
|
||||
NULL, NULL, &desc, NULL);
|
||||
name = g_strdup_printf (_("%s Channel Copy"), desc);
|
||||
gimp_object_set_name (GIMP_OBJECT (layer), name);
|
||||
gimp_object_set_name (GIMP_OBJECT (new_item), name);
|
||||
g_free (name);
|
||||
|
||||
gimp_image_add_layer (dest_image, layer, index);
|
||||
gimp_image_flush (dest_image);
|
||||
gimp_image_add_layer (item_view->gimage, GIMP_LAYER (new_item), index);
|
||||
gimp_image_flush (item_view->gimage);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -256,20 +256,24 @@ gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view,
|
|||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpImage *gimage = view->gimage;
|
||||
GError *error = NULL;
|
||||
gint index;
|
||||
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (tree_view);
|
||||
GimpImage *image = view->gimage;
|
||||
gint index = -1;
|
||||
GError *error = NULL;
|
||||
|
||||
if (gimage->gimp->be_verbose)
|
||||
if (image->gimp->be_verbose)
|
||||
g_print ("%s: SVG dropped (len = %d)\n", G_STRFUNC, (gint) svg_data_len);
|
||||
|
||||
index = gimp_image_get_vectors_index (gimage, GIMP_VECTORS (dest_viewable));
|
||||
if (dest_viewable)
|
||||
{
|
||||
index = gimp_image_get_vectors_index (image,
|
||||
GIMP_VECTORS (dest_viewable));
|
||||
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
||||
index++;
|
||||
}
|
||||
|
||||
if (! gimp_vectors_import_buffer (gimage, svg_data, svg_data_len,
|
||||
if (! gimp_vectors_import_buffer (image, svg_data, svg_data_len,
|
||||
TRUE, TRUE, index, &error))
|
||||
{
|
||||
g_message (error->message);
|
||||
|
@ -277,7 +281,7 @@ gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view,
|
|||
}
|
||||
else
|
||||
{
|
||||
gimp_image_flush (gimage);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue