[gimp] Add a GimpGroupLayer class (not used yet)
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add a GimpGroupLayer class (not used yet)
- Date: Mon, 3 Aug 2009 21:25:31 +0000 (UTC)
commit 7dafae7f2694cb8e23d9efeac2aaa4bbab28270e
Author: Michael Natterer <mitch gimp org>
Date: Mon Aug 3 23:24:46 2009 +0200
Add a GimpGroupLayer class (not used yet)
app/core/Makefile.am | 2 +
app/core/core-types.h | 1 +
app/core/gimpgrouplayer.c | 171 +++++++++++++++++++++++++++++++++++++++++++++
app/core/gimpgrouplayer.h | 56 +++++++++++++++
4 files changed, 230 insertions(+), 0 deletions(-)
---
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index e4162ec..5d792e9 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -183,6 +183,8 @@ libappcore_a_sources = \
gimpgradient-save.h \
gimpgrid.c \
gimpgrid.h \
+ gimpgrouplayer.c \
+ gimpgoruplayer.h \
gimpguide.c \
gimpguide.h \
gimpguideundo.c \
diff --git a/app/core/core-types.h b/app/core/core-types.h
index b831adc..dce9853 100644
--- a/app/core/core-types.h
+++ b/app/core/core-types.h
@@ -112,6 +112,7 @@ typedef struct _GimpChannel GimpChannel;
typedef struct _GimpLayerMask GimpLayerMask;
typedef struct _GimpSelection GimpSelection;
typedef struct _GimpLayer GimpLayer;
+typedef struct _GimpGroupLayer GimpGroupLayer;
/* undo objects */
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
new file mode 100644
index 0000000..54cd739
--- /dev/null
+++ b/app/core/gimpgrouplayer.c
@@ -0,0 +1,171 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * GimpGroupLayer
+ * Copyright (C) 2009 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gegl.h>
+
+#include "core-types.h"
+
+#include "gimpgrouplayer.h"
+#include "gimpimage.h"
+#include "gimpdrawablestack.h"
+
+#include "gimp-intl.h"
+
+
+static void gimp_group_layer_finalize (GObject *object);
+
+static gint64 gimp_group_layer_get_memsize (GimpObject *object,
+ gint64 *gui_size);
+
+static GimpContainer * gimp_group_layer_get_children (GimpViewable *viewable);
+
+static GimpItem * gimp_group_layer_duplicate (GimpItem *item,
+ GType new_type);
+
+
+G_DEFINE_TYPE (GimpGroupLayer, gimp_group_layer, GIMP_TYPE_LAYER)
+
+#define parent_class gimp_group_layer_parent_class
+
+
+static void
+gimp_group_layer_class_init (GimpGroupLayerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
+ GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
+ GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
+
+ object_class->finalize = gimp_group_layer_finalize;
+
+ gimp_object_class->get_memsize = gimp_group_layer_get_memsize;
+
+ viewable_class->default_stock_id = "gtk-directory";
+ viewable_class->get_children = gimp_group_layer_get_children;
+
+ item_class->duplicate = gimp_group_layer_duplicate;
+
+ item_class->default_name = _("Group Layer");
+ item_class->rename_desc = _("Rename Group Layer");
+ item_class->translate_desc = _("Move Group Layer");
+ item_class->scale_desc = _("Scale Group Layer");
+ item_class->resize_desc = _("Resize Group Layer");
+ item_class->flip_desc = _("Flip Group Layer");
+ item_class->rotate_desc = _("Rotate Group Layer");
+ item_class->transform_desc = _("Transform Group Layer");
+}
+
+static void
+gimp_group_layer_init (GimpGroupLayer *layer)
+{
+ layer->children = gimp_drawable_stack_new (GIMP_TYPE_LAYER);
+}
+
+static void
+gimp_group_layer_finalize (GObject *object)
+{
+ GimpGroupLayer *layer = GIMP_GROUP_LAYER (object);
+
+ if (layer->children)
+ {
+ g_object_unref (layer->children);
+ layer->children = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static gint64
+gimp_group_layer_get_memsize (GimpObject *object,
+ gint64 *gui_size)
+{
+ GimpGroupLayer *layer = GIMP_GROUP_LAYER (object);
+ gint64 memsize = 0;
+
+ memsize += gimp_object_get_memsize (GIMP_OBJECT (layer->children), gui_size);
+
+ return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
+ gui_size);
+}
+
+static GimpContainer *
+gimp_group_layer_get_children (GimpViewable *viewable)
+{
+ GimpGroupLayer *layer = GIMP_GROUP_LAYER (viewable);
+
+ return layer->children;
+}
+
+static GimpItem *
+gimp_group_layer_duplicate (GimpItem *item,
+ GType new_type)
+{
+ GimpItem *new_item;
+
+ g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_GROUP_LAYER), NULL);
+
+ new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
+
+ if (GIMP_IS_GROUP_LAYER (new_item))
+ {
+ GimpGroupLayer *layer = GIMP_GROUP_LAYER (item);
+ GimpGroupLayer *new_layer = GIMP_GROUP_LAYER (new_item);
+ GList *list;
+ gint position;
+
+ for (list = GIMP_LIST (layer->children)->list, position = 0;
+ list;
+ list = g_list_next (list))
+ {
+ GimpItem *child = list->data;
+ GimpItem *new_child;
+
+ new_child = gimp_item_duplicate (child, G_TYPE_FROM_INSTANCE (child));
+
+ gimp_container_insert (new_layer->children,
+ GIMP_OBJECT (new_child),
+ position);
+ }
+ }
+
+ return new_item;
+}
+
+GimpLayer *
+gimp_group_layer_new (GimpImage *image)
+{
+ GimpGroupLayer *layer;
+
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ layer = g_object_new (GIMP_TYPE_GROUP_LAYER, NULL);
+
+ gimp_drawable_configure (GIMP_DRAWABLE (layer),
+ image,
+ 0, 0, 1, 1,
+ gimp_image_base_type_with_alpha (image),
+ NULL);
+
+ return GIMP_LAYER (layer);
+}
diff --git a/app/core/gimpgrouplayer.h b/app/core/gimpgrouplayer.h
new file mode 100644
index 0000000..8da16f9
--- /dev/null
+++ b/app/core/gimpgrouplayer.h
@@ -0,0 +1,56 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * GimpGroupLayer
+ * Copyright (C) 2009 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_GROUP_LAYER_H__
+#define __GIMP_GROUP_LAYER_H__
+
+
+#include "core/gimplayer.h"
+
+
+#define GIMP_TYPE_GROUP_LAYER (gimp_group_layer_get_type ())
+#define GIMP_GROUP_LAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_GROUP_LAYER, GimpGroupLayer))
+#define GIMP_GROUP_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_GROUP_LAYER, GimpGroupLayerClass))
+#define GIMP_IS_GROUP_LAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_GROUP_LAYER))
+#define GIMP_IS_GROUP_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_GROUP_LAYER))
+#define GIMP_GROUP_LAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_GROUP_LAYER, GimpGroupLayerClass))
+
+
+typedef struct _GimpGroupLayerClass GimpGroupLayerClass;
+
+struct _GimpGroupLayer
+{
+ GimpLayer parent_instance;
+
+ GimpContainer *children;
+};
+
+struct _GimpGroupLayerClass
+{
+ GimpLayerClass parent_class;
+};
+
+
+GType gimp_group_layer_get_type (void) G_GNUC_CONST;
+
+GimpLayer * gimp_group_layer_new (GimpImage *image);
+
+
+#endif /* __GIMP_GROUP_LAYER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]