[libpeas] Use g_object_install_properties() and g_object_notify_by_pspec()
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Use g_object_install_properties() and g_object_notify_by_pspec()
- Date: Thu, 8 Dec 2011 16:23:30 +0000 (UTC)
commit b0b1a39bef1662b48d24e3b079b558e2316ce804
Author: Garrett Regier <garrettregier gmail com>
Date: Thu Dec 8 08:11:31 2011 -0800
Use g_object_install_properties() and g_object_notify_by_pspec()
libpeas-gtk/peas-gtk-disable-plugins-dialog.c | 40 ++++++++-------
libpeas-gtk/peas-gtk-plugin-manager-store.c | 25 ++++++----
libpeas-gtk/peas-gtk-plugin-manager-view.c | 42 +++++++++--------
libpeas-gtk/peas-gtk-plugin-manager.c | 42 +++++++++--------
libpeas/peas-engine.c | 46 ++++++++++--------
libpeas/peas-extension-base.c | 44 +++++++++--------
libpeas/peas-extension-set.c | 61 +++++++++++++-----------
libpeas/peas-object-module.c | 63 +++++++++++++------------
8 files changed, 191 insertions(+), 172 deletions(-)
---
diff --git a/libpeas-gtk/peas-gtk-disable-plugins-dialog.c b/libpeas-gtk/peas-gtk-disable-plugins-dialog.c
index 27aed38..311e930 100644
--- a/libpeas-gtk/peas-gtk-disable-plugins-dialog.c
+++ b/libpeas-gtk/peas-gtk-disable-plugins-dialog.c
@@ -41,9 +41,12 @@ struct _PeasGtkDisablePluginsDialogPrivate {
enum {
PROP_0,
PROP_PLUGIN_INFO,
- PROP_DEPENDANT_PLUGINS
+ PROP_DEPENDANT_PLUGINS,
+ N_PROPERTIES
};
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
+
G_DEFINE_TYPE (PeasGtkDisablePluginsDialog,
peas_gtk_disable_plugins_dialog,
GTK_TYPE_MESSAGE_DIALOG);
@@ -257,24 +260,23 @@ peas_gtk_disable_plugins_dialog_class_init (PeasGtkDisablePluginsDialogClass *kl
object_class->constructed = peas_gtk_disable_plugins_dialog_constructed;
object_class->finalize = peas_gtk_disable_plugins_dialog_finalize;
- g_object_class_install_property (object_class,
- PROP_PLUGIN_INFO,
- g_param_spec_pointer ("plugin-info",
- "Plugin Information",
- "Plugin that is being disabled",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_DEPENDANT_PLUGINS,
- g_param_spec_pointer ("dependant-plugins",
- "Dependant plugins",
- "Dependant plugins",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
+ properties[PROP_PLUGIN_INFO] =
+ g_param_spec_pointer ("plugin-info",
+ "Plugin Information",
+ "Plugin that is being disabled",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_DEPENDANT_PLUGINS] =
+ g_param_spec_pointer ("dependant-plugins",
+ "Dependant plugins",
+ "Dependant plugins",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (object_class, sizeof (PeasGtkDisablePluginsDialogPrivate));
}
diff --git a/libpeas-gtk/peas-gtk-plugin-manager-store.c b/libpeas-gtk/peas-gtk-plugin-manager-store.c
index cd28c91..12844b1 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager-store.c
+++ b/libpeas-gtk/peas-gtk-plugin-manager-store.c
@@ -51,9 +51,12 @@ struct _PeasGtkPluginManagerStorePrivate {
/* Properties */
enum {
PROP_0,
- PROP_ENGINE
+ PROP_ENGINE,
+ N_PROPERTIES
};
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
+
G_DEFINE_TYPE (PeasGtkPluginManagerStore, peas_gtk_plugin_manager_store, GTK_TYPE_LIST_STORE);
static void
@@ -290,16 +293,16 @@ peas_gtk_plugin_manager_store_class_init (PeasGtkPluginManagerStoreClass *klass)
*
* The #PeasEngine this store is attached to.
*/
- g_object_class_install_property (object_class,
- PROP_ENGINE,
- g_param_spec_object ("engine",
- "engine",
- "The PeasEngine this store is attached to",
- PEAS_TYPE_ENGINE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
+ properties[PROP_ENGINE] =
+ g_param_spec_object ("engine",
+ "engine",
+ "The PeasEngine this store is attached to",
+ PEAS_TYPE_ENGINE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (object_class, sizeof (PeasGtkPluginManagerStorePrivate));
}
diff --git a/libpeas-gtk/peas-gtk-plugin-manager-view.c b/libpeas-gtk/peas-gtk-plugin-manager-view.c
index f1e8794..86399bc 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager-view.c
+++ b/libpeas-gtk/peas-gtk-plugin-manager-view.c
@@ -66,7 +66,8 @@ struct _PeasGtkPluginManagerViewPrivate {
enum {
PROP_0,
PROP_ENGINE,
- PROP_SHOW_BUILTIN
+ PROP_SHOW_BUILTIN,
+ N_PROPERTIES
};
/* Signals */
@@ -76,6 +77,7 @@ enum {
};
static guint signals[LAST_SIGNAL];
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
G_DEFINE_TYPE (PeasGtkPluginManagerView, peas_gtk_plugin_manager_view, GTK_TYPE_TREE_VIEW);
@@ -764,15 +766,14 @@ peas_gtk_plugin_manager_view_class_init (PeasGtkPluginManagerViewClass *klass)
*
* The #PeasEngine this view is attached to.
*/
- g_object_class_install_property (object_class,
- PROP_ENGINE,
- g_param_spec_object ("engine",
- "engine",
- "The PeasEngine this view is attached to",
- PEAS_TYPE_ENGINE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_ENGINE] =
+ g_param_spec_object ("engine",
+ "engine",
+ "The PeasEngine this view is attached to",
+ PEAS_TYPE_ENGINE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
/**
* PeasGtkPluginManagerView:show-builtin:
@@ -781,15 +782,14 @@ peas_gtk_plugin_manager_view_class_init (PeasGtkPluginManagerViewClass *klass)
*
* Deprecated: 1.2: Use hidden plugins instead.
*/
- g_object_class_install_property (object_class,
- PROP_SHOW_BUILTIN,
- g_param_spec_boolean ("show-builtin",
- "show-builtin",
- "If builtin plugins should be shown",
- FALSE,
- G_PARAM_DEPRECATED |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_SHOW_BUILTIN] =
+ g_param_spec_boolean ("show-builtin",
+ "show-builtin",
+ "If builtin plugins should be shown",
+ FALSE,
+ G_PARAM_DEPRECATED |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
/**
* PeasGtkPluginManagerView::populate-popup:
@@ -811,6 +811,7 @@ peas_gtk_plugin_manager_view_class_init (PeasGtkPluginManagerViewClass *klass)
1,
GTK_TYPE_MENU);
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (object_class, sizeof (PeasGtkPluginManagerViewPrivate));
}
@@ -892,7 +893,8 @@ peas_gtk_plugin_manager_view_set_show_builtin (PeasGtkPluginManagerView *view,
if (iter_set && convert_child_iter_to_iter (view, &iter))
gtk_tree_selection_select_iter (selection, &iter);
- g_object_notify (G_OBJECT (view), "show-builtin");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties[PROP_SHOW_BUILTIN]);
}
/**
diff --git a/libpeas-gtk/peas-gtk-plugin-manager.c b/libpeas-gtk/peas-gtk-plugin-manager.c
index 4a3709b..758df1f 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager.c
+++ b/libpeas-gtk/peas-gtk-plugin-manager.c
@@ -73,9 +73,12 @@ struct _PeasGtkPluginManagerPrivate {
enum {
PROP_0,
PROP_ENGINE,
- PROP_VIEW
+ PROP_VIEW,
+ N_PROPERTIES
};
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
+
G_DEFINE_TYPE (PeasGtkPluginManager, peas_gtk_plugin_manager, GTK_TYPE_BOX);
static gboolean
@@ -529,31 +532,30 @@ peas_gtk_plugin_manager_class_init (PeasGtkPluginManagerClass *klass)
*
* The #PeasEngine this manager is attached to.
*/
- g_object_class_install_property (object_class,
- PROP_ENGINE,
- g_param_spec_object ("engine",
- "engine",
- "The PeasEngine this manager is attached to",
- PEAS_TYPE_ENGINE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_ENGINE] =
+ g_param_spec_object ("engine",
+ "engine",
+ "The PeasEngine this manager is attached to",
+ PEAS_TYPE_ENGINE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
/**
* PeasGtkPluginManager:view:
*
* The #PeasGtkPluginManagerView shown in the #PeasGtkPluginManager.
*/
- g_object_class_install_property (object_class,
- PROP_VIEW,
- g_param_spec_object ("view",
- "view",
- "The view shown in the manager",
- PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
+ properties[PROP_VIEW] =
+ g_param_spec_object ("view",
+ "view",
+ "The view shown in the manager",
+ PEAS_GTK_TYPE_PLUGIN_MANAGER_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (object_class, sizeof (PeasGtkPluginManagerPrivate));
}
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 8125d9c..774fa26 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -69,15 +69,17 @@ enum {
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL];
-
/* Properties */
enum {
PROP_0,
PROP_PLUGIN_LIST,
- PROP_LOADED_PLUGINS
+ PROP_LOADED_PLUGINS,
+ N_PROPERTIES
};
+static guint signals[LAST_SIGNAL];
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
+
typedef struct _LoaderInfo LoaderInfo;
struct _LoaderInfo {
@@ -132,7 +134,8 @@ load_plugin_info (PeasEngine *engine,
engine->priv->plugin_list = g_list_prepend (engine->priv->plugin_list,
info);
- g_object_notify (G_OBJECT (engine), "plugin-list");
+ g_object_notify_by_pspec (G_OBJECT (engine),
+ properties[PROP_PLUGIN_LIST]);
}
}
@@ -474,13 +477,12 @@ peas_engine_class_init (PeasEngineClass *klass)
* Note that the list belongs to the engine and should not be modified
* or freed.
*/
- g_object_class_install_property (object_class,
- PROP_PLUGIN_LIST,
- g_param_spec_pointer ("plugin-list",
- "Plugin list",
- "The list of found plugins",
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_PLUGIN_LIST] =
+ g_param_spec_pointer ("plugin-list",
+ "Plugin list",
+ "The list of found plugins",
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
/**
* PeasEngine:loaded-plugins:
@@ -502,14 +504,13 @@ peas_engine_class_init (PeasEngineClass *klass)
*
* Note: notify will not be called when the engine is being destroyed.
*/
- g_object_class_install_property (object_class,
- PROP_LOADED_PLUGINS,
- g_param_spec_boxed ("loaded-plugins",
- "Loaded plugins",
- "The list of loaded plugins",
- G_TYPE_STRV,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_LOADED_PLUGINS] =
+ g_param_spec_boxed ("loaded-plugins",
+ "Loaded plugins",
+ "The list of loaded plugins",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
/**
* PeasEngine::load-plugin:
@@ -560,6 +561,7 @@ peas_engine_class_init (PeasEngineClass *klass)
1, PEAS_TYPE_PLUGIN_INFO |
G_SIGNAL_TYPE_STATIC_SCOPE);
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (klass, sizeof (PeasEnginePrivate));
/* We are doing some global initialization here as there is currently no
@@ -839,7 +841,8 @@ peas_engine_load_plugin_real (PeasEngine *engine,
PeasPluginInfo *info)
{
if (load_plugin (engine, info))
- g_object_notify (G_OBJECT (engine), "loaded-plugins");
+ g_object_notify_by_pspec (G_OBJECT (engine),
+ properties[PROP_LOADED_PLUGINS]);
}
/**
@@ -909,7 +912,8 @@ peas_engine_unload_plugin_real (PeasEngine *engine,
g_debug ("Unloaded plugin '%s'", peas_plugin_info_get_module_name (info));
if (!engine->priv->in_dispose)
- g_object_notify (G_OBJECT (engine), "loaded-plugins");
+ g_object_notify_by_pspec (G_OBJECT (engine),
+ properties[PROP_LOADED_PLUGINS]);
}
/**
diff --git a/libpeas/peas-extension-base.c b/libpeas/peas-extension-base.c
index 7c4cba0..dccface 100644
--- a/libpeas/peas-extension-base.c
+++ b/libpeas/peas-extension-base.c
@@ -52,9 +52,12 @@ struct _PeasExtensionBasePrivate {
enum {
PROP_0,
PROP_PLUGIN_INFO,
- PROP_DATA_DIR
+ PROP_DATA_DIR,
+ N_PROPERTIES
};
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
+
static void
peas_extension_base_get_property (GObject *object,
guint prop_id,
@@ -112,26 +115,25 @@ peas_extension_base_class_init (PeasExtensionBaseClass *klass)
object_class->get_property = peas_extension_base_get_property;
object_class->set_property = peas_extension_base_set_property;
- g_object_class_install_property (object_class,
- PROP_PLUGIN_INFO,
- g_param_spec_boxed ("plugin-info",
- "Plugin Information",
- "Information related to the current plugin",
- PEAS_TYPE_PLUGIN_INFO,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_DATA_DIR,
- g_param_spec_string ("data-dir",
- "Data Directory",
- "The full path of the directory where the "
- "plugin should look for its data files",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
+ properties[PROP_PLUGIN_INFO] =
+ g_param_spec_boxed ("plugin-info",
+ "Plugin Information",
+ "Information related to the current plugin",
+ PEAS_TYPE_PLUGIN_INFO,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_DATA_DIR] =
+ g_param_spec_string ("data-dir",
+ "Data Directory",
+ "The full path of the directory where the "
+ "plugin should look for its data files",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (klass, sizeof (PeasExtensionBasePrivate));
}
diff --git a/libpeas/peas-extension-set.c b/libpeas/peas-extension-set.c
index be4da89..19644c8 100644
--- a/libpeas/peas-extension-set.c
+++ b/libpeas/peas-extension-set.c
@@ -117,16 +117,18 @@ enum {
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL];
-
/* Properties */
enum {
PROP_0,
PROP_ENGINE,
PROP_EXTENSION_TYPE,
- PROP_CONSTRUCT_PROPERTIES
+ PROP_CONSTRUCT_PROPERTIES,
+ N_PROPERTIES
};
+static guint signals[LAST_SIGNAL];
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
+
static void
set_construct_properties (PeasExtensionSet *set,
PeasParameterArray *array)
@@ -405,32 +407,33 @@ peas_extension_set_class_init (PeasExtensionSetClass *klass)
PEAS_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE,
PEAS_TYPE_EXTENSION);
- g_object_class_install_property (object_class, PROP_ENGINE,
- g_param_spec_object ("engine",
- "Engine",
- "The PeasEngine this set is attached to",
- PEAS_TYPE_ENGINE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class, PROP_EXTENSION_TYPE,
- g_param_spec_gtype ("extension-type",
- "Extension Type",
- "The extension GType managed by this set",
- G_TYPE_NONE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class, PROP_CONSTRUCT_PROPERTIES,
- g_param_spec_pointer ("construct-properties",
- "Construct Properties",
- "The properties to pass the extensions when creating them",
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
+ properties[PROP_ENGINE] =
+ g_param_spec_object ("engine",
+ "Engine",
+ "The PeasEngine this set is attached to",
+ PEAS_TYPE_ENGINE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_EXTENSION_TYPE] =
+ g_param_spec_gtype ("extension-type",
+ "Extension Type",
+ "The extension GType managed by this set",
+ G_TYPE_NONE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_CONSTRUCT_PROPERTIES] =
+ g_param_spec_pointer ("construct-properties",
+ "Construct Properties",
+ "The properties to pass the extensions when creating them",
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (klass, sizeof (PeasExtensionSetPrivate));
}
diff --git a/libpeas/peas-object-module.c b/libpeas/peas-object-module.c
index c24f75b..26a5a92 100644
--- a/libpeas/peas-object-module.c
+++ b/libpeas/peas-object-module.c
@@ -50,9 +50,12 @@ enum {
PROP_0,
PROP_MODULE_NAME,
PROP_PATH,
- PROP_RESIDENT
+ PROP_RESIDENT,
+ N_PROPERTIES
};
+static GParamSpec *properties[N_PROPERTIES] = { NULL };
+
typedef struct {
GType iface_type;
PeasFactoryFunc func;
@@ -238,36 +241,34 @@ peas_object_module_class_init (PeasObjectModuleClass *klass)
module_class->load = peas_object_module_load;
module_class->unload = peas_object_module_unload;
- g_object_class_install_property (object_class,
- PROP_MODULE_NAME,
- g_param_spec_string ("module-name",
- "Module Name",
- "The module to load for this object",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_PATH,
- g_param_spec_string ("path",
- "Path",
- "The path to use when loading this module",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_RESIDENT,
- g_param_spec_boolean ("resident",
- "Resident",
- "Whether the module is resident",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
+ properties[PROP_MODULE_NAME] =
+ g_param_spec_string ("module-name",
+ "Module Name",
+ "The module to load for this object",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_PATH] =
+ g_param_spec_string ("path",
+ "Path",
+ "The path to use when loading this module",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_RESIDENT] =
+ g_param_spec_boolean ("resident",
+ "Resident",
+ "Whether the module is resident",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_type_class_add_private (klass, sizeof (PeasObjectModulePrivate));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]