removed "linked" member and API...

2003-05-08  Michael Natterer  <mitch@gimp.org>

	* app/core/gimplayer.[ch]: removed "linked" member and API...

	* app/core/gimpitem.[ch]: ...and added it here.

	* app/core/core-enums.[ch]
	* app/core/gimpimage-undo-push.[ch]: changed layer_linked undo
	types and functions to be item_linked ones.

	* app/tools/gimpeditselectiontool.c
	* app/xcf/xcf-load.c
	* app/xcf/xcf-save.c
	* tools/pdbgen/pdb/layer.pdb: changed accordingly.

	* app/pdb/layer_cmds.c: regenerated.

	* app/widgets/gimplayertreeview.[ch]: removed "linked" icon and
	functions...

	* app/widgets/gimpitemtreeview.[ch]: and added them here. Setting
	channels or vectors to "linked" does nothing yet.
This commit is contained in:
Michael Natterer 2003-05-08 20:26:01 +00:00 committed by Michael Natterer
parent 129c78d271
commit 33b7d779d6
18 changed files with 360 additions and 212 deletions

View File

@ -1,3 +1,26 @@
2003-05-08 Michael Natterer <mitch@gimp.org>
* app/core/gimplayer.[ch]: removed "linked" member and API...
* app/core/gimpitem.[ch]: ...and added it here.
* app/core/core-enums.[ch]
* app/core/gimpimage-undo-push.[ch]: changed layer_linked undo
types and functions to be item_linked ones.
* app/tools/gimpeditselectiontool.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* tools/pdbgen/pdb/layer.pdb: changed accordingly.
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimplayertreeview.[ch]: removed "linked" icon and
functions...
* app/widgets/gimpitemtreeview.[ch]: and added them here. Setting
channels or vectors to "linked" does nothing yet.
2003-05-08 Michael Natterer <mitch@gimp.org>
* app/core/gimpitem.[ch]: added gimp_item_translate() and

View File

@ -438,10 +438,10 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_GROUP_MASK, N_("Selection Mask"), "group-mask" },
{ GIMP_UNDO_GROUP_ITEM_PROPERTIES, N_("Item Properties"), "group-item-properties" },
{ GIMP_UNDO_GROUP_ITEM_DISPLACE, N_("Move Item"), "group-item-displace" },
{ GIMP_UNDO_GROUP_ITEM_LINKED, N_("Linked Item"), "group-item-linked" },
{ GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY, N_("Drawable Visibility"), "group-drawable-visibility" },
{ GIMP_UNDO_GROUP_LAYER_SCALE, N_("Scale Layer"), "group-layer-scale" },
{ GIMP_UNDO_GROUP_LAYER_RESIZE, N_("Resize Layer"), "group-layer-resize" },
{ GIMP_UNDO_GROUP_LAYER_LINKED, N_("Linked Layer"), "group-layer-linked" },
{ GIMP_UNDO_GROUP_LAYER_APPLY_MASK, N_("Apply Layer Mask"), "group-layer-apply-mask" },
{ GIMP_UNDO_GROUP_FS_TO_LAYER, N_("Floating Selection to Layer"), "group-fs-to-layer" },
{ GIMP_UNDO_GROUP_FS_FLOAT, N_("Float Selection"), "group-fs-float" },
@ -466,6 +466,7 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_MASK, N_("Selection Mask"), "mask" },
{ GIMP_UNDO_ITEM_RENAME, N_("Rename Item"), "item-rename" },
{ GIMP_UNDO_ITEM_DISPLACE, N_("Move Item"), "item-displace" },
{ GIMP_UNDO_ITEM_LINKED, N_("Set Item Linked"), "item-linked" },
{ GIMP_UNDO_DRAWABLE_VISIBILITY, N_("Drawable Visibility"), "drawable-visibility" },
{ GIMP_UNDO_LAYER_ADD, N_("New Layer"), "layer-add" },
{ GIMP_UNDO_LAYER_REMOVE, N_("Delete Layer"), "layer-remove" },
@ -476,7 +477,6 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_LAYER_MODE, N_("Set Layer Mode"), "layer-mode" },
{ GIMP_UNDO_LAYER_OPACITY, N_("Set Layer Opacity"), "layer-opacity" },
{ GIMP_UNDO_LAYER_PRESERVE_TRANS, N_("Set Preserve Trans"), "layer-preserve-trans" },
{ GIMP_UNDO_LAYER_LINKED, N_("Set Layer Linked"), "layer-linked" },
{ GIMP_UNDO_CHANNEL_ADD, N_("New Channel"), "channel-add" },
{ GIMP_UNDO_CHANNEL_REMOVE, N_("Delete Channel"), "channel-remove" },
{ GIMP_UNDO_CHANNEL_MOD, N_("Channel Mod"), "channel-mod" },

View File

