2001-05-03 20:26:05 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2003-03-16 19:14:29 +08:00
|
|
|
* gimpchanneltreeview.c
|
2004-05-13 02:36:33 +08:00
|
|
|
* Copyright (C) 2001-2004 Michael Natterer <mitch@gimp.org>
|
2001-05-03 20:26:05 +08:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
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"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
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"
|
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
|
|
|
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_channel_tree_view_class_init (GimpChannelTreeViewClass *klass);
|
|
|
|
static void gimp_channel_tree_view_init (GimpChannelTreeView *view);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-11-17 02:36:48 +08:00
|
|
|
static void gimp_channel_tree_view_view_iface_init (GimpContainerViewInterface *view_iface);
|
|
|
|
static void gimp_channel_tree_view_docked_iface_init (GimpDockedInterface *docked_iface);
|
2004-05-11 07:22:39 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
static GObject * gimp_channel_tree_view_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
2005-01-16 03:17:11 +08:00
|
|
|
static void gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view,
|
|
|
|
GimpImage *gimage,
|
|
|
|
GimpChannelType component,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos);
|
2004-05-13 02:36:33 +08:00
|
|
|
static void gimp_channel_tree_view_set_image (GimpItemTreeView *item_view,
|
|
|
|
GimpImage *gimage);
|
2004-10-16 23:48:23 +08:00
|
|
|
static GimpItem * gimp_channel_tree_view_item_new (GimpImage *image);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_channel_tree_view_set_preview_size (GimpContainerView *view);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-11-17 02:36:48 +08:00
|
|
|
static void gimp_channel_tree_view_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-11-17 02:36:48 +08:00
|
|
|
|
|
|
|
static GimpDrawableTreeViewClass *parent_class = NULL;
|
|
|
|
static GimpContainerViewInterface *parent_view_iface = NULL;
|
|
|
|
static GimpDockedInterface *parent_docked_iface = NULL;
|
2001-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
GType
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_channel_tree_view_get_type (void)
|
2001-05-03 20:26:05 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
static GType view_type = 0;
|
2001-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
if (! view_type)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
static const GTypeInfo view_info =
|
2001-05-03 20:26:05 +08:00
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
sizeof (GimpChannelTreeViewClass),
|
2001-10-17 19:33:43 +08:00
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
2003-03-16 19:14:29 +08:00
|
|
|
(GClassInitFunc) gimp_channel_tree_view_class_init,
|
2001-10-17 19:33:43 +08:00
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
2003-03-16 19:14:29 +08:00
|
|
|
sizeof (GimpChannelTreeView),
|
2001-10-17 19:33:43 +08:00
|
|
|
0, /* n_preallocs */
|
2003-03-16 19:14:29 +08:00
|
|
|
(GInstanceInitFunc) gimp_channel_tree_view_init,
|
2001-05-03 20:26:05 +08:00
|
|
|
};
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
static const GInterfaceInfo view_iface_info =
|
|
|
|
{
|
|
|
|
(GInterfaceInitFunc) gimp_channel_tree_view_view_iface_init,
|
|
|
|
NULL, /* iface_finalize */
|
|
|
|
NULL /* iface_data */
|
|
|
|
};
|
2004-11-17 02:36:48 +08:00
|
|
|
static const GInterfaceInfo docked_iface_info =
|
|
|
|
{
|
|
|
|
(GInterfaceInitFunc) gimp_channel_tree_view_docked_iface_init,
|
|
|
|
NULL, /* iface_finalize */
|
|
|
|
NULL /* iface_data */
|
|
|
|
};
|
2004-05-11 07:22:39 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
view_type = g_type_register_static (GIMP_TYPE_DRAWABLE_TREE_VIEW,
|
|
|
|
"GimpChannelTreeView",
|
2001-10-17 19:33:43 +08:00
|
|
|
&view_info, 0);
|
2004-05-11 07:22:39 +08:00
|
|
|
|
|
|
|
g_type_add_interface_static (view_type, GIMP_TYPE_CONTAINER_VIEW,
|
|
|
|
&view_iface_info);
|
2004-11-17 02:36:48 +08:00
|
|
|
g_type_add_interface_static (view_type, GIMP_TYPE_DOCKED,
|
|
|
|
&docked_iface_info);
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return view_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01-16 03:17:11 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GimpContainerTreeViewClass *view_class;
|
|
|
|
GimpItemTreeViewClass *item_view_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
|
|
|
|
item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
object_class->constructor = gimp_channel_tree_view_constructor;
|
|
|
|
|
2005-01-16 03:17:11 +08:00
|
|
|
view_class->drop_component = gimp_channel_tree_view_drop_component;
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
item_view_class->set_image = gimp_channel_tree_view_set_image;
|
2003-02-17 21:33:29 +08:00
|
|
|
|
2004-10-17 04:17:30 +08:00
|
|
|
item_view_class->item_type = GIMP_TYPE_CHANNEL;
|
|
|
|
item_view_class->signal_name = "active-channel-changed";
|
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
item_view_class->get_container = gimp_image_get_channels;
|
|
|
|
item_view_class->get_active_item = (GimpGetItemFunc) gimp_image_get_active_channel;
|
|
|
|
item_view_class->set_active_item = (GimpSetItemFunc) gimp_image_set_active_channel;
|
|
|
|
item_view_class->reorder_item = (GimpReorderItemFunc) gimp_image_position_channel;
|
|
|
|
item_view_class->add_item = (GimpAddItemFunc) gimp_image_add_channel;
|
|
|
|
item_view_class->remove_item = (GimpRemoveItemFunc) gimp_image_remove_channel;
|
2004-10-16 23:48:23 +08:00
|
|
|
item_view_class->new_item = gimp_channel_tree_view_item_new;
|
|
|
|
|
|
|
|
item_view_class->action_group = "channels";
|
|
|
|
item_view_class->activate_action = "channels-edit-attributes";
|
|
|
|
item_view_class->edit_action = "channels-edit-attributes";
|
|
|
|
item_view_class->new_action = "channels-new";
|
2004-10-23 08:53:48 +08:00
|
|
|
item_view_class->new_default_action = "channels-new-last-values";
|
2004-10-16 23:48:23 +08:00
|
|
|
item_view_class->raise_action = "channels-raise";
|
|
|
|
item_view_class->raise_top_action = "channels-raise-to-top";
|
|
|
|
item_view_class->lower_action = "channels-lower";
|
|
|
|
item_view_class->lower_bottom_action = "channels-lower-to-bottom";
|
|
|
|
item_view_class->duplicate_action = "channels-duplicate";
|
|
|
|
item_view_class->delete_action = "channels-delete";
|
|
|
|
item_view_class->reorder_desc = _("Reorder Channel");
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_channel_tree_view_init (GimpChannelTreeView *view)
|
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);
|
|
|
|
|
|
|
|
view_iface->set_preview_size = gimp_channel_tree_view_set_preview_size;
|
|
|
|
}
|
|
|
|
|
2004-11-17 02:36:48 +08:00
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_docked_iface_init (GimpDockedInterface *docked_iface)
|
|
|
|
{
|
|
|
|
parent_docked_iface = g_type_interface_peek_parent (docked_iface);
|
|
|
|
|
|
|
|
docked_iface->set_context = gimp_channel_tree_view_set_context;
|
|
|
|
}
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_channel_tree_view_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
2005-01-16 03:17:11 +08:00
|
|
|
GObject *object;
|
|
|
|
GimpEditor *editor;
|
|
|
|
GimpChannelTreeView *view;
|
|
|
|
GimpContainerTreeView *tree_view;
|
2004-05-13 02:36:33 +08:00
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
2005-01-16 03:17:11 +08:00
|
|
|
editor = GIMP_EDITOR (object);
|
|
|
|
view = GIMP_CHANNEL_TREE_VIEW (object);
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
|
|
|
|
|
|
|
|
gimp_dnd_component_dest_add (GTK_WIDGET (tree_view->view),
|
|
|
|
NULL, tree_view);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
view->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",
|
|
|
|
GDK_SHIFT_MASK,
|
2004-10-17 01:10:04 +08:00
|
|
|
"channels-selection-subtract",
|
|
|
|
GDK_CONTROL_MASK,
|
|
|
|
"channels-selection-intersect",
|
|
|
|
GDK_SHIFT_MASK | GDK_CONTROL_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),
|
2001-08-05 04:38:54 +08:00
|
|
|
GTK_BUTTON (view->toselection_button),
|
|
|
|
GIMP_TYPE_CHANNEL);
|
2004-10-17 01:10:04 +08:00
|
|
|
gtk_box_reorder_child (GTK_BOX (GIMP_EDITOR (view)->button_box),
|
|
|
|
view->toselection_button, 5);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
return object;
|
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 */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view,
|
|
|
|
GimpImage *src_image,
|
|
|
|
GimpChannelType component,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos)
|
|
|
|
{
|
|
|
|
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (tree_view);
|
|
|
|
GimpImage *dest_image = view->gimage;
|
|
|
|
GimpChannel *new_channel;
|
|
|
|
gint index;
|
|
|
|
const gchar *desc;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
index = gimp_image_get_channel_index (dest_image,
|
|
|
|
GIMP_CHANNEL (dest_viewable));
|
|
|
|
|
|
|
|
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
|
|
|
index++;
|
|
|
|
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,
|
|
|
|
NULL, NULL, &desc, NULL);
|
|
|
|
name = g_strdup_printf (_("%s Channel Copy"), desc);
|
|
|
|
|
|
|
|
new_channel = gimp_channel_new_from_component (src_image, component,
|
|
|
|
name, NULL);
|
|
|
|
|
|
|
|
/* copied components are invisible by default so subsequent copies
|
|
|
|
* of components don't affect each other
|
|
|
|
*/
|
|
|
|
gimp_item_set_visible (GIMP_ITEM (new_channel), FALSE, FALSE);
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
if (src_image != dest_image)
|
|
|
|
{
|
|
|
|
GimpItem *item = GIMP_ITEM (new_channel);
|
|
|
|
gint width = gimp_image_get_width (dest_image);
|
|
|
|
gint height = gimp_image_get_height (dest_image);
|
|
|
|
|
|
|
|
GIMP_ITEM_GET_CLASS (new_channel)->convert (item, dest_image);
|
|
|
|
|
|
|
|
if (gimp_item_width (item) != width ||
|
|
|
|
gimp_item_height (item) != height)
|
|
|
|
{
|
|
|
|
gimp_item_resize (item, view->context, width, height, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_add_channel (dest_image, new_channel, index);
|
|
|
|
gimp_image_flush (dest_image);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpImage *gimage)
|
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
|
|
|
|
2003-03-13 01:12:01 +08:00
|
|
|
if (! channel_view->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);
|
|
|
|
gint preview_size;
|
|
|
|
|
|
|
|
preview_size = gimp_container_view_get_preview_size (view, NULL);
|
|
|
|
|
2003-03-13 01:12:01 +08:00
|
|
|
channel_view->component_editor =
|
2004-05-11 01:16:50 +08:00
|
|
|
gimp_component_editor_new (preview_size,
|
2003-03-21 19:47:37 +08:00
|
|
|
GIMP_EDITOR (item_view)->menu_factory);
|
2004-11-17 02:36:48 +08:00
|
|
|
gimp_docked_set_context (GIMP_DOCKED (channel_view->component_editor),
|
|
|
|
item_view->context);
|
2003-03-13 01:12:01 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (item_view), channel_view->component_editor,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (item_view),
|
|
|
|
channel_view->component_editor, 0);
|
|
|
|
}
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2003-03-13 01:12:01 +08:00
|
|
|
if (! gimage)
|
|
|
|
gtk_widget_hide (channel_view->component_editor);
|
2001-05-07 00:14:34 +08:00
|
|
|
|
2003-03-13 01:12:01 +08:00
|
|
|
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (channel_view->component_editor),
|
|
|
|
gimage);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_CLASS (parent_class)->set_image (item_view, gimage);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
if (item_view->gimage)
|
2003-03-13 01:12:01 +08:00
|
|
|
gtk_widget_show (channel_view->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),
|
|
|
|
_("Empty Channel"), &color);
|
|
|
|
|
|
|
|
gimp_image_add_channel (image, new_channel, -1);
|
|
|
|
|
|
|
|
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
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_channel_tree_view_set_preview_size (GimpContainerView *view)
|
2001-05-07 01:56:10 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpChannelTreeView *channel_view = GIMP_CHANNEL_TREE_VIEW (view);
|
|
|
|
gint preview_size;
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
parent_view_iface->set_preview_size (view);
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
preview_size = gimp_container_view_get_preview_size (view, NULL);
|
2001-05-07 01:56:10 +08:00
|
|
|
|
2003-03-27 01:49:42 +08:00
|
|
|
if (channel_view->component_editor)
|
|
|
|
gimp_component_editor_set_preview_size (GIMP_COMPONENT_EDITOR (channel_view->component_editor),
|
2004-05-11 01:16:50 +08:00
|
|
|
preview_size);
|
2001-05-07 01:56:10 +08:00
|
|
|
}
|
2004-11-17 02:36:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* GimpDocked methods */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_channel_tree_view_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpChannelTreeView *channel_view = GIMP_CHANNEL_TREE_VIEW (docked);
|
|
|
|
|
|
|
|
parent_docked_iface->set_context (docked, context);
|
|
|
|
|
|
|
|
if (channel_view->component_editor)
|
|
|
|
gimp_docked_set_context (GIMP_DOCKED (channel_view->component_editor),
|
|
|
|
context);
|
|
|
|
}
|