2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-05-03 20:26:05 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2003-03-16 19:14:29 +08:00
|
|
|
* gimpchanneltreeview.c
|
2009-08-04 01:21:51 +08:00
|
|
|
* Copyright (C) 2001-2009 Michael Natterer <mitch@gimp.org>
|
2001-05-03 20:26:05 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-05-03 20:26:05 +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-05-03 20:26:05 +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-05-03 20:26:05 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2001-05-03 20:26:05 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-01-16 03:17:11 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2004-10-16 23:48:23 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-05-03 20:26:05 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpimage.h"
|
2004-10-16 23:48:23 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2005-01-16 05:15:43 +08:00
|
|
|
#include "core/gimplayer.h"
|
|
|
|
#include "core/gimplayermask.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2009-07-18 22:59:43 +08:00
|
|
|
#include "gimpactiongroup.h"
|
2003-03-16 19:14:29 +08:00
|
|
|
#include "gimpchanneltreeview.h"
|
2003-03-13 01:12:01 +08:00
|
|
|
#include "gimpcomponenteditor.h"
|
2004-05-11 07:22:39 +08:00
|
|
|
#include "gimpcontainerview.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "gimpdnd.h"
|
2004-11-17 02:36:48 +08:00
|
|
|
#include "gimpdocked.h"
|
2003-08-24 21:52:51 +08:00
|
|
|
#include "gimphelp-ids.h"
|
2009-07-18 22:59:43 +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-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
|
2008-12-25 20:00:18 +08:00
|
|
|
struct _GimpChannelTreeViewPriv
|
|
|
|
{
|
2009-08-04 01:21:51 +08:00
|
|
|
GtkWidget *component_editor;
|
2008-12-25 20:00:18 +08:00
|
|
|
|
2009-08-04 01:21:51 +08:00
|
|
|
GtkWidget *toselection_button;
|
2008-12-25 20:00:18 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
static void gimp_channel_tree_view_view_iface_init (GimpContainerViewInterface *iface);
|
2004-05-11 07:22:39 +08:00
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void gimp_channel_tree_view_constructed (GObject *object);
|
|
|
|
|
|
|
|
static void gimp_channel_tree_view_drop_viewable (GimpContainerTreeView *view,
|
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos);
|
|
|
|
static void gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpChannelType component,
|
|
|
|
GimpViewable *dest_viewable,
|
2005-01-16 05:15:43 +08:00
|
|
|
GtkTreeViewDropPosition drop_pos);
|
2011-01-14 16:38:11 +08:00
|
|
|
static void gimp_channel_tree_view_set_image (GimpItemTreeView *item_view,
|
|
|
|
GimpImage *image);
|
|
|
|
static GimpItem * gimp_channel_tree_view_item_new (GimpImage *image);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void gimp_channel_tree_view_set_context (GimpContainerView *view,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_channel_tree_view_set_view_size (GimpContainerView *view);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-11-17 02:36:48 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpChannelTreeView, gimp_channel_tree_view,
|
|
|
|
GIMP_TYPE_DRAWABLE_TREE_VIEW,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONTAINER_VIEW,
|
2006-09-01 05:40:16 +08:00
|
|
|
gimp_channel_tree_view_view_iface_init))
|
2005-12-20 06:37:49 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_channel_tree_view_parent_class
|
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
static GimpContainerViewInterface *parent_view_iface = NULL;
|
2001-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_channel_tree_view_class_init (GimpChannelTreeViewClass *klass)
|
2001-05-03 20:26:05 +08:00
|
|
|
{
|
2005-12-20 06:37:49 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpContainerTreeViewClass *view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
|
|
|
|
GimpItemTreeViewClass *iv_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
object_class->constructed = gimp_channel_tree_view_constructed;
|
2005-12-20 06:37:49 +08:00
|
|
|
|
|
|
|
view_class->drop_viewable = gimp_channel_tree_view_drop_viewable;
|
|
|
|
view_class->drop_component = gimp_channel_tree_view_drop_component;
|
|
|
|
|
|
|
|
iv_class->set_image = gimp_channel_tree_view_set_image;
|
|
|
|
|
|
|
|
iv_class->item_type = GIMP_TYPE_CHANNEL;
|
|
|
|
iv_class->signal_name = "active-channel-changed";
|
|
|
|
|
|
|
|
iv_class->get_container = gimp_image_get_channels;
|
|
|
|
iv_class->get_active_item = (GimpGetItemFunc) gimp_image_get_active_channel;
|
|
|
|
iv_class->set_active_item = (GimpSetItemFunc) gimp_image_set_active_channel;
|
|
|
|
iv_class->add_item = (GimpAddItemFunc) gimp_image_add_channel;
|
|
|
|
iv_class->remove_item = (GimpRemoveItemFunc) gimp_image_remove_channel;
|
|
|
|
iv_class->new_item = gimp_channel_tree_view_item_new;
|
|
|
|
|
2012-11-09 18:17:25 +08:00
|
|
|
iv_class->action_group = "channels";
|
|
|
|
iv_class->activate_action = "channels-edit-attributes";
|
|
|
|
iv_class->edit_action = "channels-edit-attributes";
|
|
|
|
iv_class->new_action = "channels-new";
|
|
|
|
iv_class->new_default_action = "channels-new-last-values";
|
|
|
|
iv_class->raise_action = "channels-raise";
|
|
|
|
iv_class->raise_top_action = "channels-raise-to-top";
|
|
|
|
iv_class->lower_action = "channels-lower";
|
|
|
|
iv_class->lower_bottom_action = "channels-lower-to-bottom";
|
|
|
|
iv_class->duplicate_action = "channels-duplicate";
|
|
|
|
iv_class->delete_action = "channels-delete";
|
|
|
|
iv_class->lock_content_help_id = GIMP_HELP_CHANNEL_LOCK_PIXELS;
|
|
|
|
iv_class->lock_position_help_id = GIMP_HELP_CHANNEL_LOCK_POSITION;
|
2008-12-25 20:00:18 +08:00
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (GimpChannelTreeViewPriv));
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_view_iface_init (GimpContainerViewInterface *view_iface)
|
|
|
|
{
|
|
|
|
parent_view_iface = g_type_interface_peek_parent (view_iface);
|
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
view_iface->set_context = gimp_channel_tree_view_set_context;
|
2006-01-17 18:08:50 +08:00
|
|
|
view_iface->set_view_size = gimp_channel_tree_view_set_view_size;
|
2004-05-13 02:36:33 +08:00
|
|
|
}
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_init (GimpChannelTreeView *view)
|
|
|
|
{
|
2008-12-25 20:00:18 +08:00
|
|
|
view->priv = G_TYPE_INSTANCE_GET_PRIVATE (view,
|
|
|
|
GIMP_TYPE_CHANNEL_TREE_VIEW,
|
|
|
|
GimpChannelTreeViewPriv);
|
|
|
|
|
|
|
|
view->priv->component_editor = NULL;
|
|
|
|
view->priv->toselection_button = NULL;
|
2006-08-30 05:44:51 +08:00
|
|
|
}
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_constructed (GObject *object)
|
2004-05-13 02:36:33 +08:00
|
|
|
{
|
2011-01-14 16:38:11 +08:00
|
|
|
GimpChannelTreeView *view = GIMP_CHANNEL_TREE_VIEW (object);
|
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (object);
|
2011-10-06 01:25:29 +08:00
|
|
|
GdkModifierType extend_mask;
|
|
|
|
GdkModifierType modify_mask;
|
2004-05-13 02:36:33 +08:00
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2005-01-16 03:17:11 +08:00
|
|
|
|
2011-10-06 01:25:29 +08:00
|
|
|
extend_mask = gtk_widget_get_modifier_mask (GTK_WIDGET (object),
|
|
|
|
GDK_MODIFIER_INTENT_EXTEND_SELECTION);
|
|
|
|
modify_mask = gtk_widget_get_modifier_mask (GTK_WIDGET (object),
|
|
|
|
GDK_MODIFIER_INTENT_MODIFY_SELECTION);
|
|
|
|
|
2005-01-16 05:15:43 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_LAYER,
|
|
|
|
NULL, tree_view);
|
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (tree_view->view), GIMP_TYPE_LAYER_MASK,
|
|
|
|
NULL, tree_view);
|
2005-01-16 03:17:11 +08:00
|
|
|
gimp_dnd_component_dest_add (GTK_WIDGET (tree_view->view),
|
|
|
|
NULL, tree_view);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2008-12-25 20:00:18 +08:00
|
|
|
view->priv->toselection_button =
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (view), "channels",
|
|
|
|
"channels-selection-replace",
|
|
|
|
"channels-selection-add",
|
2011-10-06 01:25:29 +08:00
|
|
|
extend_mask,
|
2004-10-17 01:10:04 +08:00
|
|
|
"channels-selection-subtract",
|
2011-10-06 01:25:29 +08:00
|
|
|
modify_mask,
|
2004-10-17 01:10:04 +08:00
|
|
|
"channels-selection-intersect",
|
2011-10-06 01:25:29 +08:00
|
|
|
extend_mask | modify_mask,
|
2004-05-13 02:36:33 +08:00
|
|
|
NULL);
|
2003-03-13 01:12:01 +08:00
|
|
|
gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (view),
|
2008-12-25 20:00:18 +08:00
|
|
|
GTK_BUTTON (view->priv->toselection_button),
|
2006-04-12 20:49:29 +08:00
|
|
|
GIMP_TYPE_CHANNEL);
|
2011-04-10 01:51:51 +08:00
|
|
|
gtk_box_reorder_child (gimp_editor_get_button_box (GIMP_EDITOR (view)),
|
2008-12-25 20:00:18 +08:00
|
|
|
view->priv->toselection_button, 5);
|
2004-05-11 07:22:39 +08:00
|
|
|
}
|
|
|
|
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2005-01-16 03:17:11 +08:00
|
|
|
/* GimpContainerTreeView methods */
|
|
|
|
|
2005-01-16 05:15:43 +08:00
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
|
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos)
|
|
|
|
{
|
2005-01-17 23:28:08 +08:00
|
|
|
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
2009-08-04 01:21:51 +08:00
|
|
|
GimpImage *image = gimp_item_tree_view_get_image (item_view);
|
2005-01-16 05:15:43 +08:00
|
|
|
GimpItemTreeViewClass *item_view_class;
|
|
|
|
|
|
|
|
item_view_class = GIMP_ITEM_TREE_VIEW_GET_CLASS (item_view);
|
|
|
|
|
2005-01-17 23:28:08 +08:00
|
|
|
if (GIMP_IS_DRAWABLE (src_viewable) &&
|
2009-08-04 01:21:51 +08:00
|
|
|
(image != gimp_item_get_image (GIMP_ITEM (src_viewable)) ||
|
2005-01-17 23:28:08 +08:00
|
|
|
G_TYPE_FROM_INSTANCE (src_viewable) != item_view_class->item_type))
|
2005-01-16 05:15:43 +08:00
|
|
|
{
|
|
|
|
GimpItem *new_item;
|
2009-08-04 01:21:51 +08:00
|
|
|
GimpItem *parent;
|
|
|
|
gint index;
|
2005-01-16 05:15:43 +08:00
|
|
|
|
2009-08-04 01:21:51 +08:00
|
|
|
index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable,
|
|
|
|
drop_pos,
|
|
|
|
(GimpViewable **) &parent);
|
2005-01-16 05:15:43 +08:00
|
|
|
|
|
|
|
new_item = gimp_item_convert (GIMP_ITEM (src_viewable),
|
2008-12-25 19:31:51 +08:00
|
|
|
gimp_item_tree_view_get_image (item_view),
|
2008-01-08 19:46:15 +08:00
|
|
|
item_view_class->item_type);
|
2005-01-16 05:15:43 +08:00
|
|
|
|
2007-06-02 19:45:54 +08:00
|
|
|
gimp_item_set_linked (new_item, FALSE, FALSE);
|
|
|
|
|
2009-08-04 01:21:51 +08:00
|
|
|
item_view_class->add_item (image, new_item, parent, index, TRUE);
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
2005-01-17 23:28:08 +08:00
|
|
|
return;
|
2005-01-16 05:15:43 +08:00
|
|
|
}
|
2005-01-17 23:28:08 +08:00
|
|
|
|
|
|
|
GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (tree_view,
|
|
|
|
src_viewable,
|
|
|
|
dest_viewable,
|
|
|
|
drop_pos);
|
2005-01-16 05:15:43 +08:00
|
|
|
}
|
|
|
|
|
2005-01-16 03:17:11 +08:00
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view,
|
|
|
|
GimpImage *src_image,
|
|
|
|
GimpChannelType component,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos)
|
|
|
|
{
|
2005-01-17 23:28:08 +08:00
|
|
|
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view);
|
2009-08-04 01:21:51 +08:00
|
|
|
GimpImage *image = gimp_item_tree_view_get_image (item_view);
|
2005-01-17 23:28:08 +08:00
|
|
|
GimpItem *new_item;
|
2009-08-04 01:21:51 +08:00
|
|
|
GimpChannel *parent;
|
|
|
|
gint index;
|
2005-01-16 03:17:11 +08:00
|
|
|
const gchar *desc;
|
|
|
|
gchar *name;
|
|
|
|
|
2009-08-04 01:21:51 +08:00
|
|
|
index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable,
|
|
|
|
drop_pos,
|
|
|
|
(GimpViewable **) &parent);
|
2005-01-16 03:17:11 +08:00
|
|
|
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,
|
|
|
|
NULL, NULL, &desc, NULL);
|
|
|
|
name = g_strdup_printf (_("%s Channel Copy"), desc);
|
|
|
|
|
2005-01-17 23:28:08 +08:00
|
|
|
new_item = GIMP_ITEM (gimp_channel_new_from_component (src_image, component,
|
|
|
|
name, NULL));
|
2005-01-16 03:17:11 +08:00
|
|
|
|
|
|
|
/* copied components are invisible by default so subsequent copies
|
|
|
|
* of components don't affect each other
|
|
|
|
*/
|
2005-01-17 23:28:08 +08:00
|
|
|
gimp_item_set_visible (new_item, FALSE, FALSE);
|
2005-01-16 03:17:11 +08:00
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
|
2009-08-04 01:21:51 +08:00
|
|
|
if (src_image != image)
|
2015-08-16 21:47:43 +08:00
|
|
|
GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, image,
|
|
|
|
GIMP_TYPE_CHANNEL);
|
2009-08-04 01:21:51 +08:00
|
|
|
|
|
|
|
gimp_image_add_channel (image, GIMP_CHANNEL (new_item), parent, index, TRUE);
|
2005-01-16 03:17:11 +08:00
|
|
|
|
2009-08-04 01:21:51 +08:00
|
|
|
gimp_image_flush (image);
|
2005-01-16 03:17:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
/* GimpItemTreeView methods */
|
2001-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_channel_tree_view_set_image (GimpItemTreeView *item_view,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpImage *image)
|
2001-05-03 20:26:05 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpChannelTreeView *channel_view = GIMP_CHANNEL_TREE_VIEW (item_view);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2008-12-25 20:00:18 +08:00
|
|
|
if (! channel_view->priv->component_editor)
|
2001-05-03 20:26:05 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerView *view = GIMP_CONTAINER_VIEW (item_view);
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size = gimp_container_view_get_view_size (view, NULL);
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2008-12-25 20:00:18 +08:00
|
|
|
channel_view->priv->component_editor =
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_component_editor_new (view_size,
|
2011-04-10 01:51:51 +08:00
|
|
|
gimp_editor_get_menu_factory (GIMP_EDITOR (item_view)));
|
2008-12-25 20:00:18 +08:00
|
|
|
gimp_docked_set_context (GIMP_DOCKED (channel_view->priv->component_editor),
|
2006-09-01 05:40:16 +08:00
|
|
|
gimp_container_view_get_context (view));
|
2008-12-25 20:00:18 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (item_view), channel_view->priv->component_editor,
|
2003-03-13 01:12:01 +08:00
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (item_view),
|
2008-12-25 20:00:18 +08:00
|
|
|
channel_view->priv->component_editor, 0);
|
2003-03-13 01:12:01 +08:00
|
|
|
}
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! image)
|
2008-12-25 20:00:18 +08:00
|
|
|
gtk_widget_hide (channel_view->priv->component_editor);
|
2001-05-07 00:14:34 +08:00
|
|
|
|
2008-12-25 20:00:18 +08:00
|
|
|
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (channel_view->priv->component_editor),
|
2006-03-29 01:08:36 +08:00
|
|
|
image);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_CLASS (parent_class)->set_image (item_view, image);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2008-12-25 19:31:51 +08:00
|
|
|
if (gimp_item_tree_view_get_image (item_view))
|
2008-12-25 20:00:18 +08:00
|
|
|
gtk_widget_show (channel_view->priv->component_editor);
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
static GimpItem *
|
|
|
|
gimp_channel_tree_view_item_new (GimpImage *image)
|
|
|
|
{
|
|
|
|
GimpChannel *new_channel;
|
|
|
|
GimpRGB color;
|
|
|
|
|
|
|
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.5);
|
|
|
|
|
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
|
|
|
|
_("New Channel"));
|
|
|
|
|
|
|
|
new_channel = gimp_channel_new (image,
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
gimp_image_get_height (image),
|
2010-02-08 02:39:48 +08:00
|
|
|
_("Channel"), &color);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2009-08-04 04:30:36 +08:00
|
|
|
gimp_image_add_channel (image, new_channel,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
|
|
|
return GIMP_ITEM (new_channel);
|
|
|
|
}
|
|
|
|
|
2001-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
/* GimpContainerView methods */
|
|
|
|
|
2001-05-07 01:56:10 +08:00
|
|
|
static void
|
2006-09-01 05:40:16 +08:00
|
|
|
gimp_channel_tree_view_set_context (GimpContainerView *view,
|
|
|
|
GimpContext *context)
|
2001-05-07 01:56:10 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpChannelTreeView *channel_view = GIMP_CHANNEL_TREE_VIEW (view);
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
parent_view_iface->set_context (view, context);
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2008-12-25 20:00:18 +08:00
|
|
|
if (channel_view->priv->component_editor)
|
|
|
|
gimp_docked_set_context (GIMP_DOCKED (channel_view->priv->component_editor),
|
2006-09-01 05:40:16 +08:00
|
|
|
context);
|
2001-05-07 01:56:10 +08:00
|
|
|
}
|
2004-11-17 02:36:48 +08:00
|
|
|
|
|
|
|
static void
|
2006-09-01 05:40:16 +08:00
|
|
|
gimp_channel_tree_view_set_view_size (GimpContainerView *view)
|
2004-11-17 02:36:48 +08:00
|
|
|
{
|
2006-09-01 05:40:16 +08:00
|
|
|
GimpChannelTreeView *channel_view = GIMP_CHANNEL_TREE_VIEW (view);
|
|
|
|
gint view_size;
|
2004-11-17 02:36:48 +08:00
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
parent_view_iface->set_view_size (view);
|
|
|
|
|
|
|
|
view_size = gimp_container_view_get_view_size (view, NULL);
|
2004-11-17 02:36:48 +08:00
|
|
|
|
2008-12-25 20:00:18 +08:00
|
|
|
if (channel_view->priv->component_editor)
|
|
|
|
gimp_component_editor_set_view_size (GIMP_COMPONENT_EDITOR (channel_view->priv->component_editor),
|
2006-09-01 05:40:16 +08:00
|
|
|
view_size);
|
2004-11-17 02:36:48 +08:00
|
|
|
}
|