@ -325,10 +325,10 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_MASK, /*< desc="Selection Mask" >*/
GIMP_UNDO_GROUP_ITEM_PROPERTIES, /*< desc="Item Properties" >*/
GIMP_UNDO_GROUP_ITEM_DISPLACE, /*< desc="Move Item" >*/
GIMP_UNDO_GROUP_ITEM_LINKED, /*< desc="Linked Item" >*/
GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY,/*< desc="Drawable Visibility" >*/
GIMP_UNDO_GROUP_LAYER_SCALE, /*< desc="Scale Layer" >*/
GIMP_UNDO_GROUP_LAYER_RESIZE, /*< desc="Resize Layer" >*/
GIMP_UNDO_GROUP_LAYER_LINKED, /*< desc="Linked Layer" >*/
GIMP_UNDO_GROUP_LAYER_APPLY_MASK, /*< desc="Apply Layer Mask" >*/
GIMP_UNDO_GROUP_FS_TO_LAYER, /*< desc="Floating Selection to Layer" >*/
GIMP_UNDO_GROUP_FS_FLOAT, /*< desc="Float Selection" >*/
@ -358,6 +358,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_MASK, /*< desc="Selection Mask" >*/
GIMP_UNDO_ITEM_RENAME, /*< desc="Rename Item" >*/
GIMP_UNDO_ITEM_DISPLACE, /*< desc="Move Item" >*/
GIMP_UNDO_ITEM_LINKED, /*< desc="Set Item Linked" >*/
GIMP_UNDO_DRAWABLE_VISIBILITY, /*< desc="Drawable Visibility" >*/
GIMP_UNDO_LAYER_ADD, /*< desc="New Layer" >*/
GIMP_UNDO_LAYER_REMOVE, /*< desc="Delete Layer" >*/
@ -368,7 +369,6 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_LAYER_MODE, /*< desc="Set Layer Mode" >*/
GIMP_UNDO_LAYER_OPACITY, /*< desc="Set Layer Opacity" >*/
GIMP_UNDO_LAYER_PRESERVE_TRANS, /*< desc="Set Preserve Trans" >*/
GIMP_UNDO_LAYER_LINKED, /*< desc="Set Layer Linked" >*/
GIMP_UNDO_CHANNEL_ADD, /*< desc="New Channel" >*/
GIMP_UNDO_CHANNEL_REMOVE, /*< desc="Delete Channel" >*/
GIMP_UNDO_CHANNEL_MOD, /*< desc="Channel Mod" >*/

View File

