2001-03-12 01:24:47 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2003-03-16 19:14:29 +08:00
|
|
|
* gimplayertreeview.c
|
|
|
|
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
|
2001-04-22 08:38:56 +08:00
|
|
|
*
|
2001-03-12 01:24:47 +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>
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-03-12 01:24:47 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimplayer.h"
|
2003-03-16 19:14:29 +08:00
|
|
|
#include "core/gimplayermask.h"
|
2003-02-17 21:33:29 +08:00
|
|
|
#include "core/gimplayer-floating-sel.h"
|
2003-09-07 05:17:16 +08:00
|
|
|
#include "core/gimplist.h"
|
2002-05-09 01:48:24 +08:00
|
|
|
#include "core/gimpimage.h"
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
#include "core/gimpitemundo.h"
|
|
|
|
#include "core/gimpundostack.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
#include "gimpcellrenderertoggle.h"
|
|
|
|
#include "gimpcellrendererviewable.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "gimpdnd.h"
|
2003-08-24 21:52:51 +08:00
|
|
|
#include "gimphelp-ids.h"
|
2003-03-16 19:14:29 +08:00
|
|
|
#include "gimplayertreeview.h"
|
|
|
|
#include "gimppreviewrenderer.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
#include "gimpwidgets-constructors.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_layer_tree_view_class_init (GimpLayerTreeViewClass *klass);
|
|
|
|
static void gimp_layer_tree_view_init (GimpLayerTreeView *view);
|
|
|
|
|
|
|
|
static GObject * gimp_layer_tree_view_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
2003-09-07 05:17:16 +08:00
|
|
|
static void gimp_layer_tree_view_finalize (GObject *object);
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_layer_tree_view_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style);
|
|
|
|
|
|
|
|
static void gimp_layer_tree_view_set_container (GimpContainerView *view,
|
|
|
|
GimpContainer *container);
|
|
|
|
static gpointer gimp_layer_tree_view_insert_item (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint index);
|
2003-05-18 21:28:27 +08:00
|
|
|
static gboolean gimp_layer_tree_view_select_item (GimpContainerView *view,
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data);
|
2003-05-21 19:34:00 +08:00
|
|
|
static void gimp_layer_tree_view_set_preview_size (GimpContainerView *view);
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-05-21 19:34:00 +08:00
|
|
|
static gboolean gimp_layer_tree_view_drop_possible(GimpContainerTreeView *view,
|
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos,
|
|
|
|
GdkDragAction *drag_action);
|
2003-03-19 23:17:13 +08:00
|
|
|
|
2003-09-07 05:17:16 +08:00
|
|
|
static void gimp_layer_tree_view_set_image (GimpItemTreeView *view,
|
|
|
|
GimpImage *gimage);
|
2003-03-16 21:19:43 +08:00
|
|
|
static void gimp_layer_tree_view_remove_item (GimpImage *gimage,
|
|
|
|
GimpItem *layer);
|
|
|
|
|
2003-09-07 05:17:16 +08:00
|
|
|
static void gimp_layer_tree_view_floating_selection_changed
|
|
|
|
(GimpImage *gimage,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_layer_tree_view_anchor_clicked (GtkWidget *widget,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
|
|
|
|
static void gimp_layer_tree_view_paint_mode_menu_callback
|
|
|
|
(GtkWidget *widget,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
static void gimp_layer_tree_view_preserve_button_toggled
|
|
|
|
(GtkWidget *widget,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
static void gimp_layer_tree_view_opacity_scale_changed
|
|
|
|
(GtkAdjustment *adj,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
|
|
|
|
static void gimp_layer_tree_view_layer_signal_handler
|
|
|
|
(GimpLayer *layer,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
static void gimp_layer_tree_view_update_options (GimpLayerTreeView *view,
|
|
|
|
GimpLayer *layer);
|
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
static void gimp_layer_tree_view_mask_update (GimpLayerTreeView *view,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GimpLayer *layer);
|
2003-03-16 19:14:29 +08:00
|
|
|
static void gimp_layer_tree_view_mask_changed (GimpLayer *layer,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
static void gimp_layer_tree_view_renderer_update(GimpPreviewRenderer *renderer,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
|
|
|
|
static void gimp_layer_tree_view_update_borders (GimpLayerTreeView *view,
|
|
|
|
GtkTreeIter *iter);
|
2003-03-16 21:19:43 +08:00
|
|
|
static void gimp_layer_tree_view_mask_callback (GimpLayerMask *mask,
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpLayerTreeView *view);
|
|
|
|
static void gimp_layer_tree_view_layer_clicked (GimpCellRendererViewable *cell,
|
|
|
|
const gchar *path,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
static void gimp_layer_tree_view_mask_clicked (GimpCellRendererViewable *cell,
|
|
|
|
const gchar *path,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
|
2003-05-21 19:34:00 +08:00
|
|
|
static void gimp_layer_tree_view_alpha_update (GimpLayerTreeView *view,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GimpLayer *layer);
|
|
|
|
static void gimp_layer_tree_view_alpha_changed (GimpLayer *layer,
|
|
|
|
GimpLayerTreeView *view);
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
static GimpDrawableTreeViewClass *parent_class = NULL;
|
|
|
|
|
|
|
|
static GimpRGB black_color;
|
|
|
|
static GimpRGB white_color;
|
|
|
|
static GimpRGB green_color;
|
|
|
|
static GimpRGB red_color;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
GType
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_get_type (void)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2001-08-05 04:38:54 +08:00
|
|
|
static GType view_type = 0;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
if (! view_type)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
static const GTypeInfo view_info =
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
sizeof (GimpLayerTreeViewClass),
|
2001-10-17 19:33:43 +08:00
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
2003-03-16 19:14:29 +08:00
|
|
|
(GClassInitFunc) gimp_layer_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 (GimpLayerTreeView),
|
2001-10-17 19:33:43 +08:00
|
|
|
0, /* n_preallocs */
|
2003-03-16 19:14:29 +08:00
|
|
|
(GInstanceInitFunc) gimp_layer_tree_view_init,
|
2001-03-12 01:24:47 +08:00
|
|
|
};
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
view_type = g_type_register_static (GIMP_TYPE_DRAWABLE_TREE_VIEW,
|
|
|
|
"GimpLayerTreeView",
|
2001-10-17 19:33:43 +08:00
|
|
|
&view_info, 0);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return view_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_class_init (GimpLayerTreeViewClass *klass)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-03-19 23:17:13 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
GimpContainerViewClass *container_view_class;
|
|
|
|
GimpContainerTreeViewClass *tree_view_class;
|
|
|
|
GimpItemTreeViewClass *item_view_class;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2001-10-13 20:52:30 +08:00
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
container_view_class = GIMP_CONTAINER_VIEW_CLASS (klass);
|
2003-03-19 23:17:13 +08:00
|
|
|
tree_view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
|
2003-03-16 19:14:29 +08:00
|
|
|
item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
object_class->constructor = gimp_layer_tree_view_constructor;
|
2003-09-07 05:17:16 +08:00
|
|
|
object_class->finalize = gimp_layer_tree_view_finalize;
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
widget_class->style_set = gimp_layer_tree_view_style_set;
|
2001-08-05 04:38:54 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
container_view_class->set_container = gimp_layer_tree_view_set_container;
|
|
|
|
container_view_class->insert_item = gimp_layer_tree_view_insert_item;
|
|
|
|
container_view_class->select_item = gimp_layer_tree_view_select_item;
|
|
|
|
container_view_class->set_preview_size = gimp_layer_tree_view_set_preview_size;
|
2003-02-17 21:33:29 +08:00
|
|
|
|
2003-03-19 23:17:13 +08:00
|
|
|
tree_view_class->drop_possible = gimp_layer_tree_view_drop_possible;
|
|
|
|
|
2003-09-07 05:17:16 +08:00
|
|
|
item_view_class->set_image = gimp_layer_tree_view_set_image;
|
2003-02-17 21:33:29 +08:00
|
|
|
item_view_class->get_container = gimp_image_get_layers;
|
|
|
|
item_view_class->get_active_item = (GimpGetItemFunc) gimp_image_get_active_layer;
|
|
|
|
item_view_class->set_active_item = (GimpSetItemFunc) gimp_image_set_active_layer;
|
|
|
|
item_view_class->reorder_item = (GimpReorderItemFunc) gimp_image_position_layer;
|
|
|
|
item_view_class->add_item = (GimpAddItemFunc) gimp_image_add_layer;
|
2003-03-16 21:19:43 +08:00
|
|
|
item_view_class->remove_item = gimp_layer_tree_view_remove_item;
|
2003-02-17 21:33:29 +08:00
|
|
|
|
2003-09-18 06:54:48 +08:00
|
|
|
item_view_class->edit_desc = _("Edit Layer Attributes");
|
|
|
|
item_view_class->edit_help_id = GIMP_HELP_LAYER_EDIT;
|
2003-08-24 21:52:51 +08:00
|
|
|
item_view_class->new_desc = _("New Layer");
|
|
|
|
item_view_class->new_help_id = GIMP_HELP_LAYER_NEW;
|
|
|
|
item_view_class->duplicate_desc = _("Duplicate Layer");
|
|
|
|
item_view_class->duplicate_help_id = GIMP_HELP_LAYER_DUPLICATE;
|
|
|
|
item_view_class->delete_desc = _("Delete Layer");
|
|
|
|
item_view_class->delete_help_id = GIMP_HELP_LAYER_DELETE;
|
|
|
|
item_view_class->raise_desc = _("Raise Layer");
|
|
|
|
item_view_class->raise_help_id = GIMP_HELP_LAYER_RAISE;
|
|
|
|
item_view_class->raise_to_top_desc = _("Raise Layer to Top");
|
|
|
|
item_view_class->raise_to_top_help_id = GIMP_HELP_LAYER_RAISE_TO_TOP;
|
|
|
|
item_view_class->lower_desc = _("Lower Layer");
|
|
|
|
item_view_class->lower_help_id = GIMP_HELP_LAYER_LOWER;
|
|
|
|
item_view_class->lower_to_bottom_desc = _("Lower Layer to Bottom");
|
|
|
|
item_view_class->lower_to_bottom_help_id = GIMP_HELP_LAYER_LOWER_TO_BOTTOM;
|
|
|
|
item_view_class->reorder_desc = _("Reorder Layer");
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
gimp_rgba_set (&black_color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
|
|
|
gimp_rgba_set (&white_color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
|
|
|
gimp_rgba_set (&green_color, 0.0, 1.0, 0.0, GIMP_OPACITY_OPAQUE);
|
|
|
|
gimp_rgba_set (&red_color, 1.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_init (GimpLayerTreeView *view)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpDrawableTreeView *drawable_view;
|
|
|
|
GtkWidget *hbox;
|
2003-09-12 02:48:00 +08:00
|
|
|
GtkWidget *toggle;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkIconSize icon_size;
|
2003-09-07 05:17:16 +08:00
|
|
|
PangoAttribute *attr;
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
|
|
|
drawable_view = GIMP_DRAWABLE_TREE_VIEW (view);
|
|
|
|
|
|
|
|
view->model_column_mask = tree_view->n_model_columns;
|
|
|
|
tree_view->model_columns[tree_view->n_model_columns++] = GIMP_TYPE_PREVIEW_RENDERER;
|
|
|
|
|
|
|
|
view->model_column_mask_visible = tree_view->n_model_columns;
|
|
|
|
tree_view->model_columns[tree_view->n_model_columns++] = G_TYPE_BOOLEAN;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2002-03-09 02:30:40 +08:00
|
|
|
view->options_box = gtk_table_new (2, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (view->options_box), 2);
|
2001-03-12 01:24:47 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (view), view->options_box, FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (view), view->options_box, 0);
|
|
|
|
gtk_widget_show (view->options_box);
|
|
|
|
|
2003-09-24 02:39:02 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
/* Paint mode menu */
|
|
|
|
|
|
|
|
view->paint_mode_menu =
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_paint_mode_menu_new (G_CALLBACK (gimp_layer_tree_view_paint_mode_menu_callback),
|
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
|
|
|
view,
|
|
|
|
FALSE,
|
2001-12-09 07:12:59 +08:00
|
|
|
GIMP_NORMAL_MODE);
|
2003-09-24 02:39:02 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), view->paint_mode_menu, TRUE, TRUE, 0);
|
2001-03-12 01:24:47 +08:00
|
|
|
gtk_widget_show (view->paint_mode_menu);
|
|
|
|
|
2003-08-24 21:52:51 +08:00
|
|
|
gimp_help_set_help_data (view->paint_mode_menu,
|
2003-09-12 02:48:00 +08:00
|
|
|
NULL, "#paint_mode_menu");
|
2001-03-12 12:40:17 +08:00
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
/* Preserve transparency toggle */
|
|
|
|
|
2003-09-12 02:48:00 +08:00
|
|
|
view->preserve_trans_toggle = toggle = gtk_check_button_new ();
|
2003-09-24 02:39:02 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
2003-09-12 02:48:00 +08:00
|
|
|
gtk_widget_show (toggle);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-09-24 02:39:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
|
|
|
G_CALLBACK (gimp_layer_tree_view_preserve_button_toggled),
|
|
|
|
view);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (toggle,
|
|
|
|
_("Keep Transparency"), "#keep_trans_button");
|
|
|
|
|
2003-09-12 02:48:00 +08:00
|
|
|
gtk_widget_style_get (GTK_WIDGET (view),
|
|
|
|
"button_icon_size", &icon_size,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_TRANSPARENCY, icon_size);
|
|
|
|
gtk_container_add (GTK_CONTAINER (toggle), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2002-03-09 02:30:40 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (view->options_box), 0, 0,
|
|
|
|
_("Mode:"), 1.0, 0.5,
|
2003-09-12 02:48:00 +08:00
|
|
|
hbox, 2, FALSE);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
/* Opacity scale */
|
|
|
|
|
|
|
|
view->opacity_adjustment =
|
2002-03-09 02:30:40 +08:00
|
|
|
GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (view->options_box), 0, 1,
|
2002-09-08 20:18:23 +08:00
|
|
|
_("Opacity:"), -1, -1,
|
2002-03-09 02:30:40 +08:00
|
|
|
100.0, 0.0, 100.0, 1.0, 10.0, 1,
|
|
|
|
TRUE, 0.0, 0.0,
|
|
|
|
NULL, "#opacity_sacle"));
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->opacity_adjustment, "value_changed",
|
2003-03-16 19:14:29 +08:00
|
|
|
G_CALLBACK (gimp_layer_tree_view_opacity_scale_changed),
|
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
|
|
|
view);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
/* Anchor button */
|
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
view->anchor_button =
|
2002-03-08 08:27:45 +08:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (view),
|
2003-08-24 21:52:51 +08:00
|
|
|
GIMP_STOCK_ANCHOR, _("Anchor Floating Layer"),
|
|
|
|
GIMP_HELP_LAYER_ANCHOR,
|
2003-03-16 19:14:29 +08:00
|
|
|
G_CALLBACK (gimp_layer_tree_view_anchor_clicked),
|
2002-03-08 08:27:45 +08:00
|
|
|
NULL,
|
|
|
|
view);
|
|
|
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (GIMP_EDITOR (view)->button_box),
|
2001-08-05 04:38:54 +08:00
|
|
|
view->anchor_button, 5);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (view),
|
|
|
|
GTK_BUTTON (view->anchor_button),
|
|
|
|
GIMP_TYPE_LAYER);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (view->options_box, FALSE);
|
|
|
|
gtk_widget_set_sensitive (view->anchor_button, FALSE);
|
|
|
|
|
2003-09-07 05:17:16 +08:00
|
|
|
view->italic_attrs = pango_attr_list_new ();
|
|
|
|
attr = pango_attr_style_new (PANGO_STYLE_ITALIC);
|
|
|
|
attr->start_index = 0;
|
|
|
|
attr->end_index = -1;
|
|
|
|
pango_attr_list_insert (view->italic_attrs, attr);
|
|
|
|
|
|
|
|
view->bold_attrs = pango_attr_list_new ();
|
|
|
|
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
|
|
|
|
attr->start_index = 0;
|
|
|
|
attr->end_index = -1;
|
|
|
|
pango_attr_list_insert (view->bold_attrs, attr);
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
view->mode_changed_handler_id = 0;
|
|
|
|
view->opacity_changed_handler_id = 0;
|
|
|
|
view->preserve_trans_changed_handler_id = 0;
|
2003-03-16 19:14:29 +08:00
|
|
|
view->mask_changed_handler_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gimp_layer_tree_view_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpLayerTreeView *layer_view;
|
|
|
|
GObject *object;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
|
|
|
|
layer_view = GIMP_LAYER_TREE_VIEW (object);
|
|
|
|
|
|
|
|
layer_view->mask_cell = gimp_cell_renderer_viewable_new ();
|
|
|
|
gtk_tree_view_column_pack_start (tree_view->main_column,
|
|
|
|
layer_view->mask_cell,
|
|
|
|
FALSE);
|
|
|
|
gtk_tree_view_column_set_attributes (tree_view->main_column,
|
|
|
|
layer_view->mask_cell,
|
|
|
|
"renderer",
|
|
|
|
layer_view->model_column_mask,
|
|
|
|
"visible",
|
|
|
|
layer_view->model_column_mask_visible,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
tree_view->renderer_cells = g_list_prepend (tree_view->renderer_cells,
|
|
|
|
layer_view->mask_cell);
|
|
|
|
|
|
|
|
g_signal_connect (tree_view->renderer_cell, "clicked",
|
|
|
|
G_CALLBACK (gimp_layer_tree_view_layer_clicked),
|
|
|
|
layer_view);
|
|
|
|
g_signal_connect (layer_view->mask_cell, "clicked",
|
|
|
|
G_CALLBACK (gimp_layer_tree_view_mask_clicked),
|
|
|
|
layer_view);
|
|
|
|
|
|
|
|
return object;
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
2003-09-07 05:17:16 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpLayerTreeView *layer_view = GIMP_LAYER_TREE_VIEW (object);
|
|
|
|
|
|
|
|
if (layer_view->italic_attrs)
|
|
|
|
{
|
|
|
|
pango_attr_list_unref (layer_view->italic_attrs);
|
|
|
|
layer_view->italic_attrs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (layer_view->bold_attrs)
|
|
|
|
{
|
|
|
|
pango_attr_list_unref (layer_view->bold_attrs);
|
|
|
|
layer_view->bold_attrs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_style_set (GtkWidget *widget,
|
2001-08-05 04:38:54 +08:00
|
|
|
GtkStyle *prev_style)
|
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpLayerTreeView *layer_view;
|
2001-08-07 08:06:06 +08:00
|
|
|
gint content_spacing;
|
|
|
|
gint button_spacing;
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
layer_view = GIMP_LAYER_TREE_VIEW (widget);
|
2001-08-05 04:38:54 +08:00
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
2001-11-26 21:17:18 +08:00
|
|
|
"content_spacing", &content_spacing,
|
|
|
|
"button_spacing", &button_spacing,
|
2001-08-05 04:38:54 +08:00
|
|
|
NULL);
|
|
|
|
|
2002-03-09 02:30:40 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (layer_view->options_box),
|
|
|
|
button_spacing);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (layer_view->options_box),
|
|
|
|
content_spacing);
|
2001-08-05 04:38:54 +08:00
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->style_set)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
|
|
|
}
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
/* GimpContainerView methods */
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_set_container (GimpContainerView *view,
|
2001-03-12 01:24:47 +08:00
|
|
|
GimpContainer *container)
|
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpLayerTreeView *layer_view;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
layer_view = GIMP_LAYER_TREE_VIEW (view);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
if (view->container)
|
|
|
|
{
|
|
|
|
gimp_container_remove_handler (view->container,
|
|
|
|
layer_view->mode_changed_handler_id);
|
|
|
|
gimp_container_remove_handler (view->container,
|
|
|
|
layer_view->opacity_changed_handler_id);
|
|
|
|
gimp_container_remove_handler (view->container,
|
|
|
|
layer_view->preserve_trans_changed_handler_id);
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_container_remove_handler (view->container,
|
|
|
|
layer_view->mask_changed_handler_id);
|
2003-05-21 19:34:00 +08:00
|
|
|
gimp_container_remove_handler (view->container,
|
|
|
|
layer_view->alpha_changed_handler_id);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
GIMP_CONTAINER_VIEW_CLASS (parent_class)->set_container (view, container);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
if (view->container)
|
|
|
|
{
|
|
|
|
layer_view->mode_changed_handler_id =
|
|
|
|
gimp_container_add_handler (view->container, "mode_changed",
|
2003-03-16 19:14:29 +08:00
|
|
|
G_CALLBACK (gimp_layer_tree_view_layer_signal_handler),
|
2001-03-12 01:24:47 +08:00
|
|
|
view);
|
|
|
|
layer_view->opacity_changed_handler_id =
|
|
|
|
gimp_container_add_handler (view->container, "opacity_changed",
|
2003-03-16 19:14:29 +08:00
|
|
|
G_CALLBACK (gimp_layer_tree_view_layer_signal_handler),
|
2001-03-12 01:24:47 +08:00
|
|
|
view);
|
|
|
|
layer_view->preserve_trans_changed_handler_id =
|
|
|
|
gimp_container_add_handler (view->container, "preserve_trans_changed",
|
2003-03-16 19:14:29 +08:00
|
|
|
G_CALLBACK (gimp_layer_tree_view_layer_signal_handler),
|
|
|
|
view);
|
|
|
|
layer_view->mask_changed_handler_id =
|
|
|
|
gimp_container_add_handler (view->container, "mask_changed",
|
|
|
|
G_CALLBACK (gimp_layer_tree_view_mask_changed),
|
2001-03-12 01:24:47 +08:00
|
|
|
view);
|
2003-05-21 19:34:00 +08:00
|
|
|
layer_view->alpha_changed_handler_id =
|
|
|
|
gimp_container_add_handler (view->container, "alpha_changed",
|
|
|
|
G_CALLBACK (gimp_layer_tree_view_alpha_changed),
|
|
|
|
view);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static gpointer
|
|
|
|
gimp_layer_tree_view_insert_item (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint index)
|
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpLayerTreeView *layer_view;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
|
|
|
layer_view = GIMP_LAYER_TREE_VIEW (view);
|
|
|
|
|
|
|
|
iter = GIMP_CONTAINER_VIEW_CLASS (parent_class)->insert_item (view, viewable,
|
|
|
|
index);
|
|
|
|
|
|
|
|
layer = GIMP_LAYER (viewable);
|
|
|
|
|
2003-05-21 19:34:00 +08:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
|
|
|
gimp_layer_tree_view_alpha_update (layer_view, iter, layer);
|
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
gimp_layer_tree_view_mask_update (layer_view, iter, layer);
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
return iter;
|
|
|
|
}
|
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
static gboolean
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_select_item (GimpContainerView *view,
|
2001-03-12 01:24:47 +08:00
|
|
|
GimpViewable *item,
|
|
|
|
gpointer insert_data)
|
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeView *item_view;
|
|
|
|
GimpLayerTreeView *layer_view;
|
2002-02-26 01:58:50 +08:00
|
|
|
gboolean options_sensitive = FALSE;
|
|
|
|
gboolean anchor_sensitive = FALSE;
|
|
|
|
gboolean raise_sensitive = FALSE;
|
2003-05-18 21:28:27 +08:00
|
|
|
gboolean success;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
item_view = GIMP_ITEM_TREE_VIEW (view);
|
|
|
|
layer_view = GIMP_LAYER_TREE_VIEW (view);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
success = GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view, item,
|
|
|
|
insert_data);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
if (item)
|
|
|
|
{
|
2003-05-18 21:28:27 +08:00
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
gimp_layer_tree_view_update_borders (layer_view,
|
|
|
|
(GtkTreeIter *) insert_data);
|
|
|
|
gimp_layer_tree_view_update_options (layer_view, GIMP_LAYER (item));
|
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
options_sensitive = TRUE;
|
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
if (! success || gimp_layer_is_floating_sel (GIMP_LAYER (item)))
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
anchor_sensitive = TRUE;
|
2001-08-07 08:06:06 +08:00
|
|
|
|
2003-09-18 06:54:48 +08:00
|
|
|
gtk_widget_set_sensitive (item_view->edit_button, FALSE);
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_widget_set_sensitive (item_view->lower_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (item_view->duplicate_button, FALSE);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
2001-05-08 09:32:25 +08:00
|
|
|
else
|
2001-05-07 06:29:48 +08:00
|
|
|
{
|
2001-05-08 09:32:25 +08:00
|
|
|
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (item)) &&
|
|
|
|
gimp_container_get_child_index (view->container,
|
|
|
|
GIMP_OBJECT (item)))
|
|
|
|
{
|
|
|
|
raise_sensitive = TRUE;
|
|
|
|
}
|
2001-05-07 06:29:48 +08:00
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_widget_set_sensitive (layer_view->options_box, options_sensitive);
|
|
|
|
gtk_widget_set_sensitive (item_view->raise_button, raise_sensitive);
|
|
|
|
gtk_widget_set_sensitive (layer_view->anchor_button, anchor_sensitive);
|
2003-05-18 21:28:27 +08:00
|
|
|
|
|
|
|
return success;
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_set_preview_size (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpLayerTreeView *layer_view;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean iter_valid;
|
|
|
|
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
|
|
|
layer_view = GIMP_LAYER_TREE_VIEW (view);
|
|
|
|
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
GimpPreviewRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_model_get (tree_view->model, &iter,
|
|
|
|
layer_view->model_column_mask, &renderer,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (renderer)
|
|
|
|
{
|
2003-04-05 05:16:58 +08:00
|
|
|
gimp_preview_renderer_set_size (renderer,
|
|
|
|
view->preview_size,
|
|
|
|
view->preview_border_width);
|
2003-03-16 19:14:29 +08:00
|
|
|
g_object_unref (renderer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_CONTAINER_VIEW_CLASS (parent_class)->set_preview_size (view);
|
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
|
2003-03-19 23:17:13 +08:00
|
|
|
/* GimpContainerTreeView methods */
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_layer_tree_view_drop_possible (GimpContainerTreeView *tree_view,
|
|
|
|
GimpViewable *src_viewable,
|
|
|
|
GimpViewable *dest_viewable,
|
|
|
|
GtkTreeViewDropPosition drop_pos,
|
|
|
|
GdkDragAction *drag_action)
|
|
|
|
{
|
|
|
|
GimpLayer *src_layer;
|
|
|
|
GimpLayer *dest_layer;
|
|
|
|
GimpImage *src_image;
|
|
|
|
GimpImage *dest_image;
|
|
|
|
|
|
|
|
src_layer = GIMP_LAYER (src_viewable);
|
|
|
|
dest_layer = GIMP_LAYER (dest_viewable);
|
|
|
|
|
|
|
|
src_image = gimp_item_get_image (GIMP_ITEM (src_layer));
|
|
|
|
dest_image = gimp_item_get_image (GIMP_ITEM (dest_layer));
|
|
|
|
|
|
|
|
if (gimp_image_floating_sel (dest_image))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (dest_layer)) &&
|
|
|
|
drop_pos == GTK_TREE_VIEW_DROP_AFTER)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (src_image == dest_image &&
|
|
|
|
! gimp_drawable_has_alpha (GIMP_DRAWABLE (src_layer)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_possible (tree_view,
|
|
|
|
src_viewable,
|
|
|
|
dest_viewable,
|
|
|
|
drop_pos,
|
|
|
|
drag_action);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
/* GimpItemTreeView methods */
|
|
|
|
|
2003-09-07 05:17:16 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_set_image (GimpItemTreeView *view,
|
|
|
|
GimpImage *gimage)
|
|
|
|
{
|
|
|
|
if (view->gimage)
|
|
|
|
g_signal_handlers_disconnect_by_func (view->gimage,
|
|
|
|
gimp_layer_tree_view_floating_selection_changed,
|
|
|
|
view);
|
|
|
|
|
|
|
|
GIMP_ITEM_TREE_VIEW_CLASS (parent_class)->set_image (view, gimage);
|
|
|
|
|
|
|
|
if (view->gimage)
|
|
|
|
g_signal_connect (view->gimage,
|
|
|
|
"floating_selection_changed",
|
|
|
|
G_CALLBACK (gimp_layer_tree_view_floating_selection_changed),
|
|
|
|
view);
|
|
|
|
}
|
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_remove_item (GimpImage *gimage,
|
|
|
|
GimpItem *item)
|
|
|
|
{
|
|
|
|
if (gimp_layer_is_floating_sel (GIMP_LAYER (item)))
|
|
|
|
floating_sel_remove (GIMP_LAYER (item));
|
|
|
|
else
|
|
|
|
gimp_image_remove_layer (gimage, GIMP_LAYER (item));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-07 05:17:16 +08:00
|
|
|
/* callbacks */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_floating_selection_changed (GimpImage *gimage,
|
|
|
|
GimpLayerTreeView *layer_view)
|
|
|
|
{
|
|
|
|
GimpContainerView *view;
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpLayer *floating_sel;
|
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
|
|
|
view = GIMP_CONTAINER_VIEW (layer_view);
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
|
|
|
|
|
|
|
|
floating_sel = gimp_image_floating_sel (gimage);
|
|
|
|
|
|
|
|
if (floating_sel)
|
|
|
|
{
|
|
|
|
iter = g_hash_table_lookup (view->hash_table, floating_sel);
|
|
|
|
|
|
|
|
if (iter)
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
|
|
|
|
tree_view->model_column_name_attributes,
|
|
|
|
layer_view->italic_attrs,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = GIMP_LIST (gimage->layers)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable = list->data;
|
|
|
|
|
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
|
|
|
{
|
|
|
|
iter = g_hash_table_lookup (view->hash_table, drawable);
|
|
|
|
|
|
|
|
if (iter)
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
|
|
|
|
tree_view->model_column_name_attributes,
|
|
|
|
NULL,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_anchor_clicked (GtkWidget *widget,
|
|
|
|
GimpLayerTreeView *view)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-02-17 21:33:29 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
gimage = GIMP_ITEM_TREE_VIEW (view)->gimage;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
layer = (GimpLayer *)
|
2003-03-16 19:14:29 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
if (layer && gimp_layer_is_floating_sel (layer))
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-02-17 21:33:29 +08:00
|
|
|
floating_sel_anchor (layer);
|
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* Paint Mode, Opacity and Preserve trans. callbacks */
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
#define BLOCK() \
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_block_by_func (layer, \
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_layer_signal_handler, view)
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
#define UNBLOCK() \
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_unblock_by_func (layer, \
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_layer_signal_handler, view)
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_paint_mode_menu_callback (GtkWidget *widget,
|
|
|
|
GimpLayerTreeView *view)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-02-17 21:33:29 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
gimage = GIMP_ITEM_TREE_VIEW (view)->gimage;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
layer = (GimpLayer *)
|
2003-03-16 19:14:29 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
if (layer)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2001-12-09 07:12:59 +08:00
|
|
|
GimpLayerModeEffects mode;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2001-12-09 07:12:59 +08:00
|
|
|
mode = (GimpLayerModeEffects)
|
2001-11-22 21:01:26 +08:00
|
|
|
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
|
|
|
|
"gimp-item-data"));
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
if (gimp_layer_get_mode (layer) != mode)
|
|
|
|
{
|
|
|
|
BLOCK();
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
gimp_layer_set_mode (layer, mode, TRUE);
|
2001-03-12 01:24:47 +08:00
|
|
|
UNBLOCK();
|
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_preserve_button_toggled (GtkWidget *widget,
|
|
|
|
GimpLayerTreeView *view)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-02-17 21:33:29 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
gimage = GIMP_ITEM_TREE_VIEW (view)->gimage;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
layer = (GimpLayer *)
|
2003-03-16 19:14:29 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
if (layer)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
gboolean preserve_trans;
|
|
|
|
|
|
|
|
preserve_trans = GTK_TOGGLE_BUTTON (widget)->active;
|
|
|
|
|
|
|
|
if (gimp_layer_get_preserve_trans (layer) != preserve_trans)
|
|
|
|
{
|
|
|
|
BLOCK();
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
gimp_layer_set_preserve_trans (layer, preserve_trans, TRUE);
|
2001-03-12 01:24:47 +08:00
|
|
|
UNBLOCK();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_opacity_scale_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpLayerTreeView *view)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-02-17 21:33:29 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
gimage = GIMP_ITEM_TREE_VIEW (view)->gimage;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
layer = (GimpLayer *)
|
2003-03-16 19:14:29 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
if (layer)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
gdouble opacity;
|
|
|
|
|
|
|
|
opacity = adjustment->value / 100.0;
|
|
|
|
|
|
|
|
if (gimp_layer_get_opacity (layer) != opacity)
|
|
|
|
{
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
|
|
|
undo = gimp_undo_stack_peek (gimage->undo_stack);
|
|
|
|
|
|
|
|
/* compress opacity undos */
|
|
|
|
if (GIMP_IS_ITEM_UNDO (undo) &&
|
|
|
|
undo->undo_type == GIMP_UNDO_LAYER_OPACITY &&
|
|
|
|
GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
BLOCK();
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
gimp_layer_set_opacity (layer, opacity, push_undo);
|
2001-03-12 01:24:47 +08:00
|
|
|
UNBLOCK();
|
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef BLOCK
|
|
|
|
#undef UNBLOCK
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_layer_signal_handler (GimpLayer *layer,
|
|
|
|
GimpLayerTreeView *view)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpItemTreeView *item_view;
|
2003-02-17 21:33:29 +08:00
|
|
|
GimpLayer *active_layer;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
item_view = GIMP_ITEM_TREE_VIEW (view);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
active_layer = (GimpLayer *)
|
2003-03-16 19:14:29 +08:00
|
|
|
GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (item_view->gimage);
|
2003-02-17 21:33:29 +08:00
|
|
|
|
|
|
|
if (active_layer == layer)
|
2003-03-16 21:19:43 +08:00
|
|
|
gimp_layer_tree_view_update_options (view, layer);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 04:01:14 +08:00
|
|
|
|
|
|
|
#define BLOCK(object,function) \
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_block_by_func ((object), (function), view)
|
2001-03-12 04:01:14 +08:00
|
|
|
|
|
|
|
#define UNBLOCK(object,function) \
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_unblock_by_func ((object), (function), view)
|
2001-03-12 04:01:14 +08:00
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
static void
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_update_options (GimpLayerTreeView *view,
|
2001-03-12 01:24:47 +08:00
|
|
|
GimpLayer *layer)
|
|
|
|
{
|
|
|
|
gimp_option_menu_set_history (GTK_OPTION_MENU (view->paint_mode_menu),
|
|
|
|
GINT_TO_POINTER (layer->mode));
|
|
|
|
|
|
|
|
if (layer->preserve_trans !=
|
|
|
|
GTK_TOGGLE_BUTTON (view->preserve_trans_toggle)->active)
|
|
|
|
{
|
2001-03-12 04:01:14 +08:00
|
|
|
BLOCK (view->preserve_trans_toggle,
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_preserve_button_toggled);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->preserve_trans_toggle),
|
|
|
|
layer->preserve_trans);
|
|
|
|
|
2001-03-12 04:01:14 +08:00
|
|
|
UNBLOCK (view->preserve_trans_toggle,
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_preserve_button_toggled);
|
2003-02-17 21:33:29 +08:00
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
if (layer->opacity * 100.0 != view->opacity_adjustment->value)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2001-03-12 04:01:14 +08:00
|
|
|
BLOCK (view->opacity_adjustment,
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_opacity_scale_changed);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
gtk_adjustment_set_value (view->opacity_adjustment,
|
|
|
|
layer->opacity * 100.0);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2001-03-12 04:01:14 +08:00
|
|
|
UNBLOCK (view->opacity_adjustment,
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_layer_tree_view_opacity_scale_changed);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-12 04:01:14 +08:00
|
|
|
|
|
|
|
#undef BLOCK
|
|
|
|
#undef UNBLOCK
|
2003-02-17 21:33:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
|
|
|
|
/* Layer Mask callbacks */
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void
|
2003-03-16 21:19:43 +08:00
|
|
|
gimp_layer_tree_view_mask_update (GimpLayerTreeView *layer_view,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GimpLayer *layer)
|
2003-03-16 19:14:29 +08:00
|
|
|
{
|
2003-03-16 21:19:43 +08:00
|
|
|
GimpContainerView *container_view;
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpContainerTreeView *tree_view;
|
2003-03-16 21:19:43 +08:00
|
|
|
GimpLayerMask *mask;
|
|
|
|
GimpPreviewRenderer *renderer = NULL;
|
|
|
|
gboolean mask_visible = FALSE;
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
container_view = GIMP_CONTAINER_VIEW (layer_view);
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
mask = gimp_layer_get_mask (layer);
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
if (mask)
|
2003-03-16 19:14:29 +08:00
|
|
|
{
|
2003-03-16 21:19:43 +08:00
|
|
|
GClosure *closure;
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
mask_visible = TRUE;
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
renderer = gimp_preview_renderer_new (G_TYPE_FROM_INSTANCE (mask),
|
|
|
|
container_view->preview_size,
|
2003-04-05 05:16:58 +08:00
|
|
|
container_view->preview_border_width,
|
2003-03-16 21:19:43 +08:00
|
|
|
FALSE);
|
|
|
|
gimp_preview_renderer_set_viewable (renderer, GIMP_VIEWABLE (mask));
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
g_signal_connect (renderer, "update",
|
|
|
|
G_CALLBACK (gimp_layer_tree_view_renderer_update),
|
|
|
|
layer_view);
|
2003-03-16 19:14:29 +08:00
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
closure = g_cclosure_new (G_CALLBACK (gimp_layer_tree_view_mask_callback),
|
|
|
|
layer_view, NULL);
|
|
|
|
g_object_watch_closure (G_OBJECT (renderer), closure);
|
|
|
|
g_signal_connect_closure (mask, "apply_changed", closure, FALSE);
|
2003-07-02 20:08:22 +08:00
|
|
|
g_signal_connect_closure (mask, "edit_changed", closure, FALSE);
|
|
|
|
g_signal_connect_closure (mask, "show_changed", closure, FALSE);
|
2003-03-16 21:19:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
|
|
|
|
layer_view->model_column_mask, renderer,
|
|
|
|
layer_view->model_column_mask_visible, mask_visible,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (renderer)
|
|
|
|
{
|
|
|
|
gimp_layer_tree_view_update_borders (layer_view, iter);
|
|
|
|
gimp_preview_renderer_remove_idle (renderer);
|
|
|
|
g_object_unref (renderer);
|
2003-03-16 19:14:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-16 21:19:43 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_mask_changed (GimpLayer *layer,
|
|
|
|
GimpLayerTreeView *layer_view)
|
|
|
|
{
|
|
|
|
GimpContainerView *view;
|
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
|
|
|
view = GIMP_CONTAINER_VIEW (layer_view);
|
|
|
|
|
|
|
|
iter = g_hash_table_lookup (view->hash_table, layer);
|
|
|
|
|
|
|
|
if (iter)
|
|
|
|
gimp_layer_tree_view_mask_update (layer_view, iter, layer);
|
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_renderer_update (GimpPreviewRenderer *renderer,
|
|
|
|
GimpLayerTreeView *layer_view)
|
|
|
|
{
|
|
|
|
GimpContainerView *view;
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpLayerMask *mask;
|
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
|
|
|
view = GIMP_CONTAINER_VIEW (layer_view);
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
|
|
|
|
|
|
|
|
mask = GIMP_LAYER_MASK (renderer->viewable);
|
|
|
|
|
|
|
|
iter = g_hash_table_lookup (view->hash_table,
|
|
|
|
gimp_layer_mask_get_layer (mask));
|
|
|
|
|
|
|
|
if (iter)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path (tree_view->model, iter);
|
|
|
|
|
|
|
|
gtk_tree_model_row_changed (tree_view->model, path, iter);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_update_borders (GimpLayerTreeView *layer_view,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GimpPreviewRenderer *layer_renderer;
|
|
|
|
GimpPreviewRenderer *mask_renderer;
|
2003-07-02 20:08:22 +08:00
|
|
|
GimpLayerMask *mask = NULL;
|
2003-03-16 19:14:29 +08:00
|
|
|
GimpRGB *layer_color = &black_color;
|
|
|
|
GimpRGB *mask_color = &black_color;
|
|
|
|
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
|
|
|
|
|
|
|
|
gtk_tree_model_get (tree_view->model, iter,
|
2003-07-02 20:08:22 +08:00
|
|
|
tree_view->model_column_renderer, &layer_renderer,
|
|
|
|
layer_view->model_column_mask, &mask_renderer,
|
2003-03-16 19:14:29 +08:00
|
|
|
-1);
|
|
|
|
|
|
|
|
if (mask_renderer)
|
|
|
|
mask = GIMP_LAYER_MASK (mask_renderer->viewable);
|
|
|
|
|
|
|
|
if (! mask || (mask && ! gimp_layer_mask_get_edit (mask)))
|
|
|
|
layer_color = &white_color;
|
|
|
|
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
if (gimp_layer_mask_get_show (mask))
|
|
|
|
{
|
|
|
|
mask_color = &green_color;
|
|
|
|
}
|
|
|
|
else if (! gimp_layer_mask_get_apply (mask))
|
|
|
|
{
|
|
|
|
mask_color = &red_color;
|
|
|
|
}
|
|
|
|
else if (gimp_layer_mask_get_edit (mask))
|
|
|
|
{
|
|
|
|
mask_color = &white_color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_preview_renderer_set_border_color (layer_renderer, layer_color);
|
|
|
|
|
|
|
|
if (mask)
|
|
|
|
gimp_preview_renderer_set_border_color (mask_renderer, mask_color);
|
|
|
|
|
|
|
|
if (layer_renderer)
|
|
|
|
g_object_unref (layer_renderer);
|
|
|
|
|
|
|
|
if (mask_renderer)
|
|
|
|
g_object_unref (mask_renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-16 21:19:43 +08:00
|
|
|
gimp_layer_tree_view_mask_callback (GimpLayerMask *mask,
|
|
|
|
GimpLayerTreeView *layer_view)
|
2003-03-16 19:14:29 +08:00
|
|
|
{
|
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
|
|
|
iter = g_hash_table_lookup (GIMP_CONTAINER_VIEW (layer_view)->hash_table,
|
|
|
|
gimp_layer_mask_get_layer (mask));
|
|
|
|
|
|
|
|
gimp_layer_tree_view_update_borders (layer_view, iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_layer_clicked (GimpCellRendererViewable *cell,
|
|
|
|
const gchar *path_str,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpLayerTreeView *layer_view)
|
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
|
|
|
|
{
|
|
|
|
GimpPreviewRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_model_get (tree_view->model, &iter,
|
|
|
|
layer_view->model_column_mask, &renderer,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (renderer)
|
|
|
|
{
|
|
|
|
GimpLayerMask *mask;
|
|
|
|
|
|
|
|
mask = GIMP_LAYER_MASK (renderer->viewable);
|
|
|
|
|
|
|
|
if (gimp_layer_mask_get_edit (mask))
|
2003-03-23 04:30:30 +08:00
|
|
|
{
|
|
|
|
gimp_layer_mask_set_edit (mask, FALSE);
|
|
|
|
gimp_image_flush (gimp_item_get_image (GIMP_ITEM (mask)));
|
|
|
|
}
|
2003-03-16 19:14:29 +08:00
|
|
|
|
|
|
|
g_object_unref (renderer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_mask_clicked (GimpCellRendererViewable *cell,
|
|
|
|
const gchar *path_str,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpLayerTreeView *layer_view)
|
|
|
|
{
|
|
|
|
GimpContainerTreeView *tree_view;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
|
|
|
|
{
|
|
|
|
GimpPreviewRenderer *renderer;
|
|
|
|
GimpLayerMask *mask;
|
|
|
|
gboolean flush = FALSE;
|
|
|
|
|
|
|
|
gtk_tree_model_get (tree_view->model, &iter,
|
|
|
|
layer_view->model_column_mask, &renderer,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
mask = GIMP_LAYER_MASK (renderer->viewable);
|
|
|
|
|
|
|
|
if (state & GDK_MOD1_MASK)
|
|
|
|
{
|
|
|
|
gimp_layer_mask_set_show (mask, ! gimp_layer_mask_get_show (mask));
|
|
|
|
flush = TRUE;
|
|
|
|
}
|
|
|
|
else if (state & GDK_CONTROL_MASK)
|
|
|
|
{
|
|
|
|
gimp_layer_mask_set_apply (mask, ! gimp_layer_mask_get_apply (mask));
|
|
|
|
flush = TRUE;
|
|
|
|
}
|
2003-03-23 04:30:30 +08:00
|
|
|
else if (! gimp_layer_mask_get_edit (mask))
|
2003-03-16 19:14:29 +08:00
|
|
|
{
|
2003-03-23 04:30:30 +08:00
|
|
|
gimp_layer_mask_set_edit (mask, TRUE);
|
|
|
|
flush = TRUE;
|
2003-03-16 19:14:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flush)
|
|
|
|
gimp_image_flush (gimp_item_get_image (GIMP_ITEM (mask)));
|
|
|
|
|
|
|
|
g_object_unref (renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
2003-05-21 19:34:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* GimpDrawable alpha callbacks */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_alpha_update (GimpLayerTreeView *view,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GimpLayer *layer)
|
|
|
|
{
|
2003-09-07 05:17:16 +08:00
|
|
|
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
2003-05-21 19:34:00 +08:00
|
|
|
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
|
|
|
|
tree_view->model_column_name_attributes,
|
|
|
|
gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)) ?
|
2003-09-07 05:17:16 +08:00
|
|
|
NULL : view->bold_attrs,
|
2003-05-21 19:34:00 +08:00
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_tree_view_alpha_changed (GimpLayer *layer,
|
|
|
|
GimpLayerTreeView *layer_view)
|
|
|
|
{
|
|
|
|
GimpContainerView *view;
|
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
|
|
|
view = GIMP_CONTAINER_VIEW (layer_view);
|
|
|
|
|
|
|
|
iter = g_hash_table_lookup (view->hash_table, layer);
|
|
|
|
|
|
|
|
if (iter)
|
2003-08-28 03:50:08 +08:00
|
|
|
{
|
2003-09-07 05:17:16 +08:00
|
|
|
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
|
2003-08-28 03:50:08 +08:00
|
|
|
|
|
|
|
gimp_layer_tree_view_alpha_update (layer_view, iter, layer);
|
|
|
|
|
|
|
|
/* update button states */
|
|
|
|
if (gimp_image_get_active_layer (item_view->gimage) == layer)
|
|
|
|
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
|
|
|
|
GIMP_VIEWABLE (layer));
|
|
|
|
}
|
2003-05-21 19:34:00 +08:00
|
|
|
}
|