mirror of https://github.com/GNOME/gimp.git
app/core/Makefile.am app/core/core-types.h new GimpList subclass which
* app/core/Makefile.am * app/core/core-types.h * app/core/gimpitemstack.[ch]: new GimpList subclass which (for now) does nothing but taking ownership of its children by the means of g_object_ref_sink(). * app/core/gimpdrawablestack.[ch]: derive from GimpItemStack. * app/core/gimpimage.c: use a GimpItemStack instead of a plain GimpList for the list of vectors. Remove code which takes ownerships of added items from gimp_image_add_layer(), add_channel() and add_vectors(). svn path=/trunk/; revision=27568
This commit is contained in:
parent
477110a7a3
commit
a3d556c0ca
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2008-11-06 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/core-types.h
|
||||
* app/core/gimpitemstack.[ch]: new GimpList subclass which (for
|
||||
now) does nothing but taking ownership of its children by the
|
||||
means of g_object_ref_sink().
|
||||
|
||||
* app/core/gimpdrawablestack.[ch]: derive from GimpItemStack.
|
||||
|
||||
* app/core/gimpimage.c: use a GimpItemStack instead of a plain
|
||||
GimpList for the list of vectors. Remove code which takes
|
||||
ownerships of added items from gimp_image_add_layer(),
|
||||
add_channel() and add_vectors().
|
||||
|
||||
2008-11-06 Nils Philippsen <nils@redhat.com>
|
||||
|
||||
* plug-ins/file-jpeg/jpeg-save.c: fix memory leak
|
||||
|
|
|
@ -244,6 +244,8 @@ libappcore_a_sources = \
|
|||
gimpitem-preview.h \
|
||||
gimpitempropundo.c \
|
||||
gimpitempropundo.h \
|
||||
gimpitemstack.c \
|
||||
gimpitemstack.h \
|
||||
gimpitemundo.c \
|
||||
gimpitemundo.h \
|
||||
gimplayer.c \
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef struct _GimpContainer GimpContainer;
|
|||
typedef struct _GimpList GimpList;
|
||||
typedef struct _GimpDocumentList GimpDocumentList;
|
||||
typedef struct _GimpDrawableStack GimpDrawableStack;
|
||||
typedef struct _GimpItemStack GimpItemStack;
|
||||
typedef struct _GimpToolPresets GimpToolPresets;
|
||||
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ static void gimp_drawable_stack_drawable_visible (GimpItem *item,
|
|||
GimpDrawableStack *stack);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpDrawableStack, gimp_drawable_stack, GIMP_TYPE_LIST)
|
||||
G_DEFINE_TYPE (GimpDrawableStack, gimp_drawable_stack, GIMP_TYPE_ITEM_STACK)
|
||||
|
||||
#define parent_class gimp_drawable_stack_parent_class
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef __GIMP_DRAWABLE_STACK_H__
|
||||
#define __GIMP_DRAWABLE_STACK_H__
|
||||
|
||||
#include "core/gimplist.h"
|
||||
#include "gimpitemstack.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DRAWABLE_STACK (gimp_drawable_stack_get_type ())
|
||||
|
@ -36,14 +36,14 @@ typedef struct _GimpDrawableStackClass GimpDrawableStackClass;
|
|||
|
||||
struct _GimpDrawableStack
|
||||
{
|
||||
GimpList parent_instance;
|
||||
GimpItemStack parent_instance;
|
||||
|
||||
GeglNode *graph;
|
||||
GeglNode *graph;
|
||||
};
|
||||
|
||||
struct _GimpDrawableStackClass
|
||||
{
|
||||
GimpListClass parent_class;
|
||||
GimpItemStackClass parent_class;
|
||||
|
||||
void (* update) (GimpDrawableStack *stack,
|
||||
gint x,
|
||||
|
|
|
@ -611,7 +611,7 @@ gimp_image_init (GimpImage *image)
|
|||
|
||||
image->layers = gimp_drawable_stack_new (GIMP_TYPE_LAYER);
|
||||
image->channels = gimp_drawable_stack_new (GIMP_TYPE_CHANNEL);
|
||||
image->vectors = gimp_list_new (GIMP_TYPE_VECTORS, TRUE);
|
||||
image->vectors = gimp_item_stack_new (GIMP_TYPE_VECTORS);
|
||||
image->layer_stack = NULL;
|
||||
|
||||
g_signal_connect_swapped (image->layers, "update",
|
||||
|
@ -2947,9 +2947,7 @@ gimp_image_add_layer (GimpImage *image,
|
|||
/* Don't add at a non-existing index */
|
||||
position = MIN (position, gimp_container_num_children (image->layers));
|
||||
|
||||
g_object_ref_sink (layer);
|
||||
gimp_container_insert (image->layers, GIMP_OBJECT (layer), position);
|
||||
g_object_unref (layer);
|
||||
|
||||
/* notify the layers dialog of the currently active layer */
|
||||
gimp_image_set_active_layer (image, layer);
|
||||
|
@ -3275,9 +3273,7 @@ gimp_image_add_channel (GimpImage *image,
|
|||
/* Don't add at a non-existing index */
|
||||
position = MIN (position, gimp_container_num_children (image->channels));
|
||||
|
||||
g_object_ref_sink (channel);
|
||||
gimp_container_insert (image->channels, GIMP_OBJECT (channel), position);
|
||||
g_object_unref (channel);
|
||||
|
||||
/* notify this image of the currently active channel */
|
||||
gimp_image_set_active_channel (image, channel);
|
||||
|
@ -3507,9 +3503,7 @@ gimp_image_add_vectors (GimpImage *image,
|
|||
/* Don't add at a non-existing index */
|
||||
position = MIN (position, gimp_container_num_children (image->vectors));
|
||||
|
||||
g_object_ref_sink (vectors);
|
||||
gimp_container_insert (image->vectors, GIMP_OBJECT (vectors), position);
|
||||
g_object_unref (vectors);
|
||||
|
||||
/* notify this image of the currently active vectors */
|
||||
gimp_image_set_active_vectors (image, vectors);
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpitemstack.c
|
||||
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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 <gegl.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimpitem.h"
|
||||
#include "gimpitemstack.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static GObject * gimp_item_stack_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
|
||||
static void gimp_item_stack_add (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static void gimp_item_stack_remove (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpItemStack, gimp_item_stack, GIMP_TYPE_LIST)
|
||||
|
||||
#define parent_class gimp_item_stack_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_item_stack_class_init (GimpItemStackClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpContainerClass *container_class = GIMP_CONTAINER_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_item_stack_constructor;
|
||||
|
||||
container_class->add = gimp_item_stack_add;
|
||||
container_class->remove = gimp_item_stack_remove;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_stack_init (GimpItemStack *stack)
|
||||
{
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_item_stack_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpContainer *container;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
container = GIMP_CONTAINER (object);
|
||||
|
||||
g_assert (g_type_is_a (container->children_type, GIMP_TYPE_ITEM));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_stack_add (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
g_object_ref_sink (object);
|
||||
|
||||
GIMP_CONTAINER_CLASS (parent_class)->add (container, object);
|
||||
|
||||
g_object_unref (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_stack_remove (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GIMP_CONTAINER_CLASS (parent_class)->remove (container, object);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpContainer *
|
||||
gimp_item_stack_new (GType item_type)
|
||||
{
|
||||
g_return_val_if_fail (g_type_is_a (item_type, GIMP_TYPE_ITEM), NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_ITEM_STACK,
|
||||
"name", g_type_name (item_type),
|
||||
"children-type", item_type,
|
||||
"policy", GIMP_CONTAINER_POLICY_STRONG,
|
||||
"unique-names", TRUE,
|
||||
NULL);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpitemstack.h
|
||||
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_ITEM_STACK_H__
|
||||
#define __GIMP_ITEM_STACK_H__
|
||||
|
||||
#include "gimplist.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_ITEM_STACK (gimp_item_stack_get_type ())
|
||||
#define GIMP_ITEM_STACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ITEM_STACK, GimpItemStack))
|
||||
#define GIMP_ITEM_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ITEM_STACK, GimpItemStackClass))
|
||||
#define GIMP_IS_ITEM_STACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ITEM_STACK))
|
||||
#define GIMP_IS_ITEM_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ITEM_STACK))
|
||||
|
||||
|
||||
typedef struct _GimpItemStackClass GimpItemStackClass;
|
||||
|
||||
struct _GimpItemStack
|
||||
{
|
||||
GimpList parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpItemStackClass
|
||||
{
|
||||
GimpListClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_item_stack_get_type (void) G_GNUC_CONST;
|
||||
GimpContainer * gimp_item_stack_new (GType item_type);
|
||||
|
||||
|
||||
#endif /* __GIMP_ITEM_STACK_H__ */
|
Loading…
Reference in New Issue