@ -1169,6 +1169,81 @@ undo_free_item_displace (GimpUndo *undo,
}
/**********************/
/* Item linked Undo */
/**********************/
typedef struct _ItemLinkedUndo ItemLinkedUndo;
struct _ItemLinkedUndo
{
gboolean old_linked;
};
static gboolean undo_pop_item_linked (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_item_linked (GimpUndo *undo,
GimpUndoMode undo_mode);
gboolean
gimp_image_undo_push_item_linked (GimpImage *gimage,
const gchar *undo_desc,
GimpItem *item)
{
GimpUndo *new;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
if ((new = gimp_image_undo_push_item (gimage, item,
sizeof (ItemLinkedUndo),
sizeof (ItemLinkedUndo),
GIMP_UNDO_ITEM_LINKED, undo_desc,
TRUE,
undo_pop_item_linked,
undo_free_item_linked)))
{
ItemLinkedUndo *ilu;
ilu = new->data;
ilu->old_linked = gimp_item_get_linked (item);
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_item_linked (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
ItemLinkedUndo *ilu;
GimpItem *item;
gboolean linked;
ilu = (ItemLinkedUndo *) undo->data;
item = GIMP_ITEM_UNDO (undo)->item;
linked = gimp_item_get_linked (item);
gimp_item_set_linked (item, ilu->old_linked, FALSE);
ilu->old_linked = linked;
return TRUE;
}
static void
undo_free_item_linked (GimpUndo *undo,
GimpUndoMode undo_mode)
{
g_free (undo->data);
}
/******************************/
/* Drawable Visibility Undo */
/******************************/
@ -1794,7 +1869,6 @@ struct _LayerPropertiesUndo
GimpLayerModeEffects old_mode;
gdouble old_opacity;
gboolean old_preserve_trans;
gboolean old_linked;
};
static gboolean undo_push_layer_properties (GimpImage *gimage,
@ -1834,15 +1908,6 @@ gimp_image_undo_push_layer_preserve_trans (GimpImage *gimage,
undo_desc, layer);
}
gboolean
gimp_image_undo_push_layer_linked (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer)
{
return undo_push_layer_properties (gimage, GIMP_UNDO_LAYER_LINKED,
undo_desc, layer);
}
static gboolean
undo_push_layer_properties (GimpImage *gimage,
GimpUndoType undo_type,
@ -1869,7 +1934,6 @@ undo_push_layer_properties (GimpImage *gimage,
lpu->old_mode = gimp_layer_get_mode (layer);
lpu->old_opacity = gimp_layer_get_opacity (layer);
lpu->old_preserve_trans = gimp_layer_get_preserve_trans (layer);
lpu->old_linked = gimp_layer_get_linked (layer);
return TRUE;
}
@ -1913,14 +1977,6 @@ undo_pop_layer_properties (GimpUndo *undo,
gimp_layer_set_preserve_trans (layer, lpu->old_preserve_trans, FALSE);
lpu->old_preserve_trans = preserve_trans;
}
else if (undo->undo_type == GIMP_UNDO_LAYER_LINKED)
{
gboolean linked;
linked = gimp_layer_get_linked (layer);
gimp_layer_set_linked (layer, lpu->old_linked, FALSE);
lpu->old_linked = linked;
}
return TRUE;
}

View File

@ -68,6 +68,9 @@ gboolean gimp_image_undo_push_item_rename (GimpImage *gimage,
gboolean gimp_image_undo_push_item_displace (GimpImage *gimage,
const gchar *undo_desc,
GimpItem *item);
gboolean gimp_image_undo_push_item_linked (GimpImage *gimage,
const gchar *undo_desc,
GimpItem *item);
/* drawable undos */
@ -112,9 +115,6 @@ gboolean gimp_image_undo_push_layer_opacity (GimpImage *gimage,
gboolean gimp_image_undo_push_layer_preserve_trans (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer);
gboolean gimp_image_undo_push_layer_linked (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer);
/* channel undos */

View File

@ -48,6 +48,7 @@
enum
{
REMOVED,
LINKED_CHANGED,
LAST_SIGNAL
};
@ -128,12 +129,22 @@ gimp_item_class_init (GimpItemClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_item_signals[LINKED_CHANGED] =
g_signal_new ("linked_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpItemClass, linked_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_item_finalize;
gimp_object_class->name_changed = gimp_item_name_changed;
gimp_object_class->get_memsize = gimp_item_get_memsize;
klass->removed = NULL;
klass->linked_changed = NULL;
klass->duplicate = gimp_item_real_duplicate;
klass->rename = gimp_item_real_rename;
klass->translate = gimp_item_real_translate;
@ -152,6 +163,7 @@ gimp_item_init (GimpItem *item)
item->height = 0;
item->offset_x = 0;
item->offset_y = 0;
item->linked = FALSE;
}
static void
@ -263,6 +275,8 @@ gimp_item_real_duplicate (GimpItem *item,
g_object_unref (new_item->parasites);
new_item->parasites = gimp_parasite_list_copy (item->parasites);
new_item->linked = item->linked;
return new_item;
}
@ -779,3 +793,34 @@ gimp_item_parasite_list (const GimpItem *item,
return list;
}
void
gimp_item_set_linked (GimpItem *item,
gboolean linked,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_ITEM (item));
if (item->linked != linked)
{
if (push_undo)
{
GimpImage *gimage = gimp_item_get_image (item);
if (gimage)
gimp_image_undo_push_item_linked (gimage, NULL, item);
}
item->linked = linked ? TRUE : FALSE;
g_signal_emit (item, gimp_item_signals[LINKED_CHANGED], 0);
}
}
gboolean
gimp_item_get_linked (const GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
return item->linked;
}

View File

@ -46,6 +46,8 @@ struct _GimpItem
gint width, height; /* size in pixels */
gint offset_x, offset_y; /* pixel offset in image */
gboolean linked; /* control linkage */
};
struct _GimpItemClass
@ -53,7 +55,8 @@ struct _GimpItemClass
GimpViewableClass parent_class;
/* signals */
void (* removed) (GimpItem *item);
void (* removed) (GimpItem *item);
void (* linked_changed) (GimpItem *item);
/* virtual functions */
GimpItem * (* duplicate) (GimpItem *item,
@ -159,5 +162,10 @@ GimpParasite * gimp_item_parasite_find (const GimpItem *item,
gchar ** gimp_item_parasite_list (const GimpItem *item,
gint *count);
void gimp_item_set_linked (GimpItem *item,
gboolean linked,
gboolean push_undo);
gboolean gimp_item_get_linked (const GimpItem *item);
#endif /* __GIMP_ITEM_H__ */

View File

@ -54,7 +54,6 @@ enum
OPACITY_CHANGED,
MODE_CHANGED,
PRESERVE_TRANS_CHANGED,
LINKED_CHANGED,
MASK_CHANGED,
LAST_SIGNAL
};
@ -172,15 +171,6 @@ gimp_layer_class_init (GimpLayerClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_signals[LINKED_CHANGED] =
g_signal_new ("linked_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerClass, linked_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_signals[MASK_CHANGED] =
g_signal_new ("mask_changed",
G_TYPE_FROM_CLASS (klass),
@ -209,7 +199,6 @@ gimp_layer_class_init (GimpLayerClass *klass)
klass->opacity_changed = NULL;
klass->mode_changed = NULL;
klass->preserve_trans_changed = NULL;
klass->linked_changed = NULL;
klass->mask_changed = NULL;
}
@ -219,7 +208,6 @@ gimp_layer_init (GimpLayer *layer)
layer->opacity = GIMP_OPACITY_OPAQUE;
layer->mode = GIMP_NORMAL_MODE;
layer->preserve_trans = FALSE;
layer->linked = FALSE;
layer->mask = NULL;
@ -316,11 +304,9 @@ gimp_layer_duplicate (GimpItem *item,
layer = GIMP_LAYER (item);
new_layer = GIMP_LAYER (new_item);
new_layer->linked = layer->linked;
new_layer->preserve_trans = layer->preserve_trans;
new_layer->mode = layer->mode;
new_layer->opacity = layer->opacity;
new_layer->preserve_trans = layer->preserve_trans;
/* duplicate the layer mask if necessary */
if (layer->mask)
@ -1409,34 +1395,3 @@ gimp_layer_get_preserve_trans (const GimpLayer *layer)
return layer->preserve_trans;
}
void
gimp_layer_set_linked (GimpLayer *layer,
gboolean linked,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
if (layer->linked != linked)
{
if (push_undo)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer));
if (gimage)
gimp_image_undo_push_layer_linked (gimage, NULL, layer);
}
layer->linked = linked ? TRUE : FALSE;
g_signal_emit (layer, layer_signals[LINKED_CHANGED], 0);
}
}
gboolean
gimp_layer_get_linked (const GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
return layer->linked;
}

View File

@ -41,8 +41,6 @@ struct _GimpLayer
GimpLayerModeEffects mode; /* layer combination mode */
gboolean preserve_trans; /* preserve transparency */
gboolean linked; /* control linkage */
GimpLayerMask *mask; /* possible layer mask */
/* Floating selections */
@ -65,7 +63,6 @@ struct _GimpLayerClass
void (* opacity_changed) (GimpLayer *layer);
void (* mode_changed) (GimpLayer *layer);
void (* preserve_trans_changed) (GimpLayer *layer);
void (* linked_changed) (GimpLayer *layer);
void (* mask_changed) (GimpLayer *layer);
};
@ -128,10 +125,6 @@ void gimp_layer_set_preserve_trans (GimpLayer *layer,
gboolean push_undo);
gboolean gimp_layer_get_preserve_trans (const GimpLayer *layer);
void gimp_layer_set_linked (GimpLayer *layer,
gboolean linked,
gboolean push_undo);
gboolean gimp_layer_get_linked (const GimpLayer *layer);
#endif /* __GIMP_LAYER_H__ */

View File

@ -636,7 +636,7 @@ layer_translate_invoker (Gimp *gimp,
{
floating_layer = gimp_image_floating_sel (gimage);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_LINKED,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_DISPLACE,
_("Move Layer"));
if (floating_layer)
@ -648,8 +648,11 @@ layer_translate_invoker (Gimp *gimp,
{
tmp_layer = (GimpLayer *) layer_list->data;
if ((tmp_layer == layer) || gimp_layer_get_linked (tmp_layer))
gimp_item_translate (GIMP_ITEM (tmp_layer), offx, offy, TRUE);
if ((tmp_layer == layer) || gimp_item_get_linked (GIMP_ITEM (tmp_layer)))
gimp_item_translate (GIMP_ITEM (tmp_layer),
offx,
offy,
TRUE);
}
if (floating_layer)
@ -768,7 +771,7 @@ layer_set_offsets_invoker (Gimp *gimp,
{
floating_layer = gimp_image_floating_sel (gimage);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_LINKED,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_DISPLACE,
_("Move Layer"));
if (floating_layer)
@ -780,10 +783,11 @@ layer_set_offsets_invoker (Gimp *gimp,
{
tmp_layer = (GimpLayer *) layer_list->data;
if ((tmp_layer == layer) || gimp_layer_get_linked (tmp_layer))
if ((tmp_layer == layer) || gimp_item_get_linked (GIMP_ITEM (tmp_layer)))
gimp_item_translate (GIMP_ITEM (tmp_layer),
(offx - GIMP_ITEM (layer)->offset_x),
(offy - GIMP_ITEM (layer)->offset_y), TRUE);
offx - GIMP_ITEM (layer)->offset_x,
offy - GIMP_ITEM (layer)->offset_y,
TRUE);
}
if (floating_layer)
@ -1863,7 +1867,7 @@ layer_get_linked_invoker (Gimp *gimp,
return_args = procedural_db_return_args (&layer_get_linked_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_layer_get_linked (layer);
return_args[1].value.pdb_int = gimp_item_get_linked (GIMP_ITEM (layer));
return return_args;
}
@ -1917,7 +1921,7 @@ layer_set_linked_invoker (Gimp *gimp,
linked = args[1].value.pdb_int ? TRUE : FALSE;
if (success)
gimp_layer_set_linked (layer, linked, TRUE);
gimp_item_set_linked (GIMP_ITEM (layer), linked, TRUE);
return procedural_db_return_args (&layer_set_linked_proc, success);
}

View File

@ -254,7 +254,7 @@ init_edit_selection (GimpTool *tool,
gimp_image_undo_group_start (gdisp->gimage,
edit_type == EDIT_MASK_TRANSLATE ?
GIMP_UNDO_GROUP_MASK :
GIMP_UNDO_GROUP_LAYER_DISPLACE,
GIMP_UNDO_GROUP_ITEM_DISPLACE,
undo_desc);
active_drawable = gimp_image_active_drawable (gdisp->gimage);
@ -329,10 +329,8 @@ init_edit_selection (GimpTool *tool,
layer = (GimpLayer *) layer_list->data;
if ((layer != (GimpLayer *) active_drawable) &&
gimp_layer_get_linked (layer))
gimp_item_get_linked (GIMP_ITEM (layer)))
{
g_print ("linked!\n");
gimp_item_offsets (GIMP_ITEM (layer), &x3, &y3);
x4 = x3 + gimp_item_width (GIMP_ITEM (layer));
@ -541,9 +539,10 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
layer = (GimpLayer *) layer_list->data;
if (layer == gdisp->gimage->active_layer ||
gimp_layer_get_linked (layer))
gimp_item_get_linked (GIMP_ITEM (layer)))
{
gimp_layer_translate (layer, xoffset, yoffset, TRUE);
gimp_item_translate (GIMP_ITEM (layer), xoffset, yoffset,
TRUE);
}
}
@ -589,7 +588,7 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
layer = gimp_image_get_active_layer (gdisp->gimage);
floating_sel_relax (layer, TRUE);
gimp_layer_translate (layer, xoffset, yoffset, TRUE);
gimp_item_translate (GIMP_ITEM (layer), xoffset, yoffset, TRUE);
floating_sel_rigor (layer, TRUE);
if (edit_select->first_move)
@ -734,7 +733,7 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
layer = (GimpLayer *) layer_list->data;
if ((layer != gdisp->gimage->active_layer) &&
gimp_layer_get_linked (layer))
gimp_item_get_linked (GIMP_ITEM (layer)))
{
gimp_item_offsets (GIMP_ITEM (layer), &x3, &y3);
@ -1009,7 +1008,7 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
if (translate_mask)
undo_type = GIMP_UNDO_GROUP_MASK;
else
undo_type = GIMP_UNDO_GROUP_LAYER_DISPLACE;
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
undo = gimp_undo_stack_peek (gdisp->gimage->undo_stack);
@ -1088,9 +1087,10 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
layer = (GimpLayer *) layer_list->data;
if ((layer == gdisp->gimage->active_layer) ||
gimp_layer_get_linked (layer))
gimp_item_get_linked (GIMP_ITEM (layer)))
{
gimp_layer_translate (layer, inc_x, inc_y, push_undo);
gimp_item_translate (GIMP_ITEM (layer), inc_x, inc_y,
push_undo);
}
}
@ -1100,7 +1100,7 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
case EDIT_FLOATING_SEL_TRANSLATE:
floating_sel_relax (layer, push_undo);
gimp_layer_translate (layer, inc_x, inc_y, push_undo);
gimp_item_translate (GIMP_ITEM (layer), inc_x, inc_y, push_undo);
floating_sel_rigor (layer, push_undo);
break;
}

View File

@ -37,6 +37,7 @@
#include "vectors/gimpvectors.h"
#include "gimpchanneltreeview.h"
#include "gimpcellrenderertoggle.h"
#include "gimpdnd.h"
#include "gimpitemtreeview.h"
#include "gimpitemfactory.h"
@ -68,6 +69,11 @@ static void gimp_item_tree_view_destroy (GtkObject *object);
static void gimp_item_tree_view_real_set_image (GimpItemTreeView *view,
GimpImage *gimage);
static void gimp_item_tree_view_set_container (GimpContainerView *view,
GimpContainer *container);
static gpointer gimp_item_tree_view_insert_item (GimpContainerView *view,
GimpViewable *viewable,
gint index);
static void gimp_item_tree_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
@ -124,6 +130,13 @@ static void gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
const gchar *name,
GimpItemTreeView *view);
static void gimp_item_tree_view_linked_changed (GimpItem *item,
GimpItemTreeView *view);
static void gimp_item_tree_view_chain_clicked (GtkCellRendererToggle *toggle,
gchar *path,
GdkModifierType state,
GimpItemTreeView *view);
static guint view_signals[LAST_SIGNAL] = { 0 };
@ -187,6 +200,8 @@ gimp_item_tree_view_class_init (GimpItemTreeViewClass *klass)
gtk_object_class->destroy = gimp_item_tree_view_destroy;
container_view_class->set_container = gimp_item_tree_view_set_container;
container_view_class->insert_item = gimp_item_tree_view_insert_item;
container_view_class->select_item = gimp_item_tree_view_select_item;
container_view_class->activate_item = gimp_item_tree_view_activate_item;
container_view_class->context_item = gimp_item_tree_view_context_item;
@ -218,10 +233,15 @@ static void
gimp_item_tree_view_init (GimpItemTreeView *view,
GimpItemTreeViewClass *view_class)
{
GimpEditor *editor;
gchar *str;
GimpContainerTreeView *tree_view;
GimpEditor *editor;
gchar *str;
editor = GIMP_EDITOR (view);
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
editor = GIMP_EDITOR (view);
view->model_column_linked = tree_view->n_model_columns;
tree_view->model_columns[tree_view->n_model_columns++] = G_TYPE_BOOLEAN;
view->gimage = NULL;
view->item_type = G_TYPE_NONE;
@ -290,6 +310,8 @@ gimp_item_tree_view_init (GimpItemTreeView *view,
gtk_widget_set_sensitive (view->duplicate_button, FALSE);
gtk_widget_set_sensitive (view->edit_button, FALSE);
gtk_widget_set_sensitive (view->delete_button, FALSE);
view->linked_changed_handler_id = 0;
}
static GObject *
@ -300,6 +322,7 @@ gimp_item_tree_view_constructor (GType type,
GimpContainerTreeView *tree_view;
GimpItemTreeView *item_view;
GObject *object;
GtkTreeViewColumn *column;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
@ -316,6 +339,23 @@ gimp_item_tree_view_constructor (GType type,
G_CALLBACK (gimp_item_tree_view_name_edited),
item_view);
column = gtk_tree_view_column_new ();
gtk_tree_view_insert_column (tree_view->view, column, 0);
item_view->chain_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_LINKED);
gtk_tree_view_column_pack_start (column, item_view->chain_cell, FALSE);
gtk_tree_view_column_set_attributes (column, item_view->chain_cell,
"active",
item_view->model_column_linked,
NULL);
tree_view->toggle_cells = g_list_prepend (tree_view->toggle_cells,
item_view->chain_cell);
g_signal_connect (item_view->chain_cell, "clicked",
G_CALLBACK (gimp_item_tree_view_chain_clicked),
item_view);
return object;
}
@ -491,6 +531,57 @@ gimp_item_tree_view_real_set_image (GimpItemTreeView *view,
/* GimpContainerView methods */
static void
gimp_item_tree_view_set_container (GimpContainerView *view,
GimpContainer *container)
{
GimpItemTreeView *item_view;
item_view = GIMP_ITEM_TREE_VIEW (view);
if (view->container)
{
gimp_container_remove_handler (view->container,
item_view->linked_changed_handler_id);
}
GIMP_CONTAINER_VIEW_CLASS (parent_class)->set_container (view, container);
if (view->container)
{
item_view->linked_changed_handler_id =
gimp_container_add_handler (view->container, "linked_changed",
G_CALLBACK (gimp_item_tree_view_linked_changed),
view);
}
}
static gpointer
gimp_item_tree_view_insert_item (GimpContainerView *view,
GimpViewable *viewable,
gint index)
{
GimpContainerTreeView *tree_view;
GimpItemTreeView *item_view;
GimpItem *item;
GtkTreeIter *iter;
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
item_view = GIMP_ITEM_TREE_VIEW (view);
iter = GIMP_CONTAINER_VIEW_CLASS (parent_class)->insert_item (view, viewable,
index);
item = GIMP_ITEM (viewable);
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
item_view->model_column_linked,
gimp_item_get_linked (item),
-1);
return iter;
}
static void
gimp_item_tree_view_select_item (GimpContainerView *view,
GimpViewable *item,
@ -964,3 +1055,63 @@ gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
gtk_tree_path_free (path);
}
/* "Linked" callbacks */
static void
gimp_item_tree_view_linked_changed (GimpItem *item,
GimpItemTreeView *view)
{
GimpContainerView *container_view;
GimpContainerTreeView *tree_view;
GtkTreeIter *iter;
container_view = GIMP_CONTAINER_VIEW (view);
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
iter = g_hash_table_lookup (container_view->hash_table, item);
if (iter)
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
view->model_column_linked,
gimp_item_get_linked (item),
-1);
}
static void
gimp_item_tree_view_chain_clicked (GtkCellRendererToggle *toggle,
gchar *path_str,
GdkModifierType state,
GimpItemTreeView *view)
{
GimpContainerTreeView *tree_view;
GtkTreePath *path;
GtkTreeIter iter;
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
path = gtk_tree_path_new_from_string (path_str);
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
{
GimpPreviewRenderer *renderer;
GimpItem *item;
gboolean linked;
gtk_tree_model_get (tree_view->model, &iter,
tree_view->model_column_renderer, &renderer,
-1);
g_object_get (toggle,
"active", &linked,
NULL);
item = GIMP_ITEM (renderer->viewable);
gimp_item_set_linked (item, ! linked, TRUE);
g_object_unref (renderer);
}
gtk_tree_path_free (path);
}

View File

@ -79,6 +79,12 @@ struct _GimpItemTreeView
GtkWidget *duplicate_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
gint model_column_linked;
GtkCellRenderer *chain_cell;
/*< private >*/
GQuark linked_changed_handler_id;
};
struct _GimpItemTreeViewClass

