GnomeSettingsModule
- From: Rodrigo Moya <rodrigo gnome-db org>
- To: Control Center List <gnomecc-list gnome org>
- Subject: GnomeSettingsModule
- Date: Wed, 28 Mar 2007 15:55:17 +0200
Hi
Although a bit slower than I thought, here's at last the 1st step in the
g-s-d refactoring I was talking about. This is the class to be
implemented by the modules (gnome-settings-font, gnome-settings-...), it
just provides the hooks for g-s-d to make the calls to the modules. With
this, gnome-settings-daemon.c would just need to iterate over a list
with all the objects implementing this class when making calls to their
methods (instead of: gnome_settings_font_init; gnome_settings_xrdb_init,
etc, etc).
If there's nothing against it, I'll start moving the modules to that.
One question that remains open is how to load the modules. Since the
modules are part of g-s-d itself, it makes more sense to me to include
them in the g-s-d code and just load them by hand (to a list or
something) on the g-s-d code, but, just in case, do we want to load them
from shared libs? is there any good reason to do so?
--
Rodrigo Moya <rodrigo gnome-db org>
/*
* Copyright (C) 2007 The GNOME Foundation
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Owen Taylor, Havoc Pennington, Rodrigo Moya
*/
#include "gnome-settings-module.h"
#define CLASS(module) (GNOME_SETTINGS_MODULE_CLASS (G_OBJECT_GET_CLASS (module)))
static void
gnome_settings_module_class_init (GnomeSettingsModuleClass *klass)
{
klass->initialize = NULL;
klass->load = NULL;
klass->unload = NULL;
klass->reload_settings = NULL;
}
static void
gnome_settings_module_init (GnomeSettingsModule *module, GnomeSettingsModuleClass *klass)
{
}
GType
gnome_settings_module_get_type (void)
{
static GType module_type = 0;
if (!module_type) {
static const GTypeInfo module_info = {
sizeof (GnomeSettingsModuleClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gnome_settings_module_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GnomeSettingsModule),
0, /* n_preallocs */
(GInstanceInitFunc) gnome_settings_module_init,
};
module_type = g_type_register_static (G_TYPE_OBJECT,
"GnomeSettingsModule",
&module_info, 0);
}
return module_type;
}
gboolean
gnome_settings_module_initialize (GnomeSettingsModule *module)
{
g_return_val_if_fail (GNOME_SETTINGS_IS_MODULE (module), FALSE);
g_return_val_if_fail (CLASS (module)->initialize != NULL, FALSE);
return CLASS (module)->initialize (module);
}
gboolean
gnome_settings_module_load (GnomeSettingsModule *module)
{
g_return_val_if_fail (GNOME_SETTINGS_IS_MODULE (module), FALSE);
g_return_val_if_fail (CLASS (module)->load != NULL, FALSE);
return CLASS (module)->load (module);
}
gboolean
gnome_settings_module_unload (GnomeSettingsModule *module)
{
g_return_val_if_fail (GNOME_SETTINGS_IS_MODULE (module), FALSE);
g_return_val_if_fail (CLASS (module)->unload != NULL, FALSE);
return CLASS (module)->unload (module);
}
gboolean
gnome_settings_module_reload_settings (GnomeSettingsModule *module)
{
g_return_val_if_fail (GNOME_SETTINGS_IS_MODULE (module), FALSE);
g_return_val_if_fail (CLASS (module)->reload_settings != NULL, FALSE);
return CLASS (module)->reload_settings (module);
}
/*
* Copyright (C) 2007 The GNOME Foundation
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Owen Taylor, Havoc Pennington, Rodrigo Moya
*/
#ifndef __GNOME_SETTINGS_MODULE_H__
#define __GNOME_SETTINGS_MODULE_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define GNOME_SETTINGS_TYPE_MODULE (gnome_settings_module_get_type ())
#define GNOME_SETTINGS_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_SETTINGS_TYPE_MODULE, GnomeSettingsModule))
#define GNOME_SETTINGS_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNOME_SETTINGS_TYPE_MODULE, GnomeSettingsModuleClass))
#define GNOME_SETTINGS_IS_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_SETTINGS_TYPE_MODULE))
#define GNOME_SETTINGS_IS_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_SETTINGS_TYPE_MODULE))
#define GNOME_SETTINGS_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_SETTINGS_TYPE_MODULE, GnomeSettingsModuleClass))
typedef struct _GnomeSettingsModule GnomeSettingsModule;
typedef struct _GnomeSettingsModuleClass GnomeSettingsModuleClass;
struct _GnomeSettingsModule {
GObject parent;
};
struct _GnomeSettingsModuleClass {
GObjectClass parent_class;
/* virtual methods */
gboolean (* initialize) (GnomeSettingsModule *module);
gboolean (* load) (GnomeSettingsModule *module);
gboolean (* unload) (GnomeSettingsModule *module);
gboolean (* reload_settings) (GnomeSettingsModule *module);
};
GType gnome_settings_module_get_type (void);
gboolean gnome_settings_module_initialize (GnomeSettingsModule *module);
gboolean gnome_settings_module_load (GnomeSettingsModule *module);
gboolean gnome_settings_module_unload (GnomeSettingsModule *module);
gboolean gnome_settings_module_reload_settings (GnomeSettingsModule *module);
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]