Difference between revisions of "Hacking:Code Snippets/GObject"

From GIMP Developer Wiki
Jump to: navigation, search
(Header)
(Implementation)
Line 41: Line 41:
  
  
G_DEFINE_TYPE_WITH_CODE (GimpCageConfig, gimp_cage_config,
+
G_DEFINE_TYPE (GimpCageConfig,
                        GIMP_TYPE_IMAGE_MAP_CONFIG,
+
              gimp_cage_config,
                        G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
+
              GIMP_TYPE_IMAGE_MAP_CONFIG)
                                                NULL))
+
  
 
static void
 
static void

Revision as of 09:56, 24 March 2011

The example described here is a GObject implementation of the following Java class:

class GimpCageConfig : public GimpImageMapConfig
{
  public:
    GimpCageConfig() {};
    virtual ~GimpCageConfig() {};
};


Header

#define GIMP_TYPE_CAGE_CONFIG            (gimp_cage_config_get_type ())
#define GIMP_CAGE_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CAGE_CONFIG, GimpCageConfig))
#define GIMP_CAGE_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CAGE_CONFIG, GimpCageConfigClass))
#define GIMP_IS_CAGE_CONFIG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CAGE_CONFIG))
#define GIMP_IS_CAGE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CAGE_CONFIG))
#define GIMP_CAGE_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CAGE_CONFIG, GimpCageConfigClass))


typedef struct _GimpCageConfigClass GimpCageConfigClass;

struct _GimpCageConfig
{
  GimpImageMapConfig parent_instance;
};

struct _GimpCageConfigClass
{
  GimpImageMapConfigClass parent_class;
};

GType gimp_cage_config_get_type (void) G_GNUC_CONST;

Implementation

#include "gimpcageconfig.h"

static void gimp_cage_config_finalize (GObject *object);


G_DEFINE_TYPE (GimpCageConfig,
               gimp_cage_config,
               GIMP_TYPE_IMAGE_MAP_CONFIG)

static void
gimp_cage_config_class_init (GimpCageConfigClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
  object_class->finalize     = gimp_cage_config_finalize;
}

static void
gimp_cage_config_finalize (GObject *object)
{
  GimpCageConfig  *gcc = GIMP_CAGE_CONFIG (object);

  G_OBJECT_CLASS (parent_class)->finalize (object);
}