~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to plugins/rb-plugin-macros.h

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011  Jonathan Matthew <jonathan@d14n.org>
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 *  The Rhythmbox authors hereby grant permission for non-GPL compatible
 
10
 *  GStreamer plugins to be used and distributed together with GStreamer
 
11
 *  and Rhythmbox. This permission is above and beyond the permissions granted
 
12
 *  by the GPL license by which Rhythmbox is covered. If you modify this code
 
13
 *  you may extend this exception to your version of the code, but you are not
 
14
 *  obligated to do so. If you do not wish to do so, delete this exception
 
15
 *  statement from your version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * You should have received a copy of the GNU General Public License
 
23
 * along with this program; if not, write to the Free Software
 
24
 * Foundation, Inc., 51 Franklin St, Fifth Floor,
 
25
 * Boston, MA 02110-1301  USA.
 
26
 */
 
27
 
 
28
#ifndef RB_PLUGIN_MACROS_H
 
29
#define RB_PLUGIN_MACROS_H
 
30
 
 
31
#include <libpeas/peas.h>
 
32
 
 
33
G_BEGIN_DECLS
 
34
 
 
35
enum {
 
36
        PROP_0,
 
37
        PROP_OBJECT
 
38
};
 
39
 
 
40
#define RB_DEFINE_PLUGIN(TYPE_NAME, TypeName, type_name, TYPE_CODE)     \
 
41
 GType type_name##_get_type (void) G_GNUC_CONST;                        \
 
42
 static void impl_activate (PeasActivatable *plugin);                   \
 
43
 static void impl_deactivate (PeasActivatable *plugin);                 \
 
44
 static void peas_activatable_iface_init (PeasActivatableInterface *iface); \
 
45
 \
 
46
 G_DEFINE_DYNAMIC_TYPE_EXTENDED (TypeName,                              \
 
47
                                 type_name,                             \
 
48
                                 PEAS_TYPE_EXTENSION_BASE,              \
 
49
                                 0,                                     \
 
50
                                 G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,\
 
51
                                                                peas_activatable_iface_init)\
 
52
                                 TYPE_CODE)                             \
 
53
 \
 
54
 static void peas_activatable_iface_init (PeasActivatableInterface *iface) \
 
55
 {                                                                      \
 
56
        iface->activate = impl_activate;                                \
 
57
        iface->deactivate = impl_deactivate;                            \
 
58
 }                                                                      \
 
59
 \
 
60
 static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) \
 
61
 {                                                                      \
 
62
        switch (prop_id) {                                              \
 
63
        case PROP_OBJECT:                                               \
 
64
                g_object_set_data_full (object,                         \
 
65
                                        "rb-shell",                     \
 
66
                                        g_value_dup_object (value),     \
 
67
                                        g_object_unref);                \
 
68
                break;                                                  \
 
69
        default:                                                        \
 
70
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); \
 
71
                break;                                                  \
 
72
        }                                                               \
 
73
 }                                                                      \
 
74
 static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) \
 
75
 {                                                                      \
 
76
        switch (prop_id) {                                              \
 
77
        case PROP_OBJECT:                                               \
 
78
                g_value_set_object (value, g_object_get_data (object, "rb-shell")); \
 
79
                break;                                                  \
 
80
        default:                                                        \
 
81
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); \
 
82
                break;                                                  \
 
83
        }                                                               \
 
84
 }                                                                      \
 
85
 static void type_name##_class_init (TypeName##Class *klass)            \
 
86
 {                                                                      \
 
87
        GObjectClass *object_class = G_OBJECT_CLASS (klass);            \
 
88
        object_class->set_property = set_property;                      \
 
89
        object_class->get_property = get_property;                      \
 
90
        g_object_class_override_property (object_class, PROP_OBJECT, "object"); \
 
91
 }                                                                      \
 
92
 static void type_name##_class_finalize (TypeName##Class *klass)        \
 
93
 {                                                                      \
 
94
 }
 
95
 
 
96
 
 
97
G_END_DECLS
 
98
 
 
99
#endif /* RB_PLUGIN_MACROS_H */