mirror of https://github.com/GNOME/gimp.git
Add some item tree infrastructure that will be needed later
- add gimp_image_get_layer_tree(), channel_tree() and vectors_tree() - change GimpItem::get_container() to GimpItem::get_tree() - implement gimp_item_get_container() using gimp_item_get_tree()
This commit is contained in:
parent
25d39f2daa
commit
804e692c86
|
@ -76,8 +76,7 @@ static gchar * gimp_channel_get_description (GimpViewable *viewable,
|
|||
gchar **tooltip);
|
||||
|
||||
static gboolean gimp_channel_is_attached (const GimpItem *item);
|
||||
static GimpContainer *
|
||||
gimp_channel_get_container (GimpItem *item);
|
||||
static GimpItemTree * gimp_channel_get_tree (GimpItem *item);
|
||||
static GimpItem * gimp_channel_duplicate (GimpItem *item,
|
||||
GType new_type);
|
||||
static void gimp_channel_convert (GimpItem *item,
|
||||
|
@ -250,7 +249,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
|
|||
viewable_class->default_stock_id = "gimp-channel";
|
||||
|
||||
item_class->is_attached = gimp_channel_is_attached;
|
||||
item_class->get_container = gimp_channel_get_container;
|
||||
item_class->get_tree = gimp_channel_get_tree;
|
||||
item_class->duplicate = gimp_channel_duplicate;
|
||||
item_class->convert = gimp_channel_convert;
|
||||
item_class->translate = gimp_channel_translate;
|
||||
|
@ -384,14 +383,14 @@ gimp_channel_is_attached (const GimpItem *item)
|
|||
GIMP_OBJECT (item)));
|
||||
}
|
||||
|
||||
static GimpContainer *
|
||||
gimp_channel_get_container (GimpItem *item)
|
||||
static GimpItemTree *
|
||||
gimp_channel_get_tree (GimpItem *item)
|
||||
{
|
||||
if (gimp_item_is_attached (item))
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
||||
return gimp_image_get_channels (image);
|
||||
return gimp_image_get_channel_tree (image);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -2825,6 +2825,30 @@ gimp_image_get_projection (const GimpImage *image)
|
|||
|
||||
/* layers / channels / vectors */
|
||||
|
||||
GimpItemTree *
|
||||
gimp_image_get_layer_tree (const GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->layers;
|
||||
}
|
||||
|
||||
GimpItemTree *
|
||||
gimp_image_get_channel_tree (const GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->channels;
|
||||
}
|
||||
|
||||
GimpItemTree *
|
||||
gimp_image_get_vectors_tree (const GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->vectors;
|
||||
}
|
||||
|
||||
GimpContainer *
|
||||
gimp_image_get_layers (const GimpImage *image)
|
||||
{
|
||||
|
|
|
@ -359,6 +359,10 @@ GimpProjection * gimp_image_get_projection (const GimpImage *image);
|
|||
|
||||
/* layers / channels / vectors */
|
||||
|
||||
GimpItemTree * gimp_image_get_layer_tree (const GimpImage *image);
|
||||
GimpItemTree * gimp_image_get_channel_tree (const GimpImage *image);
|
||||
GimpItemTree * gimp_image_get_vectors_tree (const GimpImage *image);
|
||||
|
||||
GimpContainer * gimp_image_get_layers (const GimpImage *image);
|
||||
GimpContainer * gimp_image_get_channels (const GimpImage *image);
|
||||
GimpContainer * gimp_image_get_vectors (const GimpImage *image);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "gimpimage-undo-push.h"
|
||||
#include "gimpitem.h"
|
||||
#include "gimpitem-preview.h"
|
||||
#include "gimpitemtree.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimpparasitelist.h"
|
||||
|
@ -180,7 +181,7 @@ gimp_item_class_init (GimpItemClass *klass)
|
|||
|
||||
klass->is_attached = NULL;
|
||||
klass->is_content_locked = gimp_item_real_is_content_locked;
|
||||
klass->get_container = NULL;
|
||||
klass->get_tree = NULL;
|
||||
klass->duplicate = gimp_item_real_duplicate;
|
||||
klass->convert = gimp_item_real_convert;
|
||||
klass->rename = gimp_item_real_rename;
|
||||
|
@ -688,10 +689,22 @@ gimp_item_is_attached (const GimpItem *item)
|
|||
return GIMP_ITEM_GET_CLASS (item)->is_attached (item);
|
||||
}
|
||||
|
||||
GimpItemTree *
|
||||
gimp_item_get_tree (GimpItem *item)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
|
||||
|
||||
if (GIMP_ITEM_GET_CLASS (item)->get_tree)
|
||||
return GIMP_ITEM_GET_CLASS (item)->get_tree (item);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpContainer *
|
||||
gimp_item_get_container (GimpItem *item)
|
||||
{
|
||||
GimpViewable *parent;
|
||||
GimpItemTree *tree;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
|
||||
|
||||
|
@ -700,8 +713,10 @@ gimp_item_get_container (GimpItem *item)
|
|||
if (parent)
|
||||
return gimp_viewable_get_children (GIMP_VIEWABLE (parent));
|
||||
|
||||
if (GIMP_ITEM_GET_CLASS (item)->get_container)
|
||||
return GIMP_ITEM_GET_CLASS (item)->get_container (item);
|
||||
tree = gimp_item_get_tree (item);
|
||||
|
||||
if (tree)
|
||||
return tree->container;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ struct _GimpItemClass
|
|||
/* virtual functions */
|
||||
gboolean (* is_attached) (const GimpItem *item);
|
||||
gboolean (* is_content_locked) (const GimpItem *item);
|
||||
GimpContainer * (* get_container) (GimpItem *item);
|
||||
GimpItemTree * (* get_tree) (GimpItem *item);
|
||||
GimpItem * (* duplicate) (GimpItem *item,
|
||||
GType new_type);
|
||||
void (* convert) (GimpItem *item,
|
||||
|
@ -143,6 +143,7 @@ gboolean gimp_item_is_removed (const GimpItem *item);
|
|||
|
||||
gboolean gimp_item_is_attached (const GimpItem *item);
|
||||
|
||||
GimpItemTree * gimp_item_get_tree (GimpItem *item);
|
||||
GimpContainer * gimp_item_get_container (GimpItem *item);
|
||||
GList * gimp_item_get_container_iter (GimpItem *item);
|
||||
gint gimp_item_get_index (GimpItem *item);
|
||||
|
|
|
@ -97,8 +97,7 @@ static gchar * gimp_layer_get_description (GimpViewable *viewable,
|
|||
|
||||
static void gimp_layer_removed (GimpItem *item);
|
||||
static gboolean gimp_layer_is_attached (const GimpItem *item);
|
||||
static GimpContainer *
|
||||
gimp_layer_get_container (GimpItem *item);
|
||||
static GimpItemTree * gimp_layer_get_tree (GimpItem *item);
|
||||
static GimpItem * gimp_layer_duplicate (GimpItem *item,
|
||||
GType new_type);
|
||||
static void gimp_layer_convert (GimpItem *item,
|
||||
|
@ -244,7 +243,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
|
|||
|
||||
item_class->removed = gimp_layer_removed;
|
||||
item_class->is_attached = gimp_layer_is_attached;
|
||||
item_class->get_container = gimp_layer_get_container;
|
||||
item_class->get_tree = gimp_layer_get_tree;
|
||||
item_class->duplicate = gimp_layer_duplicate;
|
||||
item_class->convert = gimp_layer_convert;
|
||||
item_class->rename = gimp_layer_rename;
|
||||
|
@ -488,14 +487,14 @@ gimp_layer_is_attached (const GimpItem *item)
|
|||
GIMP_OBJECT (item)));
|
||||
}
|
||||
|
||||
static GimpContainer *
|
||||
gimp_layer_get_container (GimpItem *item)
|
||||
static GimpItemTree *
|
||||
gimp_layer_get_tree (GimpItem *item)
|
||||
{
|
||||
if (gimp_item_is_attached (item))
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
||||
return gimp_image_get_layers (image);
|
||||
return gimp_image_get_layer_tree (image);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -47,7 +47,7 @@ enum
|
|||
|
||||
static gboolean gimp_layer_mask_is_attached (const GimpItem *item);
|
||||
static gboolean gimp_layer_mask_is_content_locked (const GimpItem *item);
|
||||
static GimpContainer * gimp_layer_mask_get_container (GimpItem *item);
|
||||
static GimpItemTree * gimp_layer_mask_get_tree (GimpItem *item);
|
||||
static GimpItem * gimp_layer_mask_duplicate (GimpItem *item,
|
||||
GType new_type);
|
||||
static gboolean gimp_layer_mask_rename (GimpItem *item,
|
||||
|
@ -104,7 +104,7 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
|
|||
|
||||
item_class->is_attached = gimp_layer_mask_is_attached;
|
||||
item_class->is_content_locked = gimp_layer_mask_is_content_locked;
|
||||
item_class->get_container = gimp_layer_mask_get_container;
|
||||
item_class->get_tree = gimp_layer_mask_get_tree;
|
||||
item_class->duplicate = gimp_layer_mask_duplicate;
|
||||
item_class->rename = gimp_layer_mask_rename;
|
||||
item_class->translate_desc = _("Move Layer Mask");
|
||||
|
@ -143,8 +143,8 @@ gimp_layer_mask_is_attached (const GimpItem *item)
|
|||
gimp_item_is_attached (GIMP_ITEM (layer)));
|
||||
}
|
||||
|
||||
static GimpContainer *
|
||||
gimp_layer_mask_get_container (GimpItem *item)
|
||||
static GimpItemTree *
|
||||
gimp_layer_mask_get_tree (GimpItem *item)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@
|
|||
|
||||
|
||||
static gboolean gimp_selection_is_attached (const GimpItem *item);
|
||||
static GimpContainer *
|
||||
gimp_selection_get_container (GimpItem *item);
|
||||
static GimpItemTree * gimp_selection_get_tree (GimpItem *item);
|
||||
static void gimp_selection_translate (GimpItem *item,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
|
@ -145,7 +144,7 @@ gimp_selection_class_init (GimpSelectionClass *klass)
|
|||
viewable_class->default_stock_id = "gimp-selection";
|
||||
|
||||
item_class->is_attached = gimp_selection_is_attached;
|
||||
item_class->get_container = gimp_selection_get_container;
|
||||
item_class->get_tree = gimp_selection_get_tree;
|
||||
item_class->translate = gimp_selection_translate;
|
||||
item_class->scale = gimp_selection_scale;
|
||||
item_class->resize = gimp_selection_resize;
|
||||
|
@ -193,8 +192,8 @@ gimp_selection_is_attached (const GimpItem *item)
|
|||
GIMP_CHANNEL (item));
|
||||
}
|
||||
|
||||
static GimpContainer *
|
||||
gimp_selection_get_container (GimpItem *item)
|
||||
static GimpItemTree *
|
||||
gimp_selection_get_tree (GimpItem *item)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ static gint64 gimp_vectors_get_memsize (GimpObject *object,
|
|||
gint64 *gui_size);
|
||||
|
||||
static gboolean gimp_vectors_is_attached (const GimpItem *item);
|
||||
static GimpContainer *
|
||||
gimp_vectors_get_container (GimpItem *item);
|
||||
static GimpItemTree * gimp_vectors_get_tree (GimpItem *item);
|
||||
static GimpItem * gimp_vectors_duplicate (GimpItem *item,
|
||||
GType new_type);
|
||||
static void gimp_vectors_convert (GimpItem *item,
|
||||
|
@ -182,7 +181,7 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
|
|||
viewable_class->default_stock_id = "gimp-path";
|
||||
|
||||
item_class->is_attached = gimp_vectors_is_attached;
|
||||
item_class->get_container = gimp_vectors_get_container;
|
||||
item_class->get_tree = gimp_vectors_get_tree;
|
||||
item_class->duplicate = gimp_vectors_duplicate;
|
||||
item_class->convert = gimp_vectors_convert;
|
||||
item_class->translate = gimp_vectors_translate;
|
||||
|
@ -275,14 +274,14 @@ gimp_vectors_is_attached (const GimpItem *item)
|
|||
GIMP_OBJECT (item)));
|
||||
}
|
||||
|
||||
static GimpContainer *
|
||||
gimp_vectors_get_container (GimpItem *item)
|
||||
static GimpItemTree *
|
||||
gimp_vectors_get_tree (GimpItem *item)
|
||||
{
|
||||
if (gimp_item_is_attached (item))
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
||||
return gimp_image_get_vectors (image);
|
||||
return gimp_image_get_vectors_tree (image);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue