Commit 0b401af4 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/widgets/gimpcellrenderertoggle.[ch] added public functions to emit the

2003-03-19  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpcellrenderertoggle.[ch]
	* app/widgets/gimpcellrendererviewable.[ch]: added public
	functions to emit the "clicked" signal.

	* app/widgets/gimpcontainertreeview.c: use them instead of
	g_signal_emit_by_name().

	* app/widgets/Makefile.am
	* app/widgets/gimpcontainertreeview-dnd.[ch]: new files
	implementing DND for tree views.

	* app/widgets/gimpcontainertreeview.[ch]: added virtual
	functions drop_possible() and drop().

	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimplayertreeview.c: implement drop_possible()
	and drop().
parent 7bb3536f
2003-03-19 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcellrenderertoggle.[ch]
* app/widgets/gimpcellrendererviewable.[ch]: added public
functions to emit the "clicked" signal.
* app/widgets/gimpcontainertreeview.c: use them instead of
g_signal_emit_by_name().
* app/widgets/Makefile.am
* app/widgets/gimpcontainertreeview-dnd.[ch]: new files
implementing DND for tree views.
* app/widgets/gimpcontainertreeview.[ch]: added virtual
functions drop_possible() and drop().
* app/widgets/gimpitemtreeview.c
* app/widgets/gimplayertreeview.c: implement drop_possible()
and drop().
2003-03-19 Michael Natterer <mitch@gimp.org> 2003-03-19 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdatafactoryview.c: enable in-place name * app/widgets/gimpdatafactoryview.c: enable in-place name
...@@ -55,6 +55,8 @@ libappwidgets_a_sources = \ ...@@ -55,6 +55,8 @@ libappwidgets_a_sources = \
gimpcontainermenuimpl.h \ gimpcontainermenuimpl.h \
gimpcontainertreeview.c \ gimpcontainertreeview.c \
gimpcontainertreeview.h \ gimpcontainertreeview.h \
gimpcontainertreeview-dnd.c \
gimpcontainertreeview-dnd.h \
gimpcontainerview.c \ gimpcontainerview.c \
gimpcontainerview.h \ gimpcontainerview.h \
gimpcontainerview-utils.c \ gimpcontainerview-utils.c \
......
...@@ -145,6 +145,7 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass) ...@@ -145,6 +145,7 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
cell_class->get_size = gimp_cell_renderer_toggle_get_size; cell_class->get_size = gimp_cell_renderer_toggle_get_size;
cell_class->render = gimp_cell_renderer_toggle_render; cell_class->render = gimp_cell_renderer_toggle_render;
cell_class->activate = gimp_cell_renderer_toggle_activate;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_STOCK_ID, PROP_STOCK_ID,
...@@ -451,3 +452,14 @@ gimp_cell_renderer_toggle_new (const gchar *stock_id) ...@@ -451,3 +452,14 @@ gimp_cell_renderer_toggle_new (const gchar *stock_id)
"stock_id", stock_id, "stock_id", stock_id,
NULL); NULL);
} }
void
gimp_cell_renderer_toggle_clicked (GimpCellRendererToggle *cell,
const gchar *path,
GdkModifierType state)
{
g_return_if_fail (GIMP_IS_CELL_RENDERER_TOGGLE (cell));
g_return_if_fail (path != NULL);
g_signal_emit (cell, toggle_cell_signals[CLICKED], 0, path, state);
}
...@@ -49,9 +49,9 @@ struct _GimpCellRendererToggleClass ...@@ -49,9 +49,9 @@ struct _GimpCellRendererToggleClass
{ {
GtkCellRendererToggleClass parent_class; GtkCellRendererToggleClass parent_class;
void (* clicked) (GimpCellRendererViewable *cell, void (* clicked) (GimpCellRendererToggle *cell,
const gchar *path, const gchar *path,
GdkModifierType state); GdkModifierType state);
}; };
...@@ -59,5 +59,9 @@ GType gimp_cell_renderer_toggle_get_type (void) G_GNUC_CONST; ...@@ -59,5 +59,9 @@ GType gimp_cell_renderer_toggle_get_type (void) G_GNUC_CONST;
GtkCellRenderer * gimp_cell_renderer_toggle_new (const gchar *stock_id); GtkCellRenderer * gimp_cell_renderer_toggle_new (const gchar *stock_id);
void gimp_cell_renderer_toggle_clicked (GimpCellRendererToggle *cell,
const gchar *path,
GdkModifierType state);
#endif /* __GIMP_CELL_RENDERER_TOGGLE_H__ */ #endif /* __GIMP_CELL_RENDERER_TOGGLE_H__ */
...@@ -341,3 +341,14 @@ gimp_cell_renderer_viewable_new (void) ...@@ -341,3 +341,14 @@ gimp_cell_renderer_viewable_new (void)
{ {
return g_object_new (GIMP_TYPE_CELL_RENDERER_VIEWABLE, NULL); return g_object_new (GIMP_TYPE_CELL_RENDERER_VIEWABLE, NULL);
} }
void
gimp_cell_renderer_viewable_clicked (GimpCellRendererViewable *cell,
const gchar *path,
GdkModifierType state)
{
g_return_if_fail (GIMP_IS_CELL_RENDERER_VIEWABLE (cell));
g_return_if_fail (path != NULL);
g_signal_emit (cell, viewable_cell_signals[CLICKED], 0, path, state);
}
...@@ -57,5 +57,8 @@ GType gimp_cell_renderer_viewable_get_type (void) G_GNUC_CONST; ...@@ -57,5 +57,8 @@ GType gimp_cell_renderer_viewable_get_type (void) G_GNUC_CONST;
GtkCellRenderer * gimp_cell_renderer_viewable_new (void); GtkCellRenderer * gimp_cell_renderer_viewable_new (void);
void gimp_cell_renderer_viewable_clicked (GimpCellRendererViewable *cell,
const gchar *path,
GdkModifierType state);
#endif /* __GIMP_CELL_RENDERER_VIEWABLE_H__ */ #endif /* __GIMP_CELL_RENDERER_VIEWABLE_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontainertreeview-dnd.c
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "widgets-types.h"
#include "core/gimpcontainer.h"
#include "core/gimpviewable.h"
#include "gimpcontainertreeview.h"
#include "gimpcontainertreeview-dnd.h"
#include "gimpdnd.h"
#include "gimppreviewrenderer.h"
static gboolean
gimp_container_tree_view_drop_status (GimpContainerTreeView *tree_view,
GdkDragContext *context,
gint x,
gint y,
guint time,
GtkTreePath **return_path,
GimpViewable **return_src,
GimpViewable **return_dest,
GtkTreeViewDropPosition *return_pos)
{
GtkWidget *src_widget;
GimpViewable *src_viewable;
GtkTreePath *path;
if (! GIMP_CONTAINER_VIEW (tree_view)->reorderable)
return FALSE;
src_widget = gtk_drag_get_source_widget (context);
if (! src_widget)
return FALSE;
src_viewable = gimp_dnd_get_drag_data (src_widget);
if (! GIMP_IS_VIEWABLE (src_viewable))
return FALSE;
if (gtk_tree_view_get_path_at_pos (tree_view->view, x, y,
&path, NULL, NULL, NULL))
{
GimpPreviewRenderer *renderer;
GimpViewable *dest_viewable;
GtkTreeIter iter;
GdkRectangle cell_area;
GtkTreeViewDropPosition drop_pos;
GdkDragAction drag_action;
gtk_tree_model_get_iter (tree_view->model, &iter, path);
gtk_tree_model_get (tree_view->model, &iter,
tree_view->model_column_renderer, &renderer,
-1);
dest_viewable = renderer->viewable;
gtk_tree_view_get_cell_area (tree_view->view, path, NULL, &cell_area);
if (y >= (cell_area.y + cell_area.height / 2))
drop_pos = GTK_TREE_VIEW_DROP_AFTER;
else
drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
g_object_unref (renderer);
if (GIMP_CONTAINER_TREE_VIEW_GET_CLASS (tree_view)->drop_possible (tree_view,
src_viewable,
dest_viewable,
drop_pos,
&drag_action))
{
gdk_drag_status (context, drag_action, time);
if (return_path)
*return_path = path;
else
gtk_tree_path_free (path);
if (return_src)
*return_src = src_viewable;
if (return_dest)
*return_dest = dest_viewable;
if (return_pos)
*return_pos = drop_pos;
return TRUE;
}
gdk_drag_status (context, GDK_ACTION_DEFAULT, time);
gtk_tree_path_free (path);
}
return FALSE;
}
void
gimp_container_tree_view_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time,
GimpContainerTreeView *tree_view)
{
gtk_tree_view_unset_rows_drag_dest (tree_view->view);
}
gboolean
gimp_container_tree_view_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpContainerTreeView *tree_view)
{
GtkTreePath *path;
GtkTreeViewDropPosition drop_pos;
if (gimp_container_tree_view_drop_status (tree_view,
context, x, y, time,
&path, NULL, NULL, &drop_pos))
{
gtk_tree_view_set_drag_dest_row (tree_view->view, path, drop_pos);
gtk_tree_path_free (path);
return TRUE;
}
gtk_tree_view_unset_rows_drag_dest (tree_view->view);
return FALSE;
}
gboolean
gimp_container_tree_view_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpContainerTreeView *tree_view)
{
GimpViewable *src_viewable;
GimpViewable *dest_viewable;
GtkTreeViewDropPosition drop_pos;
if (gimp_container_tree_view_drop_status (tree_view,
context, x, y, time,
NULL, &src_viewable, &dest_viewable,
&drop_pos))
{
GIMP_CONTAINER_TREE_VIEW_GET_CLASS (tree_view)->drop (tree_view,
src_viewable,
dest_viewable,
drop_pos);
return TRUE;
}
return TRUE;
}
gboolean
gimp_container_tree_view_real_drop_possible (GimpContainerTreeView *tree_view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos,
GdkDragAction *drag_action)
{
GimpContainerView *container_view;
GimpObject *src_object;
GimpObject *dest_object;
gint src_index;
gint dest_index;
container_view = GIMP_CONTAINER_VIEW (tree_view);
if (src_viewable == dest_viewable)
return FALSE;
src_object = GIMP_OBJECT (src_viewable);
dest_object = GIMP_OBJECT (dest_viewable);
src_index = gimp_container_get_child_index (container_view->container,
src_object);
dest_index = gimp_container_get_child_index (container_view->container,
dest_object);
if (src_index == -1 || dest_index == -1)
return FALSE;
if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE)
{
if (dest_index == (src_index + 1))
return FALSE;
}
else
{
if (dest_index == (src_index - 1))
return FALSE;
}
if (drag_action)
*drag_action = GDK_ACTION_MOVE;
return TRUE;
}
void
gimp_container_tree_view_real_drop (GimpContainerTreeView *tree_view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos)
{
GimpContainerView *container_view;
GimpObject *src_object;
GimpObject *dest_object;
gint src_index;
gint dest_index;
container_view = GIMP_CONTAINER_VIEW (tree_view);
src_object = GIMP_OBJECT (src_viewable);
dest_object = GIMP_OBJECT (dest_viewable);
src_index = gimp_container_get_child_index (container_view->container,
src_object);
dest_index = gimp_container_get_child_index (container_view->container,
dest_object);
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER && src_index > dest_index)
{
dest_index++;
}
else if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE && src_index < dest_index)
{
dest_index--;
}
gimp_container_reorder (container_view->container, src_object, dest_index);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontainertreeview-dnd.h
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONTAINER_TREE_VIEW_DND_H__
#define __GIMP_CONTAINER_TREE_VIEW_DND_H__
void gimp_container_tree_view_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time,
GimpContainerTreeView *view);
gboolean gimp_container_tree_view_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpContainerTreeView *view);
gboolean gimp_container_tree_view_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpContainerTreeView *view);
gboolean
gimp_container_tree_view_real_drop_possible (GimpContainerTreeView *tree_view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos,
GdkDragAction *drag_action);
void
gimp_container_tree_view_real_drop (GimpContainerTreeView *tree_view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos);
#endif /* __GIMP_CONTAINER_TREE_VIEW_DND_H__ */
...@@ -31,8 +31,10 @@ ...@@ -31,8 +31,10 @@
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpviewable.h" #include "core/gimpviewable.h"
#include "gimpcellrenderertoggle.h"
#include "gimpcellrendererviewable.h" #include "gimpcellrendererviewable.h"
#include "gimpcontainertreeview.h" #include "gimpcontainertreeview.h"
#include "gimpcontainertreeview-dnd.h"
#include "gimpdnd.h" #include "gimpdnd.h"
#include "gimppreview.h" #include "gimppreview.h"
#include "gimppreviewrenderer.h" #include "gimppreviewrenderer.h"
...@@ -139,6 +141,9 @@ gimp_container_tree_view_class_init (GimpContainerTreeViewClass *klass) ...@@ -139,6 +141,9 @@ gimp_container_tree_view_class_init (GimpContainerTreeViewClass *klass)
container_view_class->set_preview_size = gimp_container_tree_view_set_preview_size; container_view_class->set_preview_size = gimp_container_tree_view_set_preview_size;
container_view_class->insert_data_free = (GDestroyNotify) g_free; container_view_class->insert_data_free = (GDestroyNotify) g_free;
klass->drop_possible = gimp_container_tree_view_real_drop_possible;
klass->drop = gimp_container_tree_view_real_drop;
} }
static void static void
...@@ -229,6 +234,16 @@ gimp_container_tree_view_constructor (GType type, ...@@ -229,6 +234,16 @@ gimp_container_tree_view_constructor (GType type,
G_CALLBACK (gimp_container_tree_view_selection_changed), G_CALLBACK (gimp_container_tree_view_selection_changed),
tree_view); tree_view);
g_signal_connect (tree_view->view, "drag_leave",
G_CALLBACK (gimp_container_tree_view_drag_leave),
tree_view);
g_signal_connect (tree_view->view, "drag_motion",
G_CALLBACK (gimp_container_tree_view_drag_motion),
tree_view);
g_signal_connect (tree_view->view, "drag_drop",
G_CALLBACK (gimp_container_tree_view_drag_drop),
tree_view);
return object; return object;
} }
...@@ -697,13 +712,13 @@ gimp_container_tree_view_button_press (GtkWidget *widget, ...@@ -697,13 +712,13 @@ gimp_container_tree_view_button_press (GtkWidget *widget,
bevent->y, bevent->y,
&path, &column, NULL, NULL)) &path, &column, NULL, NULL))
{ {
GimpPreviewRenderer *renderer; GimpPreviewRenderer *renderer;
GtkCellRenderer *toggled_cell = NULL; GimpCellRendererToggle *toggled_cell = NULL;
GtkCellRenderer *clicked_cell = NULL; GimpCellRendererViewable *clicked_cell = NULL;
GdkRectangle column_area; GdkRectangle column_area;
gint tree_x; gint tree_x;
gint tree_y; gint tree_y;
GtkTreeIter iter; GtkTreeIter iter;
gtk_tree_model_get_iter (tree_view->model, &iter, path); gtk_tree_model_get_iter (tree_view->model, &iter, path);
...@@ -724,13 +739,13 @@ gimp_container_tree_view_button_press (GtkWidget *widget, ...@@ -724,13 +739,13 @@ gimp_container_tree_view_button_press (GtkWidget *widget,
&iter, &iter,
FALSE, FALSE); FALSE, FALSE);
toggled_cell = toggled_cell = (GimpCellRendererToggle *)
gimp_container_tree_view_find_click_cell (tree_view->toggle_cells, gimp_container_tree_view_find_click_cell (tree_view->toggle_cells,
column, &column_area, column, &column_area,
tree_x, tree_y); tree_x, tree_y);
if (! toggled_cell) if (! toggled_cell)
clicked_cell = clicked_cell = (GimpCellRendererViewable *)
gimp_container_tree_view_find_click_cell (tree_view->renderer_cells, gimp_container_tree_view_find_click_cell (tree_view->renderer_cells,
column, &column_area, column, &column_area,
tree_x, tree_y); tree_x, tree_y);
...@@ -749,15 +764,17 @@ gimp_container_tree_view_button_press (GtkWidget *widget, ...@@ -749,15 +764,17 @@ gimp_container_tree_view_button_press (GtkWidget *widget,
if (toggled_cell) if (toggled_cell)
{ {
/* don't select path */ /* don't select path */
g_signal_emit_by_name (toggled_cell, "clicked", gimp_cell_renderer_toggle_clicked (toggled_cell,
path_str, bevent->state); path_str,
bevent->state);
} }
else if (clicked_cell) else if (clicked_cell)
{ {
gtk_tree_selection_select_path (tree_view->selection, gtk_tree_selection_select_path (tree_view->selection,
path); path);
g_signal_emit_by_name (clicked_cell, "clicked", gimp_cell_renderer_viewable_clicked (clicked_cell,
path_str, bevent->state); path_str,
bevent->state);
} }
g_free (path_str); g_free (path_str);
......
...@@ -70,6 +70,16 @@ struct _GimpContainerTreeView ...@@ -70,6 +70,16 @@ struct _GimpContainerTreeView
struct _GimpContainerTreeViewClass struct _GimpContainerTreeViewClass
{ {
GimpContainerViewClass parent_class; GimpContainerViewClass parent_class;
gboolean (* drop_possible) (GimpContainerTreeView *tree_view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos,
GdkDragAction *drag_action);
void (* drop) (GimpContainerTreeView *tree_view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos);
}; };
......
...@@ -78,6 +78,16 @@ static void gimp_item_tree_view_context_item (GimpContainerView *view, ...@@ -78,6 +78,16 @@ static void gimp_item_tree_view_context_item (GimpContainerView *view,
GimpViewable *item, GimpViewable *item,
gpointer insert_data); gpointer insert_data);
static gboolean gimp_item_tree_view_drop_possible (GimpContainerTreeView *view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos,
GdkDragAction *drag_action);
static void gimp_item_tree_view_drop (GimpContainerTreeView *view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos);
static void gimp_item_tree_view_new_clicked (GtkWidget *widget, static void gimp_item_tree_view_new_clicked (GtkWidget *widget,
GimpItemTreeView *view); GimpItemTreeView *view);
static void gimp_item_tree_view_new_dropped (GtkWidget *widget, static void gimp_item_tree_view_new_dropped (GtkWidget *widget,
...@@ -151,13 +161,15 @@ gimp_item_tree_view_get_type (void) ...@@ -151,13 +161,15 @@ gimp_item_tree_view_get_type (void)
static void static void
gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass) gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class;
GtkObjectClass *gtk_object_class; GtkObjectClass *gtk_object_class;
GimpContainerViewClass *container_view_class; GimpContainerViewClass *container_view_class;
GimpContainerTreeViewClass *tree_view_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gtk_object_class = GTK_OBJECT_CLASS (klass); gtk_object_class = GTK_OBJECT_CLASS (klass);
container_view_class = GIMP_CONTAINER_VIEW_CLASS (klass); container_view_class = GIMP_CONTAINER_VIEW_CLASS (klass);
tree_view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
...@@ -179,6 +191,9 @@ gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass) ...@@ -179,6 +191,9 @@ gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass)
container_view_class->activate_item = gimp_item_tree_view_activate_item; container_view_class->activate_item = gimp_item_tree_view_activate_item;
container_view_class->context_item = gimp_item_tree_view_context_item; container_view_class->context_item = gimp_item_tree_view_context_item;
tree_view_class->drop_possible = gimp_item_tree_view_drop_possible;
tree_view_class->drop = gimp_item_tree_view_drop;
klass->set_image = gimp_item_tree_view_real_set_image; klass->set_image = gimp_item_tree_view_real_set_image;
klass->get_container = NULL; klass->get_container = NULL;
...@@ -337,8 +352,9 @@ gimp_item_tree_view_new (gint preview_size, ...@@ -337,8 +352,9 @@ gimp_item_tree_view_new (gint preview_size,
GimpMenuFactory *menu_factory, GimpMenuFactory *menu_factory,
const gchar *menu_identifier) const gchar *menu_identifier)
{ {
GimpItemTreeView *tree_view; GimpItemTreeView *item_view;
GimpContainerView *view; GimpContainerView *view;
GimpContainerTreeView *tree_view;
g_return_val_if_fail (preview_size > 0 && g_return_val_if_fail (preview_size > 0 &&
preview_size <= GIMP_PREVIEW_MAX_SIZE, NULL); preview_size <= GIMP_PREVIEW_MAX_SIZE, NULL);
...@@ -352,15 +368,15 @@ gimp_item_tree_view_new (gint preview_size, ...@@ -352,15 +368,15 @@ gimp_item_tree_view_new (gint preview_size,
if (item_type == GIMP_TYPE_LAYER) if (item_type == GIMP_TYPE_LAYER)
{ {
tree_view = g_object_new (GIMP_TYPE_LAYER_TREE_VIEW, NULL); item_view = g_object_new (GIMP_TYPE_LAYER_TREE_VIEW, NULL);
} }
else if (item_type == GIMP_TYPE_CHANNEL) else if (item_type == GIMP_TYPE_CHANNEL)
{ {
tree_view = g_object_new (GIMP_TYPE_CHANNEL_TREE_VIEW, NULL); item_view = g_object_new (GIMP_TYPE_CHANNEL_TREE_VIEW, NULL);
} }
else if (item_type == GIMP_TYPE_VECTORS) else if (item_type == GIMP_TYPE_VECTORS)
{ {
tree_view = g_object_new (GIMP_TYPE_VECTORS_TREE_VIEW, NULL); item_view = g_object_new (GIMP_TYPE_VECTORS_TREE_VIEW, NULL);
} }
else else
{ {
...@@ -369,45 +385,52 @@ gimp_item_tree_view_new (gint preview_size, ...@@ -369,45 +385,52 @@ gimp_item_tree_view_new (gint preview_size,
return NULL; return NULL;
} }
view = GIMP_CONTAINER_VIEW (tree_view); view = GIMP_CONTAINER_VIEW (item_view);
tree_view = GIMP_CONTAINER_TREE_VIEW (item_view);
view->preview_size = preview_size; view->preview_size = preview_size;
view->reorderable = TRUE; view->reorderable = TRUE;
view->dnd_widget = NULL;
gimp_dnd_drag_dest_set_by_type (GTK_WIDGET (tree_view->view),
GTK_DEST_DEFAULT_ALL,
item_type,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
tree_view->item_type = item_type;