Commit 5149940c authored by Bastien Nocera's avatar Bastien Nocera

plugins: Simplify plugin creation with a huge macro

Shaves about 2.7k lines of code.
parent e2998b46
......@@ -58,22 +58,92 @@ void gnome_settings_plugin_deactivate (GnomeSettingsPlugin *
* use: GNOME_SETTINGS_PLUGIN_REGISTER (PluginName, plugin_name)
*/
#define GNOME_SETTINGS_PLUGIN_REGISTER(PluginName, plugin_name) \
G_DEFINE_DYNAMIC_TYPE (PluginName, \
plugin_name, \
typedef struct { \
PluginName##Manager *manager; \
} PluginName##PluginPrivate; \
typedef struct { \
GnomeSettingsPlugin parent; \
PluginName##PluginPrivate *priv; \
} PluginName##Plugin; \
typedef struct { \
GnomeSettingsPluginClass parent_class; \
} PluginName##PluginClass; \
GType plugin_name##_plugin_get_type (void) G_GNUC_CONST; \
G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module); \
\
G_DEFINE_DYNAMIC_TYPE (PluginName##Plugin, \
plugin_name##_plugin, \
GNOME_TYPE_SETTINGS_PLUGIN) \
\
G_MODULE_EXPORT GType \
register_gnome_settings_plugin (GTypeModule *type_module) \
{ \
plugin_name##_register_type (type_module); \
plugin_name##_plugin_register_type (type_module); \
\
return plugin_name##_plugin_get_type(); \
} \
\
return plugin_name##_get_type(); \
static void \
plugin_name##_plugin_class_finalize (PluginName##PluginClass * plugin_name##_class) \
{ \
} \
\
static void \
plugin_name##_class_finalize (PluginName##Class *plugin_name##_class) \
plugin_name##_plugin_init (PluginName##Plugin *plugin) \
{ \
plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE ((plugin), \
plugin_name##_plugin_get_type(), PluginName##PluginPrivate); \
g_debug ("PluginName## initializing"); \
plugin->priv->manager = plugin_name##_manager_new (); \
} \
\
static void \
plugin_name##_plugin_finalize (GObject *object) \
{ \
PluginName##Plugin *plugin; \
g_return_if_fail (object != NULL); \
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (object, plugin_name##_plugin_get_type())); \
g_debug ("PluginName## finalizing"); \
plugin = G_TYPE_CHECK_INSTANCE_CAST ((object), plugin_name##_plugin_get_type(), PluginName##Plugin); \
g_return_if_fail (plugin->priv != NULL); \
if (plugin->priv->manager != NULL) \
g_object_unref (plugin->priv->manager); \
G_OBJECT_CLASS (plugin_name##_plugin_parent_class)->finalize (object); \
} \
\
static void \
impl_activate (GnomeSettingsPlugin *plugin) \
{ \
GError *error = NULL; \
PluginName##Plugin *plugin_cast; \
g_debug ("Activating %s plugin", G_STRINGIFY(plugin_name)); \
plugin_cast = G_TYPE_CHECK_INSTANCE_CAST ((plugin), plugin_name##_plugin_get_type(), PluginName##Plugin); \
if (!plugin_name##_manager_start (plugin_cast->priv->manager, &error)) { \
g_warning ("Unable to start %s manager: %s", G_STRINGIFY(plugin_name), error->message); \
g_error_free (error); \
} \
} \
\
static void \
impl_deactivate (GnomeSettingsPlugin *plugin) \
{ \
PluginName##Plugin *plugin_cast; \
plugin_cast = G_TYPE_CHECK_INSTANCE_CAST ((plugin), plugin_name##_plugin_get_type(), PluginName##Plugin); \
g_debug ("Deactivating %s plugin", G_STRINGIFY (plugin_name)); \
plugin_name##_manager_stop (plugin_cast->priv->manager); \
} \
\
static void \
plugin_name##_plugin_class_init (PluginName##PluginClass *klass) \
{ \
GObjectClass *object_class = G_OBJECT_CLASS (klass); \
GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass); \
\
object_class->finalize = plugin_name##_plugin_finalize; \
plugin_class->activate = impl_activate; \
plugin_class->deactivate = impl_deactivate; \
g_type_class_add_private (klass, sizeof (PluginName##PluginPrivate)); \
}
G_END_DECLS
......
......@@ -24,82 +24,6 @@
#include <gmodule.h>
#include "gnome-settings-plugin.h"
#include "gsd-a11y-keyboard-plugin.h"
#include "gsd-a11y-keyboard-manager.h"
struct GsdA11yKeyboardPluginPrivate {
GsdA11yKeyboardManager *manager;
};
#define GSD_A11Y_KEYBOARD_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_A11Y_KEYBOARD_PLUGIN, GsdA11yKeyboardPluginPrivate))
GNOME_SETTINGS_PLUGIN_REGISTER (GsdA11yKeyboardPlugin, gsd_a11y_keyboard_plugin)
static void
gsd_a11y_keyboard_plugin_init (GsdA11yKeyboardPlugin *plugin)
{
plugin->priv = GSD_A11Y_KEYBOARD_PLUGIN_GET_PRIVATE (plugin);
g_debug ("GsdA11yKeyboardPlugin initializing");
plugin->priv->manager = gsd_a11y_keyboard_manager_new ();
}
static void
gsd_a11y_keyboard_plugin_finalize (GObject *object)
{
GsdA11yKeyboardPlugin *plugin;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_A11Y_KEYBOARD_PLUGIN (object));
g_debug ("GsdA11yKeyboardPlugin finalizing");
plugin = GSD_A11Y_KEYBOARD_PLUGIN (object);
g_return_if_fail (plugin->priv != NULL);
if (plugin->priv->manager != NULL) {
g_object_unref (plugin->priv->manager);
}
G_OBJECT_CLASS (gsd_a11y_keyboard_plugin_parent_class)->finalize (object);
}
static void
impl_activate (GnomeSettingsPlugin *plugin)
{
gboolean res;
GError *error;
g_debug ("Activating a11y_keyboard plugin");
error = NULL;
res = gsd_a11y_keyboard_manager_start (GSD_A11Y_KEYBOARD_PLUGIN (plugin)->priv->manager, &error);
if (! res) {
g_warning ("Unable to start a11y_keyboard manager: %s", error->message);
g_error_free (error);
}
}
static void
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating a11y_keyboard plugin");
gsd_a11y_keyboard_manager_stop (GSD_A11Y_KEYBOARD_PLUGIN (plugin)->priv->manager);
}
static void
gsd_a11y_keyboard_plugin_class_init (GsdA11yKeyboardPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
object_class->finalize = gsd_a11y_keyboard_plugin_finalize;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
g_type_class_add_private (klass, sizeof (GsdA11yKeyboardPluginPrivate));
}
GNOME_SETTINGS_PLUGIN_REGISTER (GsdA11yKeyboard, gsd_a11y_keyboard)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __GSD_A11Y_KEYBOARD_PLUGIN_H__
#define __GSD_A11Y_KEYBOARD_PLUGIN_H__
#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>
#include "gnome-settings-plugin.h"
G_BEGIN_DECLS
#define GSD_TYPE_A11Y_KEYBOARD_PLUGIN (gsd_a11y_keyboard_plugin_get_type ())
#define GSD_A11Y_KEYBOARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_A11Y_KEYBOARD_PLUGIN, GsdA11yKeyboardPlugin))
#define GSD_A11Y_KEYBOARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_A11Y_KEYBOARD_PLUGIN, GsdA11yKeyboardPluginClass))
#define GSD_IS_A11Y_KEYBOARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_A11Y_KEYBOARD_PLUGIN))
#define GSD_IS_A11Y_KEYBOARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_A11Y_KEYBOARD_PLUGIN))
#define GSD_A11Y_KEYBOARD_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_A11Y_KEYBOARD_PLUGIN, GsdA11yKeyboardPluginClass))
typedef struct GsdA11yKeyboardPluginPrivate GsdA11yKeyboardPluginPrivate;
typedef struct
{
GnomeSettingsPlugin parent;
GsdA11yKeyboardPluginPrivate *priv;
} GsdA11yKeyboardPlugin;
typedef struct
{
GnomeSettingsPluginClass parent_class;
} GsdA11yKeyboardPluginClass;
GType gsd_a11y_keyboard_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */
G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
G_END_DECLS
#endif /* __GSD_A11Y_KEYBOARD_PLUGIN_H__ */
......@@ -24,81 +24,6 @@
#include <gmodule.h>
#include "gnome-settings-plugin.h"
#include "gsd-a11y-settings-plugin.h"
#include "gsd-a11y-settings-manager.h"
struct GsdA11ySettingsPluginPrivate {
GsdA11ySettingsManager *manager;
};
#define GSD_A11Y_SETTINGS_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_A11Y_SETTINGS_PLUGIN, GsdA11ySettingsPluginPrivate))
GNOME_SETTINGS_PLUGIN_REGISTER (GsdA11ySettingsPlugin, gsd_a11y_settings_plugin)
static void
gsd_a11y_settings_plugin_init (GsdA11ySettingsPlugin *plugin)
{
plugin->priv = GSD_A11Y_SETTINGS_PLUGIN_GET_PRIVATE (plugin);
g_debug ("GsdA11ySettingsPlugin initializing");
plugin->priv->manager = gsd_a11y_settings_manager_new ();
}
static void
gsd_a11y_settings_plugin_finalize (GObject *object)
{
GsdA11ySettingsPlugin *plugin;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_A11Y_SETTINGS_PLUGIN (object));
g_debug ("GsdA11ySettingsPlugin finalizing");
plugin = GSD_A11Y_SETTINGS_PLUGIN (object);
g_return_if_fail (plugin->priv != NULL);
if (plugin->priv->manager != NULL) {
g_object_unref (plugin->priv->manager);
}
G_OBJECT_CLASS (gsd_a11y_settings_plugin_parent_class)->finalize (object);
}
static void
impl_activate (GnomeSettingsPlugin *plugin)
{
gboolean res;
GError *error;
g_debug ("Activating a11y-settings plugin");
error = NULL;
res = gsd_a11y_settings_manager_start (GSD_A11Y_SETTINGS_PLUGIN (plugin)->priv->manager, &error);
if (! res) {
g_warning ("Unable to start a11y-settings manager: %s", error->message);
g_error_free (error);
}
}
static void
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating a11y-settings plugin");
gsd_a11y_settings_manager_stop (GSD_A11Y_SETTINGS_PLUGIN (plugin)->priv->manager);
}
static void
gsd_a11y_settings_plugin_class_init (GsdA11ySettingsPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
object_class->finalize = gsd_a11y_settings_plugin_finalize;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
g_type_class_add_private (klass, sizeof (GsdA11ySettingsPluginPrivate));
}
GNOME_SETTINGS_PLUGIN_REGISTER (GsdA11ySettings, gsd_a11y_settings)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2011 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __GSD_A11Y_SETTINGS_PLUGIN_H__
#define __GSD_A11Y_SETTINGS_PLUGIN_H__
#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>
#include "gnome-settings-plugin.h"
G_BEGIN_DECLS
#define GSD_TYPE_A11Y_SETTINGS_PLUGIN (gsd_a11y_settings_plugin_get_type ())
#define GSD_A11Y_SETTINGS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_A11Y_SETTINGS_PLUGIN, GsdA11ySettingsPlugin))
#define GSD_A11Y_SETTINGS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_A11Y_SETTINGS_PLUGIN, GsdA11ySettingsPluginClass))
#define GSD_IS_A11Y_SETTINGS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_A11Y_SETTINGS_PLUGIN))
#define GSD_IS_A11Y_SETTINGS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_A11Y_SETTINGS_PLUGIN))
#define GSD_A11Y_SETTINGS_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_A11Y_SETTINGS_PLUGIN, GsdA11ySettingsPluginClass))
typedef struct GsdA11ySettingsPluginPrivate GsdA11ySettingsPluginPrivate;
typedef struct
{
GnomeSettingsPlugin parent;
GsdA11ySettingsPluginPrivate *priv;
} GsdA11ySettingsPlugin;
typedef struct
{
GnomeSettingsPluginClass parent_class;
} GsdA11ySettingsPluginClass;
GType gsd_a11y_settings_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */
G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
G_END_DECLS
#endif /* __GSD_A11Y_SETTINGS_PLUGIN_H__ */
......@@ -24,81 +24,6 @@
#include <gmodule.h>
#include "gnome-settings-plugin.h"
#include "gsd-background-plugin.h"
#include "gsd-background-manager.h"
struct GsdBackgroundPluginPrivate {
GsdBackgroundManager *manager;
};
#define GSD_BACKGROUND_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_BACKGROUND_PLUGIN, GsdBackgroundPluginPrivate))
GNOME_SETTINGS_PLUGIN_REGISTER (GsdBackgroundPlugin, gsd_background_plugin)
static void
gsd_background_plugin_init (GsdBackgroundPlugin *plugin)
{
plugin->priv = GSD_BACKGROUND_PLUGIN_GET_PRIVATE (plugin);
g_debug ("GsdBackgroundPlugin initializing");
plugin->priv->manager = gsd_background_manager_new ();
}
static void
gsd_background_plugin_finalize (GObject *object)
{
GsdBackgroundPlugin *plugin;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_BACKGROUND_PLUGIN (object));
g_debug ("GsdBackgroundPlugin finalizing");
plugin = GSD_BACKGROUND_PLUGIN (object);
g_return_if_fail (plugin->priv != NULL);
if (plugin->priv->manager != NULL) {
g_object_unref (plugin->priv->manager);
}
G_OBJECT_CLASS (gsd_background_plugin_parent_class)->finalize (object);
}
static void
impl_activate (GnomeSettingsPlugin *plugin)
{
gboolean res;
GError *error;
g_debug ("Activating background plugin");
error = NULL;
res = gsd_background_manager_start (GSD_BACKGROUND_PLUGIN (plugin)->priv->manager, &error);
if (! res) {
g_warning ("Unable to start background manager: %s", error->message);
g_error_free (error);
}
}
static void
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating background plugin");
gsd_background_manager_stop (GSD_BACKGROUND_PLUGIN (plugin)->priv->manager);
}
static void
gsd_background_plugin_class_init (GsdBackgroundPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
object_class->finalize = gsd_background_plugin_finalize;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
g_type_class_add_private (klass, sizeof (GsdBackgroundPluginPrivate));
}
GNOME_SETTINGS_PLUGIN_REGISTER (GsdBackground, gsd_background)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __GSD_BACKGROUND_PLUGIN_H__
#define __GSD_BACKGROUND_PLUGIN_H__
#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>
#include "gnome-settings-plugin.h"
G_BEGIN_DECLS
#define GSD_TYPE_BACKGROUND_PLUGIN (gsd_background_plugin_get_type ())
#define GSD_BACKGROUND_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_BACKGROUND_PLUGIN, GsdBackgroundPlugin))
#define GSD_BACKGROUND_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_BACKGROUND_PLUGIN, GsdBackgroundPluginClass))
#define GSD_IS_BACKGROUND_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_BACKGROUND_PLUGIN))
#define GSD_IS_BACKGROUND_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_BACKGROUND_PLUGIN))
#define GSD_BACKGROUND_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_BACKGROUND_PLUGIN, GsdBackgroundPluginClass))
typedef struct GsdBackgroundPluginPrivate GsdBackgroundPluginPrivate;
typedef struct
{
GnomeSettingsPlugin parent;
GsdBackgroundPluginPrivate *priv;
} GsdBackgroundPlugin;
typedef struct
{
GnomeSettingsPluginClass parent_class;
} GsdBackgroundPluginClass;
GType gsd_background_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */
G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
G_END_DECLS
#endif /* __GSD_BACKGROUND_PLUGIN_H__ */
......@@ -24,81 +24,6 @@
#include <gmodule.h>
#include "gnome-settings-plugin.h"
#include "gsd-clipboard-plugin.h"
#include "gsd-clipboard-manager.h"
struct GsdClipboardPluginPrivate {
GsdClipboardManager *manager;
};
#define GSD_CLIPBOARD_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPluginPrivate))
GNOME_SETTINGS_PLUGIN_REGISTER (GsdClipboardPlugin, gsd_clipboard_plugin)
static void
gsd_clipboard_plugin_init (GsdClipboardPlugin *plugin)
{
plugin->priv = GSD_CLIPBOARD_PLUGIN_GET_PRIVATE (plugin);
g_debug ("GsdClipboardPlugin initializing");
plugin->priv->manager = gsd_clipboard_manager_new ();
}
static void
gsd_clipboard_plugin_finalize (GObject *object)
{
GsdClipboardPlugin *plugin;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_CLIPBOARD_PLUGIN (object));
g_debug ("GsdClipboardPlugin finalizing");
plugin = GSD_CLIPBOARD_PLUGIN (object);
g_return_if_fail (plugin->priv != NULL);
if (plugin->priv->manager != NULL) {
g_object_unref (plugin->priv->manager);
}
G_OBJECT_CLASS (gsd_clipboard_plugin_parent_class)->finalize (object);
}
static void
impl_activate (GnomeSettingsPlugin *plugin)
{
gboolean res;
GError *error;
g_debug ("Activating clipboard plugin");
error = NULL;
res = gsd_clipboard_manager_start (GSD_CLIPBOARD_PLUGIN (plugin)->priv->manager, &error);
if (! res) {
g_warning ("Unable to start clipboard manager: %s", error->message);
g_error_free (error);
}
}
static void
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating clipboard plugin");
gsd_clipboard_manager_stop (GSD_CLIPBOARD_PLUGIN (plugin)->priv->manager);
}
static void
gsd_clipboard_plugin_class_init (GsdClipboardPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
object_class->finalize = gsd_clipboard_plugin_finalize;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
g_type_class_add_private (klass, sizeof (GsdClipboardPluginPrivate));
}
GNOME_SETTINGS_PLUGIN_REGISTER (GsdClipboard, gsd_clipboard)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __GSD_CLIPBOARD_PLUGIN_H__
#define __GSD_CLIPBOARD_PLUGIN_H__
#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>
#include "gnome-settings-plugin.h"
G_BEGIN_DECLS
#define GSD_TYPE_CLIPBOARD_PLUGIN (gsd_clipboard_plugin_get_type ())
#define GSD_CLIPBOARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPlugin))
#define GSD_CLIPBOARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPluginClass))
#define GSD_IS_CLIPBOARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_CLIPBOARD_PLUGIN))
#define GSD_IS_CLIPBOARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_CLIPBOARD_PLUGIN))
#define GSD_CLIPBOARD_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPluginClass))
typedef struct GsdClipboardPluginPrivate GsdClipboardPluginPrivate;
typedef struct
{
GnomeSettingsPlugin parent;
GsdClipboardPluginPrivate *priv;
} GsdClipboardPlugin;
typedef struct
{
GnomeSettingsPluginClass parent_class;
} GsdClipboardPluginClass;
GType gsd_clipboard_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */
G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
G_END_DECLS
#endif /* __GSD_CLIPBOARD_PLUGIN_H__ */
......@@ -25,81 +25,6 @@
#include <gmodule.h>
#include "gnome-settings-plugin.h"
#include "gsd-color-plugin.h"
#include "gsd-color-manager.h"
struct GsdColorPluginPrivate {
GsdColorManager *manager;
};
#define GSD_COLOR_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_COLOR_PLUGIN, GsdColorPluginPrivate))
GNOME_SETTINGS_PLUGIN_REGISTER (GsdColorPlugin, gsd_color_plugin)
static void
gsd_color_plugin_init (GsdColorPlugin *plugin)
{
plugin->priv = GSD_COLOR_PLUGIN_GET_PRIVATE (plugin);
g_debug ("GsdColorPlugin initializing");
plugin->priv->manager = gsd_color_manager_new ();
}
static void
gsd_color_plugin_finalize (GObject *object)
{
GsdColorPlugin *plugin;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_COLOR_PLUGIN (object));
g_debug ("GsdColorPlugin finalizing");
plugin = GSD_COLOR_PLUGIN (object);
g_return_if_fail (plugin->priv != NULL);
if (plugin->priv->manager != NULL) {
g_object_unref (plugin->priv->manager);
}
G_OBJECT_CLASS (gsd_color_plugin_parent_class)->finalize (object);