~ldotlopez/eina/github-copy

« back to all changes in this revision

Viewing changes to eina/ext/eina-extension.h

  • Committer: Luis López
  • Date: 2011-07-11 07:00:44 UTC
  • Revision ID: luis@ugluk.cent.uji.es-20110711070044-su2jelehui4elesi
Snapshot 20110711090043

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __EINA_EXTENSION_H__
2
 
#define __EINA_EXTENSION_H__
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 
2
 *
 
3
 * Plugin engine for Eina, heavily based on the code from Rhythmbox,
 
4
 * which is based heavily on the code from eina.
 
5
 *
 
6
 * Copyright (C) 2002-2005 Paolo Maggi
 
7
 *               2006 James Livingston  <jrl@ids.org.au>
 
8
 *               2007 Bastien Nocera <hadess@hadess.net>
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or modify
 
11
 * it under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation; either version 2 of the License, or
 
13
 * (at your option) any later version.
 
14
 *
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU General Public License
 
21
 * along with this program; if not, write to the Free Software
 
22
 * Foundation, Inc., 51 Franklin St, Fifth Floor,
 
23
 * Boston, MA 02110-1301  USA.
 
24
 *
 
25
 * Sunday 13th May 2007: Bastien Nocera: Add exception clause.
 
26
 * See license_change file for details.
 
27
 *
 
28
 */
 
29
 
 
30
#ifndef __EINA_PLUGIN_H__
 
31
#define __EINA_PLUGIN_H__
3
32
 
4
33
#if HAVE_CONFIG_H
5
34
#include <config.h>
6
35
#endif
7
 
 
8
36
#include <glib/gi18n.h>
 
37
#include <libpeas/peas.h>
9
38
#include <gel/gel.h>
10
 
#include <libpeas/peas.h>
11
39
#include <eina/ext/eina-activatable.h>
12
 
 
13
 
#define EINA_DEFINE_EXTENSION_HEADERS(TypeName,type_name) \
14
 
        typedef struct _##TypeName        TypeName;        \
15
 
        typedef struct _##TypeName##Class TypeName##Class; \
16
 
        struct _##TypeName        { PeasExtensionBase      parent_instance; }; \
17
 
        struct _##TypeName##Class { PeasExtensionBaseClass parent_class;    }; \
18
 
        GType                 type_name##_get_type (void) G_GNUC_CONST;        \
19
 
        G_MODULE_EXPORT void  peas_register_types  (PeasObjectModule *module);
20
 
 
21
 
#define EINA_DEFINE_EXTENSION(TypeName,type_name,_G_TYPE_NAME) \
22
 
        \
23
 
        static void eina_activatable_iface_init (EinaActivatableInterface *iface); \
24
 
        static void type_name##_init            (TypeName *plugin)       { } \
25
 
        static void type_name##_class_init      (TypeName##Class *klass) { } \
26
 
        static void type_name##_class_finalize  (TypeName##Class *klass) { } \
27
 
        \
28
 
        G_DEFINE_DYNAMIC_TYPE_EXTENDED (TypeName, \
29
 
                type_name,                            \
30
 
                PEAS_TYPE_EXTENSION_BASE,             \
31
 
                0,                                    \
32
 
                G_IMPLEMENT_INTERFACE_DYNAMIC (EINA_TYPE_ACTIVATABLE, eina_activatable_iface_init)) \
33
 
        \
34
 
        static gboolean type_name##_activate   (EinaActivatable *activatable, EinaApplication *application, GError **error); \
35
 
        static gboolean type_name##_deactivate (EinaActivatable *activatable, EinaApplication *application, GError **error); \
36
 
        \
37
 
        static void eina_activatable_iface_init (EinaActivatableInterface *iface) { \
38
 
                iface->activate   = type_name##_activate;   \
39
 
                iface->deactivate = type_name##_deactivate; \
40
 
        }                                               \
41
 
        \
42
 
        G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module) { \
43
 
                type_name##_register_type (G_TYPE_MODULE (module));                 \
44
 
                peas_object_module_register_extension_type (module,                 \
45
 
                EINA_TYPE_ACTIVATABLE,  \
46
 
                _G_TYPE_NAME);          \
47
 
        }
