~ctf/unity-settings-daemon/bug1389099_mic_volume_icons

« back to all changes in this revision

Viewing changes to gnome-settings-daemon/gnome-settings-plugin.h

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2014-02-07 11:44:36 UTC
  • Revision ID: package-import@ubuntu.com-20140207114436-7t5u3yvwc4ul7w3e
Tags: upstream-14.04.0
ImportĀ upstreamĀ versionĀ 14.04.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 
2
 *
 
3
 * Copyright (C) 2002-2005 Paolo Maggi
 
4
 * Copyright (C) 2007      William Jon McCann <mccann@jhu.edu>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330,
 
19
 * Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#ifndef __GNOME_SETTINGS_PLUGIN_H__
 
23
#define __GNOME_SETTINGS_PLUGIN_H__
 
24
 
 
25
#include <glib-object.h>
 
26
#include <gmodule.h>
 
27
 
 
28
G_BEGIN_DECLS
 
29
#define GNOME_TYPE_SETTINGS_PLUGIN              (gnome_settings_plugin_get_type())
 
30
#define GNOME_SETTINGS_PLUGIN(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), GNOME_TYPE_SETTINGS_PLUGIN, GnomeSettingsPlugin))
 
31
#define GNOME_SETTINGS_PLUGIN_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass),  GNOME_TYPE_SETTINGS_PLUGIN, GnomeSettingsPluginClass))
 
32
#define GNOME_IS_SETTINGS_PLUGIN(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNOME_TYPE_SETTINGS_PLUGIN))
 
33
#define GNOME_IS_SETTINGS_PLUGIN_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_SETTINGS_PLUGIN))
 
34
#define GNOME_SETTINGS_PLUGIN_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj),  GNOME_TYPE_SETTINGS_PLUGIN, GnomeSettingsPluginClass))
 
35
 
 
36
typedef struct
 
37
{
 
38
        GObject parent;
 
39
} GnomeSettingsPlugin;
 
40
 
 
41
typedef struct
 
42
{
 
43
        GObjectClass parent_class;
 
44
 
 
45
        /* Virtual public methods */
 
46
        void            (*activate)                     (GnomeSettingsPlugin *plugin);
 
47
        void            (*deactivate)                   (GnomeSettingsPlugin *plugin);
 
48
} GnomeSettingsPluginClass;
 
49
 
 
50
GType            gnome_settings_plugin_get_type           (void) G_GNUC_CONST;
 
51
 
 
52
void             gnome_settings_plugin_activate           (GnomeSettingsPlugin *plugin);
 
53
void             gnome_settings_plugin_deactivate         (GnomeSettingsPlugin *plugin);
 
54
 
 
55
#define GSD_DBUS_NAME "org.gnome.SettingsDaemon"
 
56
#define GSD_DBUS_PATH "/org/gnome/SettingsDaemon"
 
57
#define GSD_DBUS_BASE_INTERFACE "org.gnome.SettingsDaemon"
 
58
 
 
59
/*
 
60
 * Utility macro used to register plugins
 
61
 *
 
62
 * use: GNOME_SETTINGS_PLUGIN_REGISTER (PluginName, plugin_name)
 
63
 */
 
64
#define GNOME_SETTINGS_PLUGIN_REGISTER(PluginName, plugin_name)                \
 
65
typedef struct {                                                               \
 
66
        PluginName##Manager *manager;                                          \
 
67
} PluginName##PluginPrivate;                                                   \
 
68
typedef struct {                                                               \
 
69
        GnomeSettingsPlugin    parent;                                         \
 
70
        PluginName##PluginPrivate *priv;                                       \
 
71
} PluginName##Plugin;                                                          \
 
72
typedef struct {                                                               \
 
73
        GnomeSettingsPluginClass parent_class;                                 \
 
74
} PluginName##PluginClass;                                                     \
 
75
GType plugin_name##_plugin_get_type (void) G_GNUC_CONST;                       \
 
76
G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);    \
 
77
                                                                               \
 
78
        G_DEFINE_DYNAMIC_TYPE (PluginName##Plugin,                             \
 
79
                               plugin_name##_plugin,                           \
 
80
                               GNOME_TYPE_SETTINGS_PLUGIN)                     \
 
81
                                                                               \
 
82
G_MODULE_EXPORT GType                                                          \
 