View File

@ -94,13 +94,6 @@ static void gimp_layer_tree_view_layer_signal_handler
static void gimp_layer_tree_view_update_options (GimpLayerTreeView *view,
GimpLayer *layer);
static void gimp_layer_tree_view_linked_changed (GimpLayer *layer,
GimpLayerTreeView *view);
static void gimp_layer_tree_view_chain_clicked (GtkCellRendererToggle *toggle,
gchar *path,
GdkModifierType state,
GimpLayerTreeView *view);
static void gimp_layer_tree_view_mask_update (GimpLayerTreeView *view,
GtkTreeIter *iter,
GimpLayer *layer);
@ -222,9 +215,6 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
drawable_view = GIMP_DRAWABLE_TREE_VIEW (view);
view->model_column_linked = tree_view->n_model_columns;
tree_view->model_columns[tree_view->n_model_columns++] = G_TYPE_BOOLEAN;
view->model_column_mask = tree_view->n_model_columns;
tree_view->model_columns[tree_view->n_model_columns++] = GIMP_TYPE_PREVIEW_RENDERER;
@ -309,7 +299,6 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
view->mode_changed_handler_id = 0;
view->opacity_changed_handler_id = 0;
view->preserve_trans_changed_handler_id = 0;
view->linked_changed_handler_id = 0;
view->mask_changed_handler_id = 0;
}
@ -321,23 +310,12 @@ gimp_layer_tree_view_constructor (GType type,
GimpContainerTreeView *tree_view;
GimpLayerTreeView *layer_view;
GObject *object;
GtkTreeViewColumn *column;
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);
column = gtk_tree_view_column_new ();
gtk_tree_view_insert_column (tree_view->view, column, 1);
layer_view->chain_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_LINKED);
gtk_tree_view_column_pack_start (column, layer_view->chain_cell, FALSE);
gtk_tree_view_column_set_attributes (column, layer_view->chain_cell,
"active",
layer_view->model_column_linked,
NULL);
layer_view->mask_cell = gimp_cell_renderer_viewable_new ();
gtk_tree_view_column_pack_start (tree_view->main_column,
layer_view->mask_cell,
@ -350,15 +328,9 @@ gimp_layer_tree_view_constructor (GType type,
layer_view->model_column_mask_visible,
NULL);
tree_view->toggle_cells = g_list_prepend (tree_view->toggle_cells,
layer_view->chain_cell);
tree_view->renderer_cells = g_list_prepend (tree_view->renderer_cells,
layer_view->mask_cell);
g_signal_connect (layer_view->chain_cell, "clicked",
G_CALLBACK (gimp_layer_tree_view_chain_clicked),
layer_view);
g_signal_connect (tree_view->renderer_cell, "clicked",
G_CALLBACK (gimp_layer_tree_view_layer_clicked),
layer_view);
@ -412,8 +384,6 @@ gimp_layer_tree_view_set_container (GimpContainerView *view,
layer_view->opacity_changed_handler_id);
gimp_container_remove_handler (view->container,
layer_view->preserve_trans_changed_handler_id);
gimp_container_remove_handler (view->container,
layer_view->linked_changed_handler_id);
gimp_container_remove_handler (view->container,
layer_view->mask_changed_handler_id);
}
@ -434,10 +404,6 @@ gimp_layer_tree_view_set_container (GimpContainerView *view,
gimp_container_add_handler (view->container, "preserve_trans_changed",
G_CALLBACK (gimp_layer_tree_view_layer_signal_handler),
view);
layer_view->linked_changed_handler_id =
gimp_container_add_handler (view->container, "linked_changed",
G_CALLBACK (gimp_layer_tree_view_linked_changed),
view);
layer_view->mask_changed_handler_id =
gimp_container_add_handler (view->container, "mask_changed",
G_CALLBACK (gimp_layer_tree_view_mask_changed),
@ -463,11 +429,6 @@ gimp_layer_tree_view_insert_item (GimpContainerView *view,
layer = GIMP_LAYER (viewable);
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
layer_view->model_column_linked,
gimp_layer_get_linked (layer),
-1);
gimp_layer_tree_view_mask_update (layer_view, iter, layer);
return iter;
@ -803,66 +764,6 @@ gimp_layer_tree_view_update_options (GimpLayerTreeView *view,
#undef UNBLOCK
/* "Linked" callbacks */
static void
gimp_layer_tree_view_linked_changed (GimpLayer *layer,
GimpLayerTreeView *view)
{
GimpContainerView *container_view;
GimpContainerTreeView *tree_view;
GtkTreeIter *iter;
container_view = GIMP_CONTAINER_VIEW (view);
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
iter = g_hash_table_lookup (container_view->hash_table, layer);
if (iter)
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
view->model_column_linked,
gimp_layer_get_linked (layer),
-1);
}
static void
gimp_layer_tree_view_chain_clicked (GtkCellRendererToggle *toggle,
gchar *path_str,
GdkModifierType state,
GimpLayerTreeView *view)
{
GimpContainerTreeView *tree_view;
GtkTreePath *path;
GtkTreeIter iter;
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
path = gtk_tree_path_new_from_string (path_str);
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
{
GimpPreviewRenderer *renderer;
GimpLayer *layer;
gboolean linked;
gtk_tree_model_get (tree_view->model, &iter,
tree_view->model_column_renderer, &renderer,
-1);
g_object_get (toggle,
"active", &linked,
NULL);
layer = GIMP_LAYER (renderer->viewable);
gimp_layer_set_linked (layer, !linked, TRUE);
g_object_unref (renderer);
}
gtk_tree_path_free (path);
}
/* Layer Mask callbacks */
static void

View File

@ -47,11 +47,9 @@ struct _GimpLayerTreeView
GtkWidget *anchor_button;
gint model_column_linked;
gint model_column_mask;
gint model_column_mask_visible;
GtkCellRenderer *chain_cell;
GtkCellRenderer *mask_cell;
/*< private >*/

View File

@ -669,7 +669,12 @@ xcf_load_layer_props (XcfInfo *info,
}
break;
case PROP_LINKED:
info->cp += xcf_read_int32 (info->fp, (guint32 *) &layer->linked, 1);
{
gboolean linked;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &linked, 1);
gimp_item_set_linked (GIMP_ITEM (layer), linked, FALSE);
}
break;
case PROP_PRESERVE_TRANSPARENCY:
info->cp +=

View File

@ -440,7 +440,7 @@ xcf_save_layer_props (XcfInfo *info,
xcf_check_error (xcf_save_prop (info, gimage, PROP_VISIBLE, error,
gimp_drawable_get_visible (GIMP_DRAWABLE (layer))));
xcf_check_error (xcf_save_prop (info, gimage, PROP_LINKED,
error, layer->linked));
error, GIMP_ITEM (layer)->linked));
xcf_check_error (xcf_save_prop (info, gimage, PROP_PRESERVE_TRANSPARENCY,
error, layer->preserve_trans));

