summaryrefslogtreecommitdiff
path: root/libpeas
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2023-03-16 18:40:03 -0700
committerChristian Hergert <chergert@redhat.com>2023-03-22 16:44:35 -0700
commita56d7ed643ab481a2df29842141909e6a81ae92c (patch)
tree3370e1e580f654f49de01a722dcd5c306da85972 /libpeas
parent3f9a89a8201f7ac7c53e53ab9d049c723997820c (diff)
downloadlibpeas-a56d7ed643ab481a2df29842141909e6a81ae92c.tar.gz
janitorial: make PeasPluginInfo a GObject
This will allow us to use PeasPluginInfo in a GListModel (and therefore expose them in a PeasEngine using GListModel). Properties are not yet exposed but will be in the future.
Diffstat (limited to 'libpeas')
-rw-r--r--libpeas/peas-engine.c12
-rw-r--r--libpeas/peas-extension-base.c30
-rw-r--r--libpeas/peas-extension-set.c8
-rw-r--r--libpeas/peas-marshal.list4
-rw-r--r--libpeas/peas-plugin-info-priv.h11
-rw-r--r--libpeas/peas-plugin-info.c81
-rw-r--r--libpeas/peas-plugin-info.h14
-rw-r--r--libpeas/peas-plugin-loader-c.c2
8 files changed, 79 insertions, 83 deletions
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 42fc736..da04ad3 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -227,7 +227,7 @@ load_plugin_info (PeasEngine *engine,
module_name = peas_plugin_info_get_module_name (info);
if (peas_engine_get_plugin_info (engine, module_name) != NULL)
{
- _peas_plugin_info_unref (info);
+ g_object_unref (info);
return FALSE;
}
@@ -667,7 +667,7 @@ peas_engine_finalize (GObject *object)
{
PeasPluginInfo *info = (PeasPluginInfo *) item->data;
- _peas_plugin_info_unref (info);
+ g_object_unref (info);
}
/* free the search path list */
@@ -779,13 +779,13 @@ peas_engine_class_init (PeasEngineClass *klass)
G_SIGNAL_RUN_LAST,
G_CALLBACK (peas_engine_load_plugin_real),
NULL, NULL,
- peas_cclosure_marshal_VOID__BOXED,
+ peas_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
PEAS_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
g_signal_set_va_marshaller (signals[LOAD_PLUGIN],
G_TYPE_FROM_CLASS (klass),
- peas_cclosure_marshal_VOID__BOXEDv);
+ peas_cclosure_marshal_VOID__OBJECTv);
/**
* PeasEngine::unload-plugin:
@@ -806,13 +806,13 @@ peas_engine_class_init (PeasEngineClass *klass)
G_SIGNAL_RUN_LAST,
G_CALLBACK (peas_engine_unload_plugin_real),
NULL, NULL,
- peas_cclosure_marshal_VOID__BOXED,
+ peas_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
PEAS_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
g_signal_set_va_marshaller (signals[UNLOAD_PLUGIN],
G_TYPE_FROM_CLASS (klass),
- peas_cclosure_marshal_VOID__BOXEDv);
+ peas_cclosure_marshal_VOID__OBJECTv);
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
diff --git a/libpeas/peas-extension-base.c b/libpeas/peas-extension-base.c
index b68a0ed..9ba96ed 100644
--- a/libpeas/peas-extension-base.c
+++ b/libpeas/peas-extension-base.c
@@ -60,6 +60,17 @@ static GParamSpec *properties[N_PROPERTIES] = { NULL };
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (PeasExtensionBase, peas_extension_base, G_TYPE_OBJECT)
static void
+peas_extension_base_finalize (GObject *object)
+{
+ PeasExtensionBase *extbase = PEAS_EXTENSION_BASE (object);
+ PeasExtensionBasePrivate *priv = peas_extension_base_get_instance_private (extbase);
+
+ g_clear_object (&priv->info);
+
+ G_OBJECT_CLASS (peas_extension_base_parent_class)->finalize (object);
+}
+
+static void
peas_extension_base_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -70,7 +81,7 @@ peas_extension_base_get_property (GObject *object,
switch (prop_id)
{
case PROP_PLUGIN_INFO:
- g_value_set_boxed (value, peas_extension_base_get_plugin_info (extbase));
+ g_value_set_object (value, peas_extension_base_get_plugin_info (extbase));
break;
case PROP_DATA_DIR:
@@ -95,7 +106,7 @@ peas_extension_base_set_property (GObject *object,
switch (prop_id)
{
case PROP_PLUGIN_INFO:
- priv->info = g_value_get_boxed (value);
+ priv->info = g_value_dup_object (value);
break;
default:
@@ -114,6 +125,7 @@ peas_extension_base_class_init (PeasExtensionBaseClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = peas_extension_base_finalize;
object_class->get_property = peas_extension_base_get_property;
object_class->set_property = peas_extension_base_set_property;
@@ -123,13 +135,13 @@ peas_extension_base_class_init (PeasExtensionBaseClass *klass)
* The [struct@PluginInfo] related to the current plugin.
*/
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);
+ g_param_spec_object ("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);
/**
* PeasExtensionBase:data-dir:
diff --git a/libpeas/peas-extension-set.c b/libpeas/peas-extension-set.c
index 1de3acf..039f5aa 100644
--- a/libpeas/peas-extension-set.c
+++ b/libpeas/peas-extension-set.c
@@ -357,14 +357,14 @@ peas_extension_set_class_init (PeasExtensionSetClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- peas_cclosure_marshal_VOID__BOXED_OBJECT,
+ peas_cclosure_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
PEAS_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE,
PEAS_TYPE_EXTENSION);
g_signal_set_va_marshaller (signals[EXTENSION_ADDED],
G_TYPE_FROM_CLASS (klass),
- peas_cclosure_marshal_VOID__BOXED_OBJECTv);
+ peas_cclosure_marshal_VOID__OBJECT_OBJECTv);
/**
* PeasExtensionSet::extension-removed:
@@ -389,14 +389,14 @@ peas_extension_set_class_init (PeasExtensionSetClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- peas_cclosure_marshal_VOID__BOXED_OBJECT,
+ peas_cclosure_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE,
2,
PEAS_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE,
PEAS_TYPE_EXTENSION);
g_signal_set_va_marshaller (signals[EXTENSION_REMOVED],
G_TYPE_FROM_CLASS (klass),
- peas_cclosure_marshal_VOID__BOXED_OBJECTv);
+ peas_cclosure_marshal_VOID__OBJECT_OBJECTv);
properties[PROP_ENGINE] =
g_param_spec_object ("engine",
diff --git a/libpeas/peas-marshal.list b/libpeas/peas-marshal.list
index ed801e0..183190d 100644
--- a/libpeas/peas-marshal.list
+++ b/libpeas/peas-marshal.list
@@ -1,2 +1,2 @@
-VOID:BOXED
-VOID:BOXED,OBJECT
+VOID:OBJECT
+VOID:OBJECT,OBJECT
diff --git a/libpeas/peas-plugin-info-priv.h b/libpeas/peas-plugin-info-priv.h
index 9d8d4ef..1362a0d 100644
--- a/libpeas/peas-plugin-info-priv.h
+++ b/libpeas/peas-plugin-info-priv.h
@@ -27,8 +27,9 @@
#include "peas-plugin-info.h"
struct _PeasPluginInfo {
+ GObject parent_instance;
+
/*< private >*/
- gint refcount;
/* Used and managed by PeasPluginLoader */
gpointer loader_data;
@@ -67,8 +68,6 @@ struct _PeasPluginInfo {
guint hidden : 1;
};
-PeasPluginInfo *_peas_plugin_info_new (const gchar *filename,
- const gchar *module_dir,
- const gchar *data_dir);
-PeasPluginInfo *_peas_plugin_info_ref (PeasPluginInfo *info);
-void _peas_plugin_info_unref (PeasPluginInfo *info);
+PeasPluginInfo *_peas_plugin_info_new (const gchar *filename,
+ const gchar *module_dir,
+ const gchar *data_dir);
diff --git a/libpeas/peas-plugin-info.c b/libpeas/peas-plugin-info.c
index 06bba97..9907957 100644
--- a/libpeas/peas-plugin-info.c
+++ b/libpeas/peas-plugin-info.c
@@ -64,48 +64,45 @@
G_DEFINE_QUARK (peas-plugin-info-error, peas_plugin_info_error)
-G_DEFINE_BOXED_TYPE (PeasPluginInfo, peas_plugin_info,
- _peas_plugin_info_ref,
- _peas_plugin_info_unref)
+G_DEFINE_FINAL_TYPE (PeasPluginInfo, peas_plugin_info, G_TYPE_OBJECT)
-PeasPluginInfo *
-_peas_plugin_info_ref (PeasPluginInfo *info)
+static void
+peas_plugin_info_finalize (GObject *object)
{
- g_atomic_int_inc (&info->refcount);
- return info;
+ PeasPluginInfo *info = PEAS_PLUGIN_INFO (object);
+
+ g_clear_pointer (&info->filename, g_free);
+ g_clear_pointer (&info->module_dir, g_free);
+ g_clear_pointer (&info->data_dir, g_free);
+ g_clear_pointer (&info->embedded, g_free);
+ g_clear_pointer (&info->module_name, g_free);
+ g_clear_pointer (&info->dependencies, g_strfreev);
+ g_clear_pointer (&info->name, g_free);
+ g_clear_pointer (&info->desc, g_free);
+ g_clear_pointer (&info->icon_name, g_free);
+ g_clear_pointer (&info->website, g_free);
+ g_clear_pointer (&info->copyright, g_free);
+ g_clear_pointer (&info->version, g_free);
+ g_clear_pointer (&info->help_uri, g_free);
+ g_clear_pointer (&info->authors, g_strfreev);
+ g_clear_pointer (&info->schema_source, g_settings_schema_source_unref);
+ g_clear_pointer (&info->external_data, g_hash_table_unref);
+ g_clear_pointer (&info->error, g_error_free);
+
+ G_OBJECT_CLASS (peas_plugin_info_parent_class)->finalize (object);
}
-void
-_peas_plugin_info_unref (PeasPluginInfo *info)
+static void
+peas_plugin_info_class_init (PeasPluginInfoClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = peas_plugin_info_finalize;
+}
+
+static void
+peas_plugin_info_init (PeasPluginInfo *info)
{
- if (!g_atomic_int_dec_and_test (&info->refcount))
- return;
-
- g_free (info->filename);
- g_free (info->module_dir);
- g_free (info->data_dir);
- g_free (info->embedded);
- g_free (info->module_name);
- g_strfreev (info->dependencies);
- g_free (info->name);
- g_free (info->desc);
- g_free (info->icon_name);
- g_free (info->website);
- g_free (info->copyright);
- g_free (info->version);
- g_free (info->help_uri);
- g_strfreev (info->authors);
-
- if (info->schema_source != NULL)
- g_settings_schema_source_unref (info->schema_source);
-
- if (info->external_data != NULL)
- g_hash_table_unref (info->external_data);
-
- if (info->error != NULL)
- g_error_free (info->error);
-
- g_free (info);
}
/*
@@ -136,11 +133,10 @@ _peas_plugin_info_new (const gchar *filename,
is_resource = g_str_has_prefix (filename, "resource://");
- info = g_new0 (PeasPluginInfo, 1);
- info->refcount = 1;
+ info = g_object_new (PEAS_TYPE_PLUGIN_INFO, NULL);
plugin_file = g_key_file_new ();
-
+
if (is_resource)
{
bytes = g_resources_lookup_data (filename + strlen ("resource://"),
@@ -323,11 +319,8 @@ _peas_plugin_info_new (const gchar *filename,
error:
- g_free (info->embedded);
+ g_object_unref (info);
g_free (loader);
- g_free (info->module_name);
- g_free (info->name);
- g_free (info);
g_clear_pointer (&bytes, g_bytes_unref);
g_key_file_free (plugin_file);
diff --git a/libpeas/peas-plugin-info.h b/libpeas/peas-plugin-info.h
index e7ce150..f7b675a 100644
--- a/libpeas/peas-plugin-info.h
+++ b/libpeas/peas-plugin-info.h
@@ -34,8 +34,7 @@
G_BEGIN_DECLS
-#define PEAS_TYPE_PLUGIN_INFO (peas_plugin_info_get_type ())
-#define PEAS_PLUGIN_INFO(obj) ((PeasPluginInfo *) (obj))
+#define PEAS_TYPE_PLUGIN_INFO (peas_plugin_info_get_type())
/**
* PEAS_PLUGIN_INFO_ERROR:
@@ -67,16 +66,9 @@ typedef enum {
PEAS_PLUGIN_INFO_ERROR_DEP_LOADING_FAILED
} PeasPluginInfoError;
-/**
- * PeasPluginInfo:
- *
- * The #PeasPluginInfo structure contains only private data and should only
- * be accessed using the provided API.
- */
-typedef struct _PeasPluginInfo PeasPluginInfo;
-
PEAS_AVAILABLE_IN_ALL
-GType peas_plugin_info_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (PeasPluginInfo, peas_plugin_info, PEAS, PLUGIN_INFO, GObject)
+
PEAS_AVAILABLE_IN_ALL
GQuark peas_plugin_info_error_quark (void);
diff --git a/libpeas/peas-plugin-loader-c.c b/libpeas/peas-plugin-loader-c.c
index a4dc3d3..c4964f6 100644
--- a/libpeas/peas-plugin-loader-c.c
+++ b/libpeas/peas-plugin-loader-c.c
@@ -136,7 +136,7 @@ peas_plugin_loader_c_create_extension (PeasPluginLoader *loader,
exten_parameters[n_parameters].name = intern_plugin_info;
memset (&exten_parameters[n_parameters].value, 0, sizeof (GValue));
g_value_init (&exten_parameters[n_parameters].value, PEAS_TYPE_PLUGIN_INFO);
- g_value_set_boxed (&exten_parameters[n_parameters].value, info);
+ g_value_set_object (&exten_parameters[n_parameters].value, info);
instance = peas_object_module_create_object (info->loader_data,
exten_type,