gimp r27778 - in trunk: . app/core
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27778 - in trunk: . app/core
- Date: Thu, 11 Dec 2008 22:04:05 +0000 (UTC)
Author: martinn
Date: Thu Dec 11 22:04:05 2008
New Revision: 27778
URL: http://svn.gnome.org/viewvc/gimp?rev=27778&view=rev
Log:
Bug 555954 â Merge Tagging of Gimp Resources GSoC Project
Partial merge of code from Aurimas JuÅka.
* app/core/gimptag.c: A new minimal GimpTag type with only a
gimp_tag_equals() class function so that we can
* app/core/gimptagged.c
* app/core/gimpdata.c (gimp_data_add_tag, gimp_data_remove_tag):
Adapt these to GimpTag being an object instead of a GQuark.
* app/core/core-types.h: Update GimpTag typedef.
* app/core/Makefile.am: Add gimptag.[ch].
Added:
trunk/app/core/gimptag.c
trunk/app/core/gimptag.h
Modified:
trunk/ChangeLog
trunk/app/core/Makefile.am
trunk/app/core/core-types.h
trunk/app/core/gimpdata.c
trunk/app/core/gimptagged.c
trunk/app/core/gimptagged.h
Modified: trunk/app/core/Makefile.am
==============================================================================
--- trunk/app/core/Makefile.am (original)
+++ trunk/app/core/Makefile.am Thu Dec 11 22:04:05 2008
@@ -323,6 +323,8 @@
gimpstrokeoptions.h \
gimpsubprogress.c \
gimpsubprogress.h \
+ gimptag.c \
+ gimptag.h \
gimptagged.c \
gimptagged.h \
gimptemplate.c \
Modified: trunk/app/core/core-types.h
==============================================================================
--- trunk/app/core/core-types.h (original)
+++ trunk/app/core/core-types.h Thu Dec 11 22:04:05 2008
@@ -148,6 +148,7 @@
typedef struct _GimpPdbProgress GimpPdbProgress;
typedef struct _GimpProjection GimpProjection;
typedef struct _GimpSubProgress GimpSubProgress;
+typedef struct _GimpTag GimpTag;
/* interfaces */
@@ -169,13 +170,6 @@
typedef guint32 GimpTattoo;
-/* tags */
-
-typedef GQuark GimpTag;
-#define gimp_tag_new(name) g_quark_from_string (name)
-#define gimp_tag_get_name(tag) g_quark_to_string (name)
-
-
/* functions */
typedef void (* GimpInitStatusFunc) (const gchar *text1,
Modified: trunk/app/core/gimpdata.c
==============================================================================
--- trunk/app/core/gimpdata.c (original)
+++ trunk/app/core/gimpdata.c Thu Dec 11 22:04:05 2008
@@ -42,6 +42,7 @@
#include "gimp-utils.h"
#include "gimpdata.h"
#include "gimpmarshal.h"
+#include "gimptag.h"
#include "gimptagged.h"
#include "gimp-intl.h"
@@ -89,9 +90,9 @@
static void gimp_data_real_dirty (GimpData *data);
static gboolean gimp_data_add_tag (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
static gboolean gimp_data_remove_tag (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
static GList * gimp_data_get_tags (GimpTagged *tagged);
@@ -349,38 +350,40 @@
static gboolean
gimp_data_add_tag (GimpTagged *tagged,
- GimpTag tag)
+ GimpTag *tag)
{
GimpData *data = GIMP_DATA (tagged);
GList *list;
for (list = data->tags; list; list = list->next)
{
- GimpTag this = GPOINTER_TO_UINT (list->data);
+ GimpTag *this = GIMP_TAG (list->data);
- if (this == tag)
+ if (gimp_tag_equals (tag, this))
return FALSE;
}
- data->tags = g_list_prepend (data->tags, GUINT_TO_POINTER (tag));
+ g_object_ref (tag);
+ data->tags = g_list_prepend (data->tags, tag);
return TRUE;
}
static gboolean
gimp_data_remove_tag (GimpTagged *tagged,
- GimpTag tag)
+ GimpTag *tag)
{
GimpData *data = GIMP_DATA (tagged);
GList *list;
for (list = data->tags; list; list = list->next)
{
- GimpTag this = GPOINTER_TO_UINT (list->data);
+ GimpTag *this = GIMP_TAG (list->data);
- if (this == tag)
+ if (gimp_tag_equals (tag, this))
{
data->tags = g_list_delete_link (data->tags, list);
+ g_object_unref (tag);
return TRUE;
}
}
Added: trunk/app/core/gimptag.c
==============================================================================
--- (empty file)
+++ trunk/app/core/gimptag.c Thu Dec 11 22:04:05 2008
@@ -0,0 +1,63 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimptag.c
+ * Copyright (C) 2008 Aurimas JuÅka <aurisj svn gnome 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 <glib-object.h>
+
+#include "core-types.h"
+
+#include "gimptag.h"
+
+
+G_DEFINE_TYPE (GimpTag, gimp_tag, G_TYPE_OBJECT)
+
+#define parent_class gimp_tag_parent_class
+
+
+static void
+gimp_tag_class_init (GimpTagClass *klass)
+{
+}
+
+static void
+gimp_tag_init (GimpTag *tag)
+{
+}
+
+/**
+ * gimp_tag_equals:
+ * @tag: a gimp tag.
+ * @other: another gimp tag to compare with.
+ *
+ * Compares tags for equality according to tag comparison rules.
+ *
+ * Return value: TRUE if tags are equal, FALSE otherwise.
+ **/
+gboolean
+gimp_tag_equals (const GimpTag *tag,
+ const GimpTag *other)
+{
+ g_return_val_if_fail (GIMP_IS_TAG (tag), FALSE);
+ g_return_val_if_fail (GIMP_IS_TAG (other), FALSE);
+
+ return FALSE;
+}
Added: trunk/app/core/gimptag.h
==============================================================================
--- (empty file)
+++ trunk/app/core/gimptag.h Thu Dec 11 22:04:05 2008
@@ -0,0 +1,57 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimptag.h
+ * Copyright (C) 2008 Aurimas JuÅka <aurisj svn gnome 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_TAG_H__
+#define __GIMP_TAG_H__
+
+
+#include <glib-object.h>
+
+
+#define GIMP_TYPE_TAG (gimp_tag_get_type ())
+#define GIMP_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TAG, GimpTag))
+#define GIMP_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TAG, GimpTagClass))
+#define GIMP_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TAG))
+#define GIMP_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TAG))
+#define GIMP_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TAG, GimpTagClass))
+
+
+typedef struct _GimpTagClass GimpTagClass;
+
+struct _GimpTag
+{
+ GObject parent_instance;
+};
+
+struct _GimpTagClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType gimp_tag_get_type (void) G_GNUC_CONST;
+
+gboolean gimp_tag_equals (const GimpTag *tag,
+ const GimpTag *other);
+
+
+#endif /* __GIMP_TAG_H__ */
+
Modified: trunk/app/core/gimptagged.c
==============================================================================
--- trunk/app/core/gimptagged.c (original)
+++ trunk/app/core/gimptagged.c Thu Dec 11 22:04:05 2008
@@ -26,6 +26,7 @@
#include "core-types.h"
#include "gimpmarshal.h"
+#include "gimptag.h"
#include "gimptagged.h"
@@ -77,18 +78,18 @@
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpTaggedInterface, tag_added),
NULL, NULL,
- gimp_marshal_VOID__INT,
+ g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- G_TYPE_INT);
+ GIMP_TYPE_TAG);
gimp_tagged_signals[TAG_REMOVED] =
g_signal_new ("tag-removed",
GIMP_TYPE_TAGGED,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpTaggedInterface, tag_removed),
NULL, NULL,
- gimp_marshal_VOID__INT,
+ g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- G_TYPE_INT);
+ GIMP_TYPE_TAG);
initialized = TRUE;
}
@@ -105,7 +106,7 @@
**/
void
gimp_tagged_add_tag (GimpTagged *tagged,
- GimpTag tag)
+ GimpTag *tag)
{
g_return_if_fail (GIMP_IS_TAGGED (tagged));
@@ -126,7 +127,7 @@
**/
void
gimp_tagged_remove_tag (GimpTagged *tagged,
- GimpTag tag)
+ GimpTag *tag)
{
g_return_if_fail (GIMP_IS_TAGGED (tagged));
Modified: trunk/app/core/gimptagged.h
==============================================================================
--- trunk/app/core/gimptagged.h (original)
+++ trunk/app/core/gimptagged.h Thu Dec 11 22:04:05 2008
@@ -37,15 +37,15 @@
/* signals */
void (* tag_added) (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
void (* tag_removed) (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
/* virtual functions */
gboolean (* add_tag) (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
gboolean (* remove_tag) (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
GList * (* get_tags) (GimpTagged *tagged);
gchar * (* get_identifier) (GimpTagged *tagged);
gchar * (* get_checksum) (GimpTagged *tagged);
@@ -55,9 +55,9 @@
GType gimp_tagged_interface_get_type (void) G_GNUC_CONST;
void gimp_tagged_add_tag (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
void gimp_tagged_remove_tag (GimpTagged *tagged,
- GimpTag tag);
+ GimpTag *tag);
GList * gimp_tagged_get_tags (GimpTagged *tagged);
gchar * gimp_tagged_get_identifier (GimpTagged *tagged);
gchar * gimp_tagged_get_checksum (GimpTagged *tagged);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]