48
 
 
49
 
#endif
 
40
#include <eina/ext/eina-application.h>
 
41
 
 
42
G_BEGIN_DECLS
 
43
 
 
44
#define EINA_PLUGIN_REGISTER_WITH_CODE(TYPE_NAME,TypeName,type_name,TYPE_CODE) \
 
45
typedef struct {                         \
 
46
        PeasExtensionBaseClass parent_class; \
 
47
} TypeName##Class;                   \
 
48
typedef struct {             \
 
49
        PeasExtensionBase parent;    \
 
50
        TypeName##Private *priv; \
 
51
} TypeName;            \
 
52
\
 
53
GType type_name##_get_type (void) G_GNUC_CONST; \
 
54
static gboolean type_name##_activate     (EinaActivatable *plugin, EinaApplication *application, GError **error); \
 
55
static gboolean type_name##_deactivate   (EinaActivatable *plugin, EinaApplication *application, GError **error); \
 
56
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);       \
 
57
static void eina_activatable_iface_init  (EinaActivatableInterface *iface); \
 
58
\
 
59
enum {               \
 
60
        PROP_0,          \
 
61
        PROP_APPLICATION \
 
62
}; \
 
63
\
 
64
G_DEFINE_DYNAMIC_TYPE_EXTENDED (TypeName, \
 
65
        type_name,                                  \
 
66
        PEAS_TYPE_EXTENSION_BASE,                   \
 
67
        0,                                          \
 
68
        G_IMPLEMENT_INTERFACE_DYNAMIC (EINA_TYPE_ACTIVATABLE, eina_activatable_iface_init) TYPE_CODE) \
 
69
\
 
70
static void     eina_activatable_iface_init (EinaActivatableInterface *iface) { \
 
71
        iface->activate   = type_name##_activate;   \
 
72
        iface->deactivate = type_name##_deactivate; \
 
73
} \
 
74
\
 
75
static void type_name##_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { \
 
76
        switch (prop_id) { \
 
77
        case PROP_APPLICATION:  \
 
78
                g_object_set_data_full (object, "application", g_value_dup_object (value), g_object_unref);     \
 
79
                break;        \
 
80
        default:          \
 
81
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); \
 
82
                break;         \
 
83
        } \
 
84
} \
 
85
\
 
86
static void     type_name##_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { \
 
87
        switch (prop_id) { \
 
88
                case PROP_APPLICATION: \
 
89
                g_value_set_object (value, g_object_get_data (object, "application")); \
 
90
                break; \
 
91
        default: \
 
92
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); \
 
93
                break; \
 
94
        } \
 
95
} \
 
96
static void type_name##_class_init (TypeName##Class *klass) { \
 
97
        GObjectClass *object_class = G_OBJECT_CLASS (klass); \
 
98
        object_class->set_property = type_name##_set_property; \
 
99
        object_class->get_property = type_name##_get_property; \
 
100
        g_object_class_override_property (object_class, PROP_APPLICATION, "application"); \
 
101
        g_type_class_add_private (klass, sizeof (TypeName##Private)); \
 
102
} \
 
103
static void type_name##_class_finalize (TypeName##Class *klass) { } \
 
104
static void type_name##_init (TypeName *plugin) { \
 
105
        plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin, TYPE_NAME, TypeName##Private); \
 
106
} \
 
107
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module) { \
 
108
        type_name##_register_type (G_TYPE_MODULE (module)); \
 
109
        peas_object_module_register_extension_type (module, EINA_TYPE_ACTIVATABLE, TYPE_NAME); \
 
110
}
 
111
 
 
112
#define EINA_PLUGIN_REGISTER(TYPE_NAME,TypeName,type_name) \
 
113
        EINA_PLUGIN_REGISTER_WITH_CODE(TYPE_NAME,TypeName,type_name,)
 
114
 
 
115
G_END_DECLS
 
116
 
 
117
#endif  /* __EINA_PLUGIN_H__ */
50
118