View File

@ -400,7 +400,7 @@ HELP
desc => "Offset in $_ direction" }
}
&layer_change_invoke('LAYER_LINKED', 'Move Layer', <<'CODE');
&layer_change_invoke('ITEM_DISPLACE', 'Move Layer', <<'CODE');
{
for (layer_list = GIMP_LIST (gimage->layers)->list;
layer_list;
@ -408,8 +408,11 @@ HELP
{
tmp_layer = (GimpLayer *) layer_list->data;
if ((tmp_layer == layer) || gimp_layer_get_linked (tmp_layer))
gimp_item_translate (GIMP_ITEM (tmp_layer), offx, offy, TRUE);
if ((tmp_layer == layer) || gimp_item_get_linked (GIMP_ITEM (tmp_layer)))
gimp_item_translate (GIMP_ITEM (tmp_layer),
offx,
offy,
TRUE);
}
}
CODE
@ -449,7 +452,7 @@ HELP
foreach (qw(x y)) {
$invoke{code} =~
s/, (off$_)/,\n\t\t\t ($1 - GIMP_ITEM (layer)->offset_$_)/;
s/(off$_),/$1 - GIMP_ITEM (layer)->offset_$_,/;
}
}
@ -586,7 +589,7 @@ CODE2
&layer_accessors('mode', 'enum GimpLayerModeEffects', 'combination mode', 0, 1);
&layer_accessors('linked', 'boolean', 'linked state', 0, 1,
<<'CODE');
<<'CODE', 'item', 'GIMP_ITEM (layer)');
$author = $copyright = 'Wolfgang Hofer';
$date = '1998';