2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-02-27 22:14:13 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2003-03-16 19:14:29 +08:00
|
|
|
* gimpitemtreeview.c
|
|
|
|
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
|
2001-04-22 08:38:56 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-02-27 22:14:13 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-02-27 22:14:13 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-02-27 22:14:13 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2004-12-11 06:11:29 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2001-02-27 22:14:13 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2007-12-12 21:57:11 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
2003-10-11 05:24:12 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-09-12 03:52:29 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2004-03-19 03:39:19 +08:00
|
|
|
#include "core/gimpimage-undo-push.h"
|
2004-03-19 01:01:46 +08:00
|
|
|
#include "core/gimpitemundo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayer.h"
|
|
|
|
#include "core/gimpmarshal.h"
|
2004-03-19 01:01:46 +08:00
|
|
|
#include "core/gimpundostack.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-02-26 13:42:14 +08:00
|
|
|
#include "vectors/gimpvectors.h"
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
#include "gimpcontainerview.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "gimpdnd.h"
|
2003-10-11 05:24:12 +08:00
|
|
|
#include "gimpdocked.h"
|
2004-10-17 04:17:30 +08:00
|
|
|
#include "gimpitemtreeview.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "gimpmenufactory.h"
|
2004-08-26 06:31:44 +08:00
|
|
|
#include "gimpviewrenderer.h"
|
2004-04-23 01:14:22 +08:00
|
|
|
#include "gimpuimanager.h"
|
2002-12-20 00:33:29 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-02-27 22:14:13 +08:00
|
|
|
|
|
|
|
|
2001-05-03 20:26:05 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SET_IMAGE,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
struct _GimpItemTreeViewPriv
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
|
|
|
|
GtkWidget *edit_button;
|
|
|
|
GtkWidget *new_button;
|
|
|
|
GtkWidget *raise_button;
|
|
|
|
GtkWidget *lower_button;
|
|
|
|
GtkWidget *duplicate_button;
|
|
|
|
GtkWidget *delete_button;
|
|
|
|
|
|
|
|
gint model_column_visible;
|
|
|
|
gint model_column_linked;
|
|
|
|
GtkCellRenderer *eye_cell;
|
|
|
|
GtkCellRenderer *chain_cell;
|
|
|
|
|
|
|
|
GQuark visible_changed_handler_id;
|
|
|
|
GQuark linked_changed_handler_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
static void gimp_item_tree_view_view_iface_init (GimpContainerViewInterface *view_iface);
|
|
|
|
static void gimp_item_tree_view_docked_iface_init (GimpDockedInterface *docked_iface);
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static GObject * gimp_item_tree_view_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
2004-10-17 04:17:30 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_item_tree_view_destroy (GtkObject *object);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_item_tree_view_real_set_image (GimpItemTreeView *view,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_item_tree_view_image_flush (GimpImage *image,
|
2007-06-27 05:39:51 +08:00
|
|
|
gboolean invalidate_preview,
|
2004-10-15 20:27:07 +08:00
|
|
|
GimpItemTreeView *view);
|
|
|
|
|
2003-05-09 04:26:01 +08:00
|
|
|
static void gimp_item_tree_view_set_container (GimpContainerView *view,
|
|
|
|
GimpContainer *container);
|
2006-09-01 05:40:16 +08:00
|
|
|
static void gimp_item_tree_view_set_context (GimpContainerView *view,
|
|
|
|
GimpContext *context);
|
|
|
|
|
2003-05-09 04:26:01 +08:00
|
|
|
static gpointer gimp_item_tree_view_insert_item (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint index);
|
2003-05-18 21:28:27 +08:00
|
|
|
static gboolean gimp_item_tree_view_select_item (GimpContainerView *view,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data);
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_item_tree_view_activate_item (GimpContainerView *view,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data);
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_item_tree_view_context_item (GimpContainerView *view,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data);
|
|
|
|
|
2003-03-19 23:17:13 +08:00
|
|
|
static gboolean gimp_item_tree_view_drop_possible (GimpContainerTreeView *view,
|
2004-06-29 06:07:12 +08:00
|
|
|
GimpDndType src_type,
|
2003-03-19 23:17:13 +08:00
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos,
|
2004-06-29 06:07:12 +08:00
|
|
|
GtkTreeViewDropPosition *return_drop_pos,
|
|
|
|
GdkDragAction *return_drag_action);
|
|
|
|
static void gimp_item_tree_view_drop_viewable (GimpContainerTreeView *view,
|
2003-03-19 23:17:13 +08:00
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos);
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_item_tree_view_new_dropped (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_item_tree_view_item_changed (GimpImage *image,
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeView *view);
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_item_tree_view_size_changed (GimpImage *image,
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeView *view);
|
|
|
|
|
|
|
|
static void gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
|
|
|
|
const gchar *path,
|
2004-12-11 05:07:28 +08:00
|
|
|
const gchar *new_name,
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeView *view);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2003-09-12 03:52:29 +08:00
|
|
|
static void gimp_item_tree_view_visible_changed (GimpItem *item,
|
|
|
|
GimpItemTreeView *view);
|
2003-05-09 04:26:01 +08:00
|
|
|
static void gimp_item_tree_view_linked_changed (GimpItem *item,
|
|
|
|
GimpItemTreeView *view);
|
2003-09-12 03:52:29 +08:00
|
|
|
|
|
|
|
static void gimp_item_tree_view_eye_clicked (GtkCellRendererToggle *toggle,
|
|
|
|
gchar *path,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpItemTreeView *view);
|
2003-05-09 04:26:01 +08:00
|
|
|
static void gimp_item_tree_view_chain_clicked (GtkCellRendererToggle *toggle,
|
|
|
|
gchar *path,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpItemTreeView *view);
|
|
|
|
|
2003-11-15 01:35:51 +08:00
|
|
|
/* utility function to avoid code duplication */
|
|
|
|
static void gimp_item_tree_view_toggle_clicked (GtkCellRendererToggle *toggle,
|
2004-03-19 03:39:19 +08:00
|
|
|
gchar *path_str,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpItemTreeView *view,
|
|
|
|
GimpUndoType undo_type);
|
2003-11-15 01:35:51 +08:00
|
|
|
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpItemTreeView, gimp_item_tree_view,
|
|
|
|
GIMP_TYPE_CONTAINER_TREE_VIEW,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONTAINER_VIEW,
|
|
|
|
gimp_item_tree_view_view_iface_init)
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
|
2006-05-15 17:46:31 +08:00
|
|
|
gimp_item_tree_view_docked_iface_init))
|
2005-12-20 06:37:49 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_item_tree_view_parent_class
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
static GimpContainerViewInterface *parent_view_iface = NULL;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
static guint view_signals[LAST_SIGNAL] = { 0 };
|
2001-02-27 22:14:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2003-03-19 23:17:13 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkObjectClass *gtk_object_class;
|
|
|
|
GimpContainerTreeViewClass *tree_view_class;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
gtk_object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
tree_view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2001-05-03 20:26:05 +08:00
|
|
|
view_signals[SET_IMAGE] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("set-image",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpItemTreeViewClass, set_image),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_OBJECT);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
object_class->constructor = gimp_item_tree_view_constructor;
|
|
|
|
|
|
|
|
gtk_object_class->destroy = gimp_item_tree_view_destroy;
|
|
|
|
|
|
|
|
tree_view_class->drop_possible = gimp_item_tree_view_drop_possible;
|
2004-06-29 06:07:12 +08:00
|
|
|
tree_view_class->drop_viewable = gimp_item_tree_view_drop_viewable;
|
2004-05-11 07:22:39 +08:00
|
|
|
|
|
|
|
klass->set_image = gimp_item_tree_view_real_set_image;
|
|
|
|
|
2004-10-17 04:17:30 +08:00
|
|
|
klass->item_type = G_TYPE_NONE;
|
|
|
|
klass->signal_name = NULL;
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
klass->get_container = NULL;
|
|
|
|
klass->get_active_item = NULL;
|
|
|
|
klass->set_active_item = NULL;
|
|
|
|
klass->reorder_item = NULL;
|
|
|
|
klass->add_item = NULL;
|
|
|
|
klass->remove_item = NULL;
|
2004-10-16 23:48:23 +08:00
|
|
|
klass->new_item = NULL;
|
|
|
|
|
|
|
|
klass->action_group = NULL;
|
|
|
|
klass->edit_action = NULL;
|
|
|
|
klass->new_action = NULL;
|
|
|
|
klass->new_default_action = NULL;
|
|
|
|
klass->raise_action = NULL;
|
|
|
|
klass->raise_top_action = NULL;
|
|
|
|
klass->lower_action = NULL;
|
|
|
|
klass->lower_bottom_action = NULL;
|
|
|
|
klass->duplicate_action = NULL;
|
|
|
|
klass->delete_action = NULL;
|
|
|
|
klass->reorder_desc = NULL;
|
2008-12-25 19:31:51 +08:00
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (GimpItemTreeViewPriv));
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
static void
|
|
|
|
gimp_item_tree_view_view_iface_init (GimpContainerViewInterface *iface)
|
|
|
|
{
|
|
|
|
parent_view_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
iface->set_container = gimp_item_tree_view_set_container;
|
2006-09-01 05:40:16 +08:00
|
|
|
iface->set_context = gimp_item_tree_view_set_context;
|
2006-08-30 05:44:51 +08:00
|
|
|
iface->insert_item = gimp_item_tree_view_insert_item;
|
|
|
|
iface->select_item = gimp_item_tree_view_select_item;
|
|
|
|
iface->activate_item = gimp_item_tree_view_activate_item;
|
|
|
|
iface->context_item = gimp_item_tree_view_context_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_item_tree_view_docked_iface_init (GimpDockedInterface *iface)
|
|
|
|
{
|
|
|
|
iface->get_preview = NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-27 22:14:13 +08:00
|
|
|
static void
|
2005-12-20 06:37:49 +08:00
|
|
|
gimp_item_tree_view_init (GimpItemTreeView *view)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2004-05-11 18:01:25 +08:00
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
2001-08-05 04:38:54 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv = G_TYPE_INSTANCE_GET_PRIVATE (view,
|
|
|
|
GIMP_TYPE_ITEM_TREE_VIEW,
|
|
|
|
GimpItemTreeViewPriv);
|
|
|
|
|
2003-10-13 07:15:51 +08:00
|
|
|
/* The following used to read:
|
|
|
|
*
|
|
|
|
* tree_view->model_columns[tree_view->n_model_columns++] = ...
|
|
|
|
*
|
|
|
|
* but combining the two lead to gcc miscompiling the function on ppc/ia64
|
|
|
|
* (model_column_mask and model_column_mask_visible would have the same
|
|
|
|
* value, probably due to bad instruction reordering). See bug #113144 for
|
|
|
|
* more info.
|
|
|
|
*/
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv->model_column_visible = tree_view->n_model_columns;
|
2003-10-13 07:15:51 +08:00
|
|
|
tree_view->model_columns[tree_view->n_model_columns] = G_TYPE_BOOLEAN;
|
|
|
|
tree_view->n_model_columns++;
|
2003-09-12 03:52:29 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv->model_column_linked = tree_view->n_model_columns;
|
2003-10-13 07:15:51 +08:00
|
|
|
tree_view->model_columns[tree_view->n_model_columns] = G_TYPE_BOOLEAN;
|
|
|
|
tree_view->n_model_columns++;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2008-11-17 03:48:54 +08:00
|
|
|
gimp_container_tree_view_set_dnd_drop_to_empty (tree_view, TRUE);
|
2005-01-17 23:28:08 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv->image = NULL;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv->visible_changed_handler_id = 0;
|
|
|
|
view->priv->linked_changed_handler_id = 0;
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_item_tree_view_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpItemTreeViewClass *item_view_class;
|
|
|
|
GimpEditor *editor;
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpItemTreeView *item_view;
|
|
|
|
GObject *object;
|
|
|
|
GtkTreeViewColumn *column;
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
2004-10-17 04:17:30 +08:00
|
|
|
editor = GIMP_EDITOR (object);
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
|
|
|
|
item_view = GIMP_ITEM_TREE_VIEW (object);
|
|
|
|
item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (object);
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2008-06-29 00:05:05 +08:00
|
|
|
gimp_container_tree_view_connect_name_edited (tree_view,
|
|
|
|
G_CALLBACK (gimp_item_tree_view_name_edited),
|
|
|
|
item_view);
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-05-09 04:26:01 +08:00
|
|
|
column = gtk_tree_view_column_new ();
|
|
|
|
gtk_tree_view_insert_column (tree_view->view, column, 0);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->eye_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_VISIBLE);
|
|
|
|
gtk_tree_view_column_pack_start (column, item_view->priv->eye_cell, FALSE);
|
|
|
|
gtk_tree_view_column_set_attributes (column, item_view->priv->eye_cell,
|
2003-09-12 03:52:29 +08:00
|
|
|
"active",
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->model_column_visible,
|
2003-09-12 03:52:29 +08:00
|
|
|
NULL);
|
|
|
|
|
2008-11-17 04:58:53 +08:00
|
|
|
gimp_container_tree_view_prepend_toggle_cell_renderer (tree_view,
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->eye_cell);
|
2003-09-12 03:52:29 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_connect (item_view->priv->eye_cell, "clicked",
|
2003-09-15 22:39:48 +08:00
|
|
|
G_CALLBACK (gimp_item_tree_view_eye_clicked),
|
2003-09-12 03:52:29 +08:00
|
|
|
item_view);
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new ();
|
2003-09-15 22:39:48 +08:00
|
|
|
gtk_tree_view_insert_column (tree_view->view, column, 1);
|
2003-09-12 03:52:29 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->chain_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_LINKED);
|
|
|
|
gtk_tree_view_column_pack_start (column, item_view->priv->chain_cell, FALSE);
|
|
|
|
gtk_tree_view_column_set_attributes (column, item_view->priv->chain_cell,
|
2003-05-09 04:26:01 +08:00
|
|
|
"active",
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->model_column_linked,
|
2003-05-09 04:26:01 +08:00
|
|
|
NULL);
|
|
|
|
|
2008-11-17 04:58:53 +08:00
|
|
|
gimp_container_tree_view_prepend_toggle_cell_renderer (tree_view,
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->chain_cell);
|
2003-05-09 04:26:01 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_connect (item_view->priv->chain_cell, "clicked",
|
2003-09-15 22:39:48 +08:00
|
|
|
G_CALLBACK (gimp_item_tree_view_chain_clicked),
|
2003-05-09 04:26:01 +08:00
|
|
|
item_view);
|
|
|
|
|
2003-12-22 00:15:34 +08:00
|
|
|
/* disable the default GimpContainerView drop handler */
|
2004-05-11 07:22:39 +08:00
|
|
|
gimp_container_view_set_dnd_widget (GIMP_CONTAINER_VIEW (item_view), NULL);
|
2003-12-22 00:15:34 +08:00
|
|
|
|
2003-12-21 20:11:44 +08:00
|
|
|
gimp_dnd_drag_dest_set_by_type (GTK_WIDGET (tree_view->view),
|
2004-06-29 06:07:12 +08:00
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT,
|
2004-10-17 04:17:30 +08:00
|
|
|
item_view_class->item_type,
|
2003-12-21 20:11:44 +08:00
|
|
|
GDK_ACTION_MOVE | GDK_ACTION_COPY);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->edit_button =
|
2004-10-16 23:48:23 +08:00
|
|
|
gimp_editor_add_action_button (editor, item_view_class->action_group,
|
|
|
|
item_view_class->edit_action, NULL);
|
|
|
|
gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (item_view),
|
2008-12-25 19:31:51 +08:00
|
|
|
GTK_BUTTON (item_view->priv->edit_button),
|
2006-04-12 20:49:29 +08:00
|
|
|
item_view_class->item_type);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->new_button =
|
2004-10-16 23:48:23 +08:00
|
|
|
gimp_editor_add_action_button (editor, item_view_class->action_group,
|
2004-10-17 01:10:04 +08:00
|
|
|
item_view_class->new_action,
|
2004-10-23 08:53:48 +08:00
|
|
|
item_view_class->new_default_action,
|
2004-10-17 01:10:04 +08:00
|
|
|
GDK_SHIFT_MASK,
|
2004-10-16 23:48:23 +08:00
|
|
|
NULL);
|
2003-12-21 20:11:44 +08:00
|
|
|
/* connect "drop to new" manually as it makes a difference whether
|
|
|
|
* it was clicked or dropped
|
|
|
|
*/
|
2008-12-25 19:31:51 +08:00
|
|
|
gimp_dnd_viewable_dest_add (item_view->priv->new_button,
|
2006-04-12 20:49:29 +08:00
|
|
|
item_view_class->item_type,
|
|
|
|
gimp_item_tree_view_new_dropped,
|
|
|
|
item_view);
|
2003-12-21 20:11:44 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->raise_button =
|
2004-10-16 23:48:23 +08:00
|
|
|
gimp_editor_add_action_button (editor, item_view_class->action_group,
|
|
|
|
item_view_class->raise_action,
|
|
|
|
item_view_class->raise_top_action,
|
|
|
|
GDK_SHIFT_MASK,
|
|
|
|
NULL);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->lower_button =
|
2004-10-16 23:48:23 +08:00
|
|
|
gimp_editor_add_action_button (editor, item_view_class->action_group,
|
|
|
|
item_view_class->lower_action,
|
|
|
|
item_view_class->lower_bottom_action,
|
|
|
|
GDK_SHIFT_MASK,
|
|
|
|
NULL);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->duplicate_button =
|
2004-10-16 23:48:23 +08:00
|
|
|
gimp_editor_add_action_button (editor, item_view_class->action_group,
|
|
|
|
item_view_class->duplicate_action, NULL);
|
2003-12-21 20:11:44 +08:00
|
|
|
gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (item_view),
|
2008-12-25 19:31:51 +08:00
|
|
|
GTK_BUTTON (item_view->priv->duplicate_button),
|
2006-04-12 20:49:29 +08:00
|
|
|
item_view_class->item_type);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->delete_button =
|
2004-10-16 23:48:23 +08:00
|
|
|
gimp_editor_add_action_button (editor, item_view_class->action_group,
|
|
|
|
item_view_class->delete_action, NULL);
|
2003-12-21 20:11:44 +08:00
|
|
|
gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (item_view),
|
2008-12-25 19:31:51 +08:00
|
|
|
GTK_BUTTON (item_view->priv->delete_button),
|
2006-04-12 20:49:29 +08:00
|
|
|
item_view_class->item_type);
|
2003-12-21 20:11:44 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
2003-12-21 20:11:44 +08:00
|
|
|
static void
|
|
|
|
gimp_item_tree_view_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (object);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
if (view->priv->image)
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_set_image (view, NULL);
|
2001-05-01 22:58:13 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2004-10-17 04:17:30 +08:00
|
|
|
gimp_item_tree_view_new (GType view_type,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size,
|
|
|
|
gint view_border_width,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image,
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpMenuFactory *menu_factory,
|
|
|
|
const gchar *menu_identifier,
|
|
|
|
const gchar *ui_path)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpItemTreeView *item_view;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2004-10-17 04:17:30 +08:00
|
|
|
g_return_val_if_fail (g_type_is_a (view_type, GIMP_TYPE_ITEM_TREE_VIEW), NULL);
|
2006-01-17 18:08:50 +08:00
|
|
|
g_return_val_if_fail (view_size > 0 &&
|
2006-04-12 20:49:29 +08:00
|
|
|
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
|
2006-01-17 18:08:50 +08:00
|
|
|
g_return_val_if_fail (view_border_width >= 0 &&
|
|
|
|
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
|
2003-04-08 20:39:02 +08:00
|
|
|
NULL);
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
|
|
|
g_return_val_if_fail (menu_identifier != NULL, NULL);
|
2004-05-13 02:36:33 +08:00
|
|
|
g_return_val_if_fail (ui_path != NULL, NULL);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2003-12-21 20:11:44 +08:00
|
|
|
item_view = g_object_new (view_type,
|
2004-05-13 02:36:33 +08:00
|
|
|
"reorderable", TRUE,
|
|
|
|
"menu-factory", menu_factory,
|
|
|
|
"menu-identifier", menu_identifier,
|
|
|
|
"ui-path", ui_path,
|
2003-12-21 20:11:44 +08:00
|
|
|
NULL);
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_container_view_set_view_size (GIMP_CONTAINER_VIEW (item_view),
|
|
|
|
view_size, view_border_width);
|
2003-03-27 01:49:42 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_item_tree_view_set_image (item_view, image);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2003-03-19 23:17:13 +08:00
|
|
|
return GTK_WIDGET (item_view);
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_set_image (GimpItemTreeView *view,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image)
|
2001-05-03 20:26:05 +08:00
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
g_return_if_fail (GIMP_IS_ITEM_TREE_VIEW (view));
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_emit (view, view_signals[SET_IMAGE], 0, image);
|
2004-10-15 20:27:07 +08:00
|
|
|
|
|
|
|
gimp_ui_manager_update (GIMP_EDITOR (view)->ui_manager, view);
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
|
2006-06-17 01:02:14 +08:00
|
|
|
GimpImage *
|
|
|
|
gimp_item_tree_view_get_image (GimpItemTreeView *view)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_ITEM_TREE_VIEW (view), NULL);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
return view->priv->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_item_tree_view_get_new_button (GimpItemTreeView *view)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_ITEM_TREE_VIEW (view), NULL);
|
|
|
|
|
|
|
|
return view->priv->new_button;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_item_tree_view_get_edit_button (GimpItemTreeView *view)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_ITEM_TREE_VIEW (view), NULL);
|
|
|
|
|
|
|
|
return view->priv->edit_button;
|
2006-06-17 01:02:14 +08:00
|
|
|
}
|
|
|
|
|
2001-05-03 20:26:05 +08:00
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_real_set_image (GimpItemTreeView *view,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2008-12-25 19:31:51 +08:00
|
|
|
if (view->priv->image == image)
|
2001-02-27 22:14:13 +08:00
|
|
|
return;
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
if (view->priv->image)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (view->priv->image,
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_item_tree_view_item_changed,
|
|
|
|
view);
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (view->priv->image,
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_item_tree_view_size_changed,
|
|
|
|
view);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
|
|
|
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), NULL);
|
2004-10-15 20:27:07 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (view->priv->image,
|
2004-10-15 20:27:07 +08:00
|
|
|
gimp_item_tree_view_image_flush,
|
|
|
|
view);
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv->image = image;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
if (view->priv->image)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
|
|
|
GimpContainer *container;
|
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
container =
|
2008-12-25 19:31:51 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_container (view->priv->image);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
|
|
|
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), container);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_connect (view->priv->image,
|
2004-10-17 04:17:30 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->signal_name,
|
2006-04-12 20:49:29 +08:00
|
|
|
G_CALLBACK (gimp_item_tree_view_item_changed),
|
|
|
|
view);
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_connect (view->priv->image, "size-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_CALLBACK (gimp_item_tree_view_size_changed),
|
|
|
|
view);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
g_signal_connect (view->priv->image, "flush",
|
2004-10-15 20:27:07 +08:00
|
|
|
G_CALLBACK (gimp_item_tree_view_image_flush),
|
|
|
|
view);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
gimp_item_tree_view_item_changed (view->priv->image, view);
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-15 20:27:07 +08:00
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_item_tree_view_image_flush (GimpImage *image,
|
2007-06-27 05:39:51 +08:00
|
|
|
gboolean invalidate_preview,
|
2004-10-15 20:27:07 +08:00
|
|
|
GimpItemTreeView *view)
|
|
|
|
{
|
|
|
|
gimp_ui_manager_update (GIMP_EDITOR (view)->ui_manager, view);
|
|
|
|
}
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
/* GimpContainerView methods */
|
|
|
|
|
2003-05-09 04:26:01 +08:00
|
|
|
static void
|
|
|
|
gimp_item_tree_view_set_container (GimpContainerView *view,
|
|
|
|
GimpContainer *container)
|
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
|
|
|
|
GimpContainer *old_container;
|
2003-05-09 04:26:01 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
old_container = gimp_container_view_get_container (view);
|
2003-05-09 04:26:01 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (old_container)
|
2003-05-09 04:26:01 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
gimp_container_remove_handler (old_container,
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->visible_changed_handler_id);
|
2004-05-11 01:16:50 +08:00
|
|
|
gimp_container_remove_handler (old_container,
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->linked_changed_handler_id);
|
2003-09-15 22:39:48 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->visible_changed_handler_id = 0;
|
|
|
|
item_view->priv->linked_changed_handler_id = 0;
|
2003-05-09 04:26:01 +08:00
|
|
|
}
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
parent_view_iface->set_container (view, container);
|
2003-05-09 04:26:01 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (container)
|
2003-05-09 04:26:01 +08:00
|
|
|
{
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->visible_changed_handler_id =
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_container_add_handler (container, "visibility-changed",
|
|
|
|
G_CALLBACK (gimp_item_tree_view_visible_changed),
|
|
|
|
view);
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->linked_changed_handler_id =
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_container_add_handler (container, "linked-changed",
|
|
|
|
G_CALLBACK (gimp_item_tree_view_linked_changed),
|
|
|
|
view);
|
2003-05-09 04:26:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
static void
|
|
|
|
gimp_item_tree_view_set_context (GimpContainerView *view,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
|
|
|
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
|
|
|
|
GimpImage *image = NULL;
|
|
|
|
GimpContext *old_context;
|
|
|
|
|
|
|
|
old_context = gimp_container_view_get_context (view);
|
|
|
|
|
|
|
|
if (old_context)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (old_context,
|
|
|
|
gimp_item_tree_view_set_image,
|
|
|
|
item_view);
|
|
|
|
}
|
|
|
|
|
|
|
|
parent_view_iface->set_context (view, context);
|
|
|
|
|
|
|
|
if (context)
|
|
|
|
{
|
|
|
|
if (! tree_view->dnd_gimp)
|
|
|
|
tree_view->dnd_gimp = context->gimp;
|
|
|
|
|
|
|
|
g_signal_connect_swapped (context, "image-changed",
|
|
|
|
G_CALLBACK (gimp_item_tree_view_set_image),
|
|
|
|
item_view);
|
|
|
|
|
|
|
|
image = gimp_context_get_image (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_item_tree_view_set_image (item_view, image);
|
|
|
|
}
|
|
|
|
|
2003-05-09 04:26:01 +08:00
|
|
|
static gpointer
|
|
|
|
gimp_item_tree_view_insert_item (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint index)
|
|
|
|
{
|
2004-05-11 18:01:25 +08:00
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
|
|
|
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
|
|
|
|
GimpItem *item = GIMP_ITEM (viewable);
|
2003-05-09 04:26:01 +08:00
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
iter = parent_view_iface->insert_item (view, viewable, index);
|
2003-05-09 04:26:01 +08:00
|
|
|
|
2009-07-25 23:38:03 +08:00
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), iter,
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->model_column_visible,
|
2003-09-12 03:52:29 +08:00
|
|
|
gimp_item_get_visible (item),
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->model_column_linked,
|
2003-05-09 04:26:01 +08:00
|
|
|
gimp_item_get_linked (item),
|
|
|
|
-1);
|
|
|
|
|
|
|
|
return iter;
|
|
|
|
}
|
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
static gboolean
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_select_item (GimpContainerView *view,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpItemTreeView *tree_view = GIMP_ITEM_TREE_VIEW (view);
|
2003-05-18 21:28:27 +08:00
|
|
|
gboolean success;
|
2001-03-06 21:28:39 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
success = parent_view_iface->select_item (view, item, insert_data);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2001-03-06 21:28:39 +08:00
|
|
|
if (item)
|
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeViewClass *item_view_class;
|
2003-02-17 21:33:29 +08:00
|
|
|
GimpItem *active_item;
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (tree_view);
|
2001-03-06 21:28:39 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
active_item = item_view_class->get_active_item (tree_view->priv->image);
|
2001-03-06 21:28:39 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
if (active_item != (GimpItem *) item)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view_class->set_active_item (tree_view->priv->image,
|
2003-02-17 21:33:29 +08:00
|
|
|
GIMP_ITEM (item));
|
2001-03-06 21:28:39 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
gimp_image_flush (tree_view->priv->image);
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2001-03-06 21:28:39 +08:00
|
|
|
}
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_ui_manager_update (GIMP_EDITOR (tree_view)->ui_manager, tree_view);
|
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
return success;
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_activate_item (GimpContainerView *view,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpItemTreeViewClass *item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (view);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
if (parent_view_iface->activate_item)
|
|
|
|
parent_view_iface->activate_item (view, item, insert_data);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
if (item_view_class->activate_action)
|
|
|
|
{
|
2006-12-15 20:03:47 +08:00
|
|
|
gimp_ui_manager_activate_action (GIMP_EDITOR (view)->ui_manager,
|
|
|
|
item_view_class->action_group,
|
|
|
|
item_view_class->activate_action);
|
2004-10-16 23:48:23 +08:00
|
|
|
}
|
2001-03-06 21:28:39 +08:00
|
|
|
}
|
|
|
|
|
2001-04-29 23:23:01 +08:00
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_context_item (GimpContainerView *view,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data)
|
2001-04-29 23:23:01 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
if (parent_view_iface->context_item)
|
|
|
|
parent_view_iface->context_item (view, item, insert_data);
|
2001-04-29 23:23:01 +08:00
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
gimp_editor_popup_menu (GIMP_EDITOR (view), NULL, NULL);
|
2001-04-29 23:23:01 +08:00
|
|
|
}
|
|
|
|
|
2003-03-19 23:17:13 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_item_tree_view_drop_possible (GimpContainerTreeView *tree_view,
|
2004-06-29 06:07:12 +08:00
|
|
|
GimpDndType src_type,
|
2003-03-19 23:17:13 +08:00
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos,
|
2004-06-29 06:07:12 +08:00
|
|
|
GtkTreeViewDropPosition *return_drop_pos,
|
|
|
|
GdkDragAction *return_drag_action)
|
2003-03-19 23:17:13 +08:00
|
|
|
{
|
2004-06-29 06:07:12 +08:00
|
|
|
if (GIMP_IS_ITEM (src_viewable) &&
|
2005-01-17 23:28:08 +08:00
|
|
|
(dest_viewable == NULL ||
|
|
|
|
gimp_item_get_image (GIMP_ITEM (src_viewable)) !=
|
|
|
|
gimp_item_get_image (GIMP_ITEM (dest_viewable))))
|
2003-03-19 23:17:13 +08:00
|
|
|
{
|
2004-06-29 06:07:12 +08:00
|
|
|
if (return_drop_pos)
|
|
|
|
*return_drop_pos = drop_pos;
|
|
|
|
|
|
|
|
if (return_drag_action)
|
|
|
|
*return_drag_action = GDK_ACTION_COPY;
|
2003-03-19 23:17:13 +08:00
|
|
|
|
2003-08-28 01:21:49 +08:00
|
|
|
return TRUE;
|
2003-03-19 23:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_possible (tree_view,
|
2004-06-29 06:07:12 +08:00
|
|
|
src_type,
|
2003-03-19 23:17:13 +08:00
|
|
|
src_viewable,
|
|
|
|
dest_viewable,
|
|
|
|
drop_pos,
|
2004-06-29 06:07:12 +08:00
|
|
|
return_drop_pos,
|
|
|
|
return_drag_action);
|
2003-03-19 23:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-06-29 06:07:12 +08:00
|
|
|
gimp_item_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
|
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos)
|
2003-03-19 23:17:13 +08:00
|
|
|
{
|
2004-05-11 18:01:25 +08:00
|
|
|
GimpContainerView *container_view = GIMP_CONTAINER_VIEW (tree_view);
|
|
|
|
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
2003-03-19 23:17:13 +08:00
|
|
|
GimpItemTreeViewClass *item_view_class;
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainer *container;
|
2005-01-17 23:28:08 +08:00
|
|
|
gint dest_index = -1;
|
2003-03-19 23:17:13 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
container = gimp_container_view_get_container (container_view);
|
|
|
|
|
2005-01-17 23:28:08 +08:00
|
|
|
if (dest_viewable)
|
|
|
|
dest_index = gimp_container_get_child_index (container,
|
|
|
|
GIMP_OBJECT (dest_viewable));
|
2003-03-19 23:17:13 +08:00
|
|
|
|
|
|
|
item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (item_view);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
if (item_view->priv->image != gimp_item_get_image (GIMP_ITEM (src_viewable)) ||
|
2005-01-15 11:24:42 +08:00
|
|
|
! g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable),
|
|
|
|
item_view_class->item_type))
|
2003-03-19 23:17:13 +08:00
|
|
|
{
|
2005-01-15 11:24:42 +08:00
|
|
|
GType item_type = item_view_class->item_type;
|
2003-03-19 23:17:13 +08:00
|
|
|
GimpItem *new_item;
|
|
|
|
|
2005-01-15 11:24:42 +08:00
|
|
|
if (g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable), item_type))
|
|
|
|
item_type = G_TYPE_FROM_INSTANCE (src_viewable);
|
|
|
|
|
2005-01-17 23:28:08 +08:00
|
|
|
if (dest_viewable && drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
2003-03-19 23:17:13 +08:00
|
|
|
dest_index++;
|
|
|
|
|
2003-08-28 01:21:49 +08:00
|
|
|
new_item = gimp_item_convert (GIMP_ITEM (src_viewable),
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view->priv->image, item_type);
|
2003-03-19 23:17:13 +08:00
|
|
|
|
2007-06-02 19:45:54 +08:00
|
|
|
gimp_item_set_linked (new_item, FALSE, FALSE);
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view_class->add_item (item_view->priv->image, new_item, dest_index, TRUE);
|
2003-03-19 23:17:13 +08:00
|
|
|
}
|
2005-01-17 23:28:08 +08:00
|
|
|
else if (dest_viewable)
|
2003-03-19 23:17:13 +08:00
|
|
|
{
|
2005-01-15 11:24:42 +08:00
|
|
|
gint src_index;
|
|
|
|
|
|
|
|
src_index = gimp_container_get_child_index (container,
|
|
|
|
GIMP_OBJECT (src_viewable));
|
|
|
|
|
2003-03-19 23:17:13 +08:00
|
|
|
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--;
|
|
|
|
}
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item_view_class->reorder_item (item_view->priv->image,
|
2004-06-01 23:14:45 +08:00
|
|
|
GIMP_ITEM (src_viewable),
|
2003-03-19 23:17:13 +08:00
|
|
|
dest_index,
|
|
|
|
TRUE,
|
2003-03-20 00:37:24 +08:00
|
|
|
item_view_class->reorder_desc);
|
2003-03-19 23:17:13 +08:00
|
|
|
}
|
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
gimp_image_flush (item_view->priv->image);
|
2003-03-19 23:17:13 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
/* "New" functions */
|
|
|
|
|
2001-02-27 22:14:13 +08:00
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_item_tree_view_new_dropped (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpItemTreeViewClass *item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (data);
|
|
|
|
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data);
|
|
|
|
GimpContainer *container;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
container = gimp_container_view_get_container (GIMP_CONTAINER_VIEW (view));
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
if (viewable && gimp_container_have (container, GIMP_OBJECT (viewable)) &&
|
|
|
|
item_view_class->new_default_action)
|
2001-03-06 21:28:39 +08:00
|
|
|
{
|
2004-10-17 01:29:42 +08:00
|
|
|
GtkAction *action;
|
2001-03-06 21:28:39 +08:00
|
|
|
|
2004-12-08 21:52:28 +08:00
|
|
|
action = gimp_ui_manager_find_action (GIMP_EDITOR (view)->ui_manager,
|
|
|
|
item_view_class->action_group,
|
|
|
|
item_view_class->new_default_action);
|
2003-02-17 21:33:29 +08:00
|
|
|
|
2004-10-17 01:29:42 +08:00
|
|
|
if (action)
|
2003-02-17 21:33:29 +08:00
|
|
|
{
|
2004-10-17 01:29:42 +08:00
|
|
|
g_object_set (action, "viewable", viewable, NULL);
|
|
|
|
gtk_action_activate (action);
|
|
|
|
g_object_set (action, "viewable", NULL, NULL);
|
2003-02-17 21:33:29 +08:00
|
|
|
}
|
2001-05-07 04:31:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
/* GimpImage callbacks */
|
|
|
|
|
2001-02-27 22:14:13 +08:00
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_item_tree_view_item_changed (GimpImage *image,
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeView *view)
|
2001-02-27 22:14:13 +08:00
|
|
|
{
|
2003-02-17 21:33:29 +08:00
|
|
|
GimpItem *item;
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (view->priv->image);
|
2001-02-27 22:14:13 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
|
|
|
|
(GimpViewable *) item);
|
2001-02-27 22:14:13 +08:00
|
|
|
}
|
2001-05-07 01:56:10 +08:00
|
|
|
|
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_item_tree_view_size_changed (GimpImage *image,
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpItemTreeView *tree_view)
|
2001-05-07 01:56:10 +08:00
|
|
|
{
|
2004-07-05 05:27:09 +08:00
|
|
|
GimpContainerView *view = GIMP_CONTAINER_VIEW (tree_view);
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size;
|
2004-05-11 01:16:50 +08:00
|
|
|
gint border_width;
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size = gimp_container_view_get_view_size (view, &border_width);
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_container_view_set_view_size (view, view_size, border_width);
|
2001-05-07 01:56:10 +08:00
|
|
|
}
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
|
|
|
|
const gchar *path_str,
|
2004-12-11 05:07:28 +08:00
|
|
|
const gchar *new_name,
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeView *view)
|
|
|
|
{
|
2006-08-30 05:44:51 +08:00
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
2003-03-16 19:14:29 +08:00
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
|
|
|
|
{
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewRenderer *renderer;
|
|
|
|
GimpItem *item;
|
2004-12-11 05:07:28 +08:00
|
|
|
const gchar *old_name;
|
2007-12-12 21:57:11 +08:00
|
|
|
GError *error = NULL;
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
gtk_tree_model_get (tree_view->model, &iter,
|
2008-11-16 04:01:55 +08:00
|
|
|
GIMP_CONTAINER_TREE_VIEW_COLUMN_RENDERER, &renderer,
|
2003-03-16 19:14:29 +08:00
|
|
|
-1);
|
|
|
|
|
|
|
|
item = GIMP_ITEM (renderer->viewable);
|
|
|
|
|
2004-12-11 05:07:28 +08:00
|
|
|
old_name = gimp_object_get_name (GIMP_OBJECT (item));
|
|
|
|
|
|
|
|
if (! old_name) old_name = "";
|
|
|
|
if (! new_name) new_name = "";
|
|
|
|
|
|
|
|
if (strcmp (old_name, new_name) &&
|
2007-12-12 21:57:11 +08:00
|
|
|
gimp_item_rename (item, new_name, &error))
|
2004-02-02 04:38:26 +08:00
|
|
|
{
|
|
|
|
gimp_image_flush (gimp_item_get_image (item));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *name = gimp_viewable_get_description (renderer->viewable, NULL);
|
|
|
|
|
2009-07-25 23:38:03 +08:00
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), &iter,
|
2008-11-16 04:01:55 +08:00
|
|
|
GIMP_CONTAINER_TREE_VIEW_COLUMN_NAME, name,
|
2004-02-02 04:38:26 +08:00
|
|
|
-1);
|
|
|
|
g_free (name);
|
2007-12-12 21:57:11 +08:00
|
|
|
|
2008-06-25 05:23:20 +08:00
|
|
|
if (error)
|
|
|
|
{
|
2008-12-25 19:31:51 +08:00
|
|
|
gimp_message_literal (view->priv->image->gimp, G_OBJECT (view),
|
2008-11-04 20:33:09 +08:00
|
|
|
GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
2008-06-25 05:23:20 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2004-02-02 04:38:26 +08:00
|
|
|
}
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
g_object_unref (renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
2003-05-09 04:26:01 +08:00
|
|
|
|
|
|
|
|
2003-09-12 03:52:29 +08:00
|
|
|
/* "Visible" callbacks */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_item_tree_view_visible_changed (GimpItem *item,
|
|
|
|
GimpItemTreeView *view)
|
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerView *container_view = GIMP_CONTAINER_VIEW (view);
|
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
|
|
|
GtkTreeIter *iter;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
iter = gimp_container_view_lookup (container_view,
|
|
|
|
(GimpViewable *) item);
|
2003-09-12 03:52:29 +08:00
|
|
|
|
|
|
|
if (iter)
|
2009-07-25 23:38:03 +08:00
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), iter,
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv->model_column_visible,
|
2003-09-12 03:52:29 +08:00
|
|
|
gimp_item_get_visible (item),
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_item_tree_view_eye_clicked (GtkCellRendererToggle *toggle,
|
|
|
|
gchar *path_str,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpItemTreeView *view)
|
|
|
|
{
|
2003-11-15 01:35:51 +08:00
|
|
|
gimp_item_tree_view_toggle_clicked (toggle, path_str, state, view,
|
2004-03-19 03:39:19 +08:00
|
|
|
GIMP_UNDO_ITEM_VISIBILITY);
|
2003-11-15 01:35:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* "Linked" callbacks */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_item_tree_view_linked_changed (GimpItem *item,
|
|
|
|
GimpItemTreeView *view)
|
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerView *container_view = GIMP_CONTAINER_VIEW (view);
|
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
|
|
|
GtkTreeIter *iter;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
iter = gimp_container_view_lookup (container_view,
|
|
|
|
(GimpViewable *) item);
|
2003-11-15 01:35:51 +08:00
|
|
|
|
|
|
|
if (iter)
|
2009-07-25 23:38:03 +08:00
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), iter,
|
2008-12-25 19:31:51 +08:00
|
|
|
view->priv->model_column_linked,
|
2003-11-15 01:35:51 +08:00
|
|
|
gimp_item_get_linked (item),
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_item_tree_view_chain_clicked (GtkCellRendererToggle *toggle,
|
|
|
|
gchar *path_str,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpItemTreeView *view)
|
|
|
|
{
|
|
|
|
gimp_item_tree_view_toggle_clicked (toggle, path_str, state, view,
|
2004-03-19 03:39:19 +08:00
|
|
|
GIMP_UNDO_ITEM_LINKED);
|
2003-11-15 01:35:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Utility functions used from eye_clicked and chain_clicked.
|
|
|
|
* Would make sense to do this in a generic fashion using
|
|
|
|
* properties, but for now it's better than duplicating the code.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
gimp_item_tree_view_toggle_clicked (GtkCellRendererToggle *toggle,
|
|
|
|
gchar *path_str,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpItemTreeView *view,
|
2004-03-19 03:39:19 +08:00
|
|
|
GimpUndoType undo_type)
|
2003-11-15 01:35:51 +08:00
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
2003-09-12 03:52:29 +08:00
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
2004-03-19 03:39:19 +08:00
|
|
|
GimpUndoType group_type;
|
2003-11-15 01:35:51 +08:00
|
|
|
const gchar *undo_desc;
|
2003-09-12 03:52:29 +08:00
|
|
|
|
2007-02-02 18:57:16 +08:00
|
|
|
gboolean (* getter) (const GimpItem *item);
|
|
|
|
void (* setter) (GimpItem *item,
|
|
|
|
gboolean value,
|
|
|
|
gboolean push_undo);
|
|
|
|
GimpUndo * (* pusher) (GimpImage *image,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpItem *item);
|
2003-11-15 01:35:51 +08:00
|
|
|
|
2004-03-19 03:39:19 +08:00
|
|
|
switch (undo_type)
|
2003-11-15 01:35:51 +08:00
|
|
|
{
|
2004-03-19 03:39:19 +08:00
|
|
|
case GIMP_UNDO_ITEM_VISIBILITY:
|
|
|
|
getter = gimp_item_get_visible;
|
|
|
|
setter = gimp_item_set_visible;
|
|
|
|
pusher = gimp_image_undo_push_item_visibility;
|
|
|
|
group_type = GIMP_UNDO_GROUP_ITEM_VISIBILITY;
|
|
|
|
undo_desc = _("Set Item Exclusive Visible");
|
2003-11-15 01:35:51 +08:00
|
|
|
break;
|
|
|
|
|
2004-03-19 03:39:19 +08:00
|
|
|
case GIMP_UNDO_ITEM_LINKED:
|
|
|
|
getter = gimp_item_get_linked;
|
|
|
|
setter = gimp_item_set_linked;
|
|
|
|
pusher = gimp_image_undo_push_item_linked;
|
|
|
|
group_type = GIMP_UNDO_GROUP_ITEM_LINKED;
|
|
|
|
undo_desc = _("Set Item Exclusive Linked");
|
2003-11-15 01:35:51 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2003-09-12 03:52:29 +08:00
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
|
|
|
|
{
|
2006-09-01 05:40:16 +08:00
|
|
|
GimpContext *context;
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewRenderer *renderer;
|
|
|
|
GimpItem *item;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-08-26 06:31:44 +08:00
|
|
|
gboolean active;
|
2003-09-12 03:52:29 +08:00
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
context = gimp_container_view_get_context (GIMP_CONTAINER_VIEW (view));
|
|
|
|
|
2003-09-12 03:52:29 +08:00
|
|
|
gtk_tree_model_get (tree_view->model, &iter,
|
2008-11-16 04:01:55 +08:00
|
|
|
GIMP_CONTAINER_TREE_VIEW_COLUMN_RENDERER, &renderer,
|
2003-09-12 03:52:29 +08:00
|
|
|
-1);
|
|
|
|
g_object_get (toggle,
|
|
|
|
"active", &active,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
item = GIMP_ITEM (renderer->viewable);
|
|
|
|
g_object_unref (renderer);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2003-09-12 03:52:29 +08:00
|
|
|
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
2003-11-15 01:35:51 +08:00
|
|
|
GList *on = NULL;
|
|
|
|
GList *off = NULL;
|
2003-09-12 03:52:29 +08:00
|
|
|
GList *list;
|
|
|
|
gboolean iter_valid;
|
|
|
|
|
|
|
|
for (iter_valid = gtk_tree_model_get_iter_first (tree_view->model,
|
|
|
|
&iter);
|
|
|
|
iter_valid;
|
|
|
|
iter_valid = gtk_tree_model_iter_next (tree_view->model,
|
|
|
|
&iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (tree_view->model, &iter,
|
2008-11-16 04:01:55 +08:00
|
|
|
GIMP_CONTAINER_TREE_VIEW_COLUMN_RENDERER, &renderer,
|
2003-09-12 03:52:29 +08:00
|
|
|
-1);
|
|
|
|
|
|
|
|
if ((GimpItem *) renderer->viewable != item)
|
|
|
|
{
|
2003-11-15 01:35:51 +08:00
|
|
|
if (getter (GIMP_ITEM (renderer->viewable)))
|
|
|
|
on = g_list_prepend (on, renderer->viewable);
|
2003-09-12 03:52:29 +08:00
|
|
|
else
|
2003-11-15 01:35:51 +08:00
|
|
|
off = g_list_prepend (off, renderer->viewable);
|
2003-09-12 03:52:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (renderer);
|
|
|
|
}
|
|
|
|
|
2004-03-19 03:39:19 +08:00
|
|
|
if (on || off || ! getter (item))
|
|
|
|
{
|
2004-10-17 04:17:30 +08:00
|
|
|
GimpItemTreeViewClass *view_class;
|
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
|
|
|
view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (view);
|
2004-03-19 03:39:19 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_UNDO_STACK,
|
2004-08-03 22:09:49 +08:00
|
|
|
group_type);
|
|
|
|
|
|
|
|
if (undo && (g_object_get_data (G_OBJECT (undo), "item-type") ==
|
2004-10-17 04:17:30 +08:00
|
|
|
(gpointer) view_class->item_type))
|
2004-03-19 03:39:19 +08:00
|
|
|
push_undo = FALSE;
|
|
|
|
|
|
|
|
if (push_undo)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_image_undo_group_start (image, group_type,
|
2004-03-19 03:39:19 +08:00
|
|
|
undo_desc))
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
undo = gimp_image_undo_can_compress (image,
|
2004-08-03 22:09:49 +08:00
|
|
|
GIMP_TYPE_UNDO_STACK,
|
|
|
|
group_type);
|
|
|
|
|
|
|
|
if (undo)
|
|
|
|
g_object_set_data (G_OBJECT (undo), "item-type",
|
2004-10-17 04:17:30 +08:00
|
|
|
(gpointer) view_class->item_type);
|
2004-03-19 03:39:19 +08:00
|
|
|
}
|
2004-03-19 01:01:46 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
pusher (image, NULL, item);
|
2003-09-12 03:52:29 +08:00
|
|
|
|
2004-03-19 03:39:19 +08:00
|
|
|
for (list = on; list; list = g_list_next (list))
|
2006-03-29 01:08:36 +08:00
|
|
|
pusher (image, NULL, list->data);
|
2004-03-19 03:39:19 +08:00
|
|
|
|
|
|
|
for (list = off; list; list = g_list_next (list))
|
2006-03-29 01:08:36 +08:00
|
|
|
pusher (image, NULL, list->data);
|
2004-03-19 03:39:19 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_end (image);
|
2004-03-19 03:39:19 +08:00
|
|
|
}
|
2004-03-20 07:42:42 +08:00
|
|
|
else
|
|
|
|
{
|
2006-09-01 05:40:16 +08:00
|
|
|
gimp_undo_refresh_preview (undo, context);
|
2004-03-20 07:42:42 +08:00
|
|
|
}
|
2004-03-19 03:39:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
setter (item, TRUE, FALSE);
|
2003-09-12 03:52:29 +08:00
|
|
|
|
2003-11-15 01:35:51 +08:00
|
|
|
if (on)
|
2003-09-12 03:52:29 +08:00
|
|
|
{
|
2003-11-15 01:35:51 +08:00
|
|
|
for (list = on; list; list = g_list_next (list))
|
2004-03-19 03:39:19 +08:00
|
|
|
setter (GIMP_ITEM (list->data), FALSE, FALSE);
|
2003-09-12 03:52:29 +08:00
|
|
|
}
|
2003-11-15 01:35:51 +08:00
|
|
|
else if (off)
|
2003-09-12 03:52:29 +08:00
|
|
|
{
|
2003-11-15 01:35:51 +08:00
|
|
|
for (list = off; list; list = g_list_next (list))
|
2004-03-19 03:39:19 +08:00
|
|
|
setter (GIMP_ITEM (list->data), TRUE, FALSE);
|
2003-09-12 03:52:29 +08:00
|
|
|
}
|
|
|
|
|
2003-11-15 01:35:51 +08:00
|
|
|
g_list_free (on);
|
|
|
|
g_list_free (off);
|
2003-09-12 03:52:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-03-19 01:01:46 +08:00
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
|
2004-08-03 22:09:49 +08:00
|
|
|
undo_type);
|
2004-03-19 01:01:46 +08:00
|
|
|
|
2004-08-03 22:09:49 +08:00
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == item)
|
2004-03-19 01:01:46 +08:00
|
|
|
push_undo = FALSE;
|
|
|
|
|
|
|
|
setter (item, ! active, push_undo);
|
2004-03-20 07:42:42 +08:00
|
|
|
|
|
|
|
if (!push_undo)
|
2006-09-01 05:40:16 +08:00
|
|
|
gimp_undo_refresh_preview (undo, context);
|
2003-09-12 03:52:29 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2003-09-12 03:52:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|