app: make the GimpResource dummy class the parent of GimpData

It does absolutely nothing except sitting there, providing an is-a
relation (both ways because GimpData is its only subclass). This will
simplify having more libgimp API on GimpResource, without having to
add different PDB code for app and libgimp.
This commit is contained in:
Michael Natterer 2023-06-05 13:17:53 +02:00
parent a4920611d1
commit bb7ed43eac
7 changed files with 35 additions and 38 deletions

View File

@ -139,6 +139,7 @@ typedef struct _GimpToolItem GimpToolItem;
typedef struct _GimpDataFactory GimpDataFactory;
typedef struct _GimpDataLoaderFactory GimpDataLoaderFactory;
typedef struct _GimpResource GimpResource;
typedef struct _GimpData GimpData;
typedef struct _GimpBrush GimpBrush;
typedef struct _GimpBrushCache GimpBrushCache;

View File

@ -109,7 +109,7 @@ static gchar * gimp_data_get_identifier (GimpTagged *tagged);
static gchar * gimp_data_get_checksum (GimpTagged *tagged);
G_DEFINE_TYPE_WITH_CODE (GimpData, gimp_data, GIMP_TYPE_VIEWABLE,
G_DEFINE_TYPE_WITH_CODE (GimpData, gimp_data, GIMP_TYPE_RESOURCE,
G_ADD_PRIVATE (GimpData)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
gimp_data_tagged_iface_init))

View File

@ -22,7 +22,7 @@
#define __GIMP_DATA_H__
#include "gimpviewable.h"
#include "gimpresource.h"
typedef enum
@ -47,14 +47,14 @@ typedef struct _GimpDataClass GimpDataClass;
struct _GimpData
{
GimpViewable parent_instance;
GimpResource parent_instance;
GimpDataPrivate *priv;
};
struct _GimpDataClass
{
GimpViewableClass parent_class;
GimpResourceClass parent_class;
/* signals */
void (* dirty) (GimpData *data);

View File

@ -22,32 +22,20 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "core-types.h"
#include "gimpresource.h"
/* This class exists to support gimp_param_spec_resource,
* which is needed to communicate with libgimp.
* So that gimp_param_spec_resource has a GIMP_TYPE_RESOURCE on the app side.
*
* This class on libgimp side is a superclass.
* On app side of wire, it is not a superclass (e.g. GimpBrush does not inherit.)
* On app side, the class is never inherited and never instantiated.
*
* The code is derived from libgimp/gimpresource.c
*/
G_DEFINE_TYPE (GimpResource, gimp_resource, GIMP_TYPE_VIEWABLE)
G_DEFINE_TYPE (GimpResource, gimp_resource, G_TYPE_OBJECT)
/* Class construction */
static void
gimp_resource_class_init (GimpResourceClass *klass)
{
g_debug("gimp_resource_class_init");
}
/* Instance construction. */
static void
gimp_resource_init (GimpResource *self)
{
g_debug("gimp_resource_init");
}

View File

@ -18,15 +18,32 @@
#ifndef __GIMP_RESOURCE_H__
#define __GIMP_RESOURCE_H__
#include "gimpviewable.h"
#define GIMP_TYPE_RESOURCE (gimp_resource_get_type ())
G_DECLARE_DERIVABLE_TYPE (GimpResource, gimp_resource, GIMP, RESOURCE, GObject)
#define GIMP_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RESOURCE, GimpResource))
#define GIMP_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RESOURCE, GimpResourceClass))
#define GIMP_IS_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RESOURCE))
#define GIMP_IS_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_RESOURCE))
#define GIMP_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_RESOURCE, GimpResourceClass))
typedef struct _GimpResourceClass GimpResourceClass;
struct _GimpResource
{
GimpViewable parent_instance;
};
struct _GimpResourceClass
{
GObjectClass parent_class;
/* Padding for future expansion */
gpointer padding[8];
GimpViewableClass parent_class;
};
GType gimp_resource_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_RESOURCE_H__ */

View File

@ -31,16 +31,15 @@
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpdisplay.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimpselection.h"
/* resource types. */
#include "core/gimpbrush.h"
#include "core/gimpgradient.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "core/gimpselection.h"
#include "text/gimpfont.h"
#include "core/gimpparamspecs.h"
@ -52,10 +51,6 @@
#include "libgimp/gimpgpparams.h"
#undef GIMP_VALUE_HOLDS_RESOURCE
#define GIMP_VALUE_HOLDS_RESOURCE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), \
GIMP_TYPE_DATA))
/* include the implementation, they are shared between app/ and
* libgimp/ but need different headers.
*/

View File

@ -942,11 +942,7 @@ gimp_param_spec_display (const gchar *name,
static void
gimp_param_resource_class_init (GParamSpecClass *klass)
{
#ifdef LIBGIMP_COMPILATION
klass->value_type = GIMP_TYPE_RESOURCE;
#else
klass->value_type = GIMP_TYPE_DATA;
#endif
klass->value_validate = gimp_param_resource_validate;
}