83
register_gnome_settings_plugin (GTypeModule *type_module)                      \
 
84
{                                                                              \
 
85
        plugin_name##_plugin_register_type (type_module);                      \
 
86
                                                                               \
 
87
        return plugin_name##_plugin_get_type();                                \
 
88
}                                                                              \
 
89
                                                                               \
 
90
static void                                                                    \
 
91
plugin_name##_plugin_class_finalize (PluginName##PluginClass * plugin_name##_class) \
 
92
{                                                                              \
 
93
}                                                                              \
 
94
                                                                               \
 
95
static void                                                                    \
 
96
plugin_name##_plugin_init (PluginName##Plugin *plugin)                         \
 
97
{                                                                              \
 
98
        plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE ((plugin),                  \
 
99
                plugin_name##_plugin_get_type(), PluginName##PluginPrivate);   \
 
100
        g_debug (#PluginName " initializing");                                 \
 
101
        plugin->priv->manager = plugin_name##_manager_new ();                  \
 
102
}                                                                              \
 
103
                                                                               \
 
104
static void                                                                    \
 
105
plugin_name##_plugin_finalize (GObject *object)                                \
 
106
{                                                                              \
 
107
        PluginName##Plugin *plugin;                                            \
 
108
        g_return_if_fail (object != NULL);                                     \
 
109
        g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (object, plugin_name##_plugin_get_type())); \
 
110
        g_debug ("PluginName## finalizing");                                   \
 
111
        plugin = G_TYPE_CHECK_INSTANCE_CAST ((object), plugin_name##_plugin_get_type(), PluginName##Plugin); \
 
112
        g_return_if_fail (plugin->priv != NULL);                               \
 
113
        if (plugin->priv->manager != NULL)                                     \
 
114
                g_object_unref (plugin->priv->manager);                        \
 
115
        G_OBJECT_CLASS (plugin_name##_plugin_parent_class)->finalize (object);        \
 
116
}                                                                              \
 
117
                                                                               \
 
118
static void                                                                    \
 
119
impl_activate (GnomeSettingsPlugin *plugin)                                    \
 
120
{                                                                              \
 
121
        GError *error = NULL;                                                  \
 
122
        PluginName##Plugin *plugin_cast;                                       \
 
123
        g_debug ("Activating %s plugin", G_STRINGIFY(plugin_name));            \
 
124
        plugin_cast = G_TYPE_CHECK_INSTANCE_CAST ((plugin), plugin_name##_plugin_get_type(), PluginName##Plugin); \
 
125
        if (!plugin_name##_manager_start (plugin_cast->priv->manager, &error)) { \
 
126
                g_warning ("Unable to start %s manager: %s", G_STRINGIFY(plugin_name), error->message); \
 
127
                g_error_free (error);                                          \
 
128
        }                                                                      \
 
129
}                                                                              \
 
130
                                                                               \
 
131
static void                                                                    \
 
132
impl_deactivate (GnomeSettingsPlugin *plugin)                                  \
 
133
{                                                                              \
 
134
        PluginName##Plugin *plugin_cast;                                       \
 
135
        plugin_cast = G_TYPE_CHECK_INSTANCE_CAST ((plugin), plugin_name##_plugin_get_type(), PluginName##Plugin); \
 
136
        g_debug ("Deactivating %s plugin", G_STRINGIFY (plugin_name));         \
 
137
        plugin_name##_manager_stop (plugin_cast->priv->manager); \
 
138
}                                                                              \
 
139
                                                                               \
 
140
static void                                                                    \
 
141
plugin_name##_plugin_class_init (PluginName##PluginClass *klass)               \
 
142
{                                                                              \
 
143
        GObjectClass           *object_class = G_OBJECT_CLASS (klass);         \
 
144
        GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass); \
 
145
                                                                               \
 
146
        object_class->finalize = plugin_name##_plugin_finalize;                \
 
147
        plugin_class->activate = impl_activate;                                \
 
148
        plugin_class->deactivate = impl_deactivate;                            \
 
149
        g_type_class_add_private (klass, sizeof (PluginName##PluginPrivate));  \
 
150
}
 
151
 
 
152
G_END_DECLS
 
153
 
 
154
#endif  /* __GNOME_SETTINGS_PLUGIN_H__ */