Commit dca38528 authored by Martin Nordholts's avatar Martin Nordholts

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].

svn path=/trunk/; revision=27778
parent d975ea72
2008-12-11 Martin Nordholts <martinn@svn.gnome.org>
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].
2008-12-11 Martin Nordholts <martinn@svn.gnome.org>
* app/core/core-types.h: Sort typedefs.
......
......@@ -323,6 +323,8 @@ libappcore_a_sources = \
gimpstrokeoptions.h \
gimpsubprogress.c \
gimpsubprogress.h \
gimptag.c \
gimptag.h \
gimptagged.c \
gimptagged.h \
gimptemplate.c \
......
......@@ -148,6 +148,7 @@ typedef struct _GimpParasiteList GimpParasiteList;
typedef struct _GimpPdbProgress GimpPdbProgress;
typedef struct _GimpProjection GimpProjection;
typedef struct _GimpSubProgress GimpSubProgress;
typedef struct _GimpTag GimpTag;
/* interfaces */
......@@ -169,13 +170,6 @@ typedef struct _GimpScanConvert GimpScanConvert;
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,
......
......@@ -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 gint64 gimp_data_get_memsize (GimpObject *object,
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 @@ gimp_data_real_dirty (GimpData *data)
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;
}
}
......
/* 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;
}
/* 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__ */
......@@ -26,6 +26,7 @@
#include "core-types.h"
#include "gimpmarshal.h"
#include "gimptag.h"
#include "gimptagged.h"
......@@ -77,18 +78,18 @@ gimp_tagged_base_init (gpointer klass)
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 @@ gimp_tagged_base_init (gpointer klass)
**/
void
gimp_tagged_add_tag (GimpTagged *tagged,
GimpTag tag)
GimpTag *tag)
{
g_return_if_fail (GIMP_IS_TAGGED (tagged));
......@@ -126,7 +127,7 @@ gimp_tagged_add_tag (GimpTagged *tagged,
**/
void
gimp_tagged_remove_tag (GimpTagged *tagged,
GimpTag tag)
GimpTag *tag)
{
g_return_if_fail (GIMP_IS_TAGGED (tagged));
......
......@@ -37,15 +37,15 @@ struct _GimpTaggedInterface
/* 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 @@ struct _GimpTaggedInterface
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment