gplugin/gplugin

Add a settings schema property to plugin info

21 months ago, Elliott Sales de Andrade
1195cedb7e55
Parents c08b3e13e04d
Children 4404fa24f8e9
Add a settings schema property to plugin info

This can be used by UIs to display a plugin's settings to the user.

Not sure about the name exactly. Also made it construct-only, as it seemed like it shouldn't change, but I dunno.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/1745/
--- a/gplugin/gplugin-plugin-info.c Mon Sep 12 04:33:39 2022 -0500
+++ b/gplugin/gplugin-plugin-info.c Mon Sep 12 04:34:25 2022 -0500
@@ -43,8 +43,8 @@
gint priority;
gchar *name;
-
gchar *version;
+ gchar *settings_schema;
gchar *license_id;
gchar *license_text;
@@ -93,6 +93,7 @@
PROP_WEBSITE,
PROP_DEPENDENCIES,
PROP_UNLOADABLE,
+ PROP_SETTINGS_SCHEMA,
N_PROPERTIES,
};
static GParamSpec *properties[N_PROPERTIES] = {
@@ -206,6 +207,17 @@
}
static void
+gplugin_plugin_info_set_settings_schema(GPluginPluginInfo *info,
+ const gchar *settings_schema)
+{
+ GPluginPluginInfoPrivate *priv =
+ gplugin_plugin_info_get_instance_private(info);
+
+ g_free(priv->settings_schema);
+ priv->settings_schema = g_strdup(settings_schema);
+}
+
+static void
gplugin_plugin_info_set_license_id(
GPluginPluginInfo *info,
const gchar *license_id)
@@ -419,6 +431,11 @@
value,
gplugin_plugin_info_get_unloadable(info));
break;
+ case PROP_SETTINGS_SCHEMA:
+ g_value_set_string(
+ value,
+ gplugin_plugin_info_get_settings_schema(info));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -509,6 +526,11 @@
info,
g_value_get_boolean(value));
break;
+ case PROP_SETTINGS_SCHEMA:
+ gplugin_plugin_info_set_settings_schema(
+ info,
+ g_value_get_string(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
break;
@@ -525,6 +547,7 @@
g_clear_pointer(&priv->provides, g_strfreev);
g_clear_pointer(&priv->name, g_free);
g_clear_pointer(&priv->version, g_free);
+ g_clear_pointer(&priv->settings_schema, g_free);
g_clear_pointer(&priv->license_id, g_free);
g_clear_pointer(&priv->license_text, g_free);
g_clear_pointer(&priv->license_url, g_free);
@@ -710,6 +733,20 @@
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
/**
+ * GPluginPluginInfo:settings-schema:
+ *
+ * The ID of the [class@Gio.Settings] schema for the plugin.
+ *
+ * Since: 0.39.0
+ */
+ properties[PROP_SETTINGS_SCHEMA] = g_param_spec_string(
+ "settings-schema",
+ "settings-schema",
+ "The GSettings schema of the plugin",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ /**
* GPluginPluginInfo:license-id:
*
* The short name of the license.
@@ -1087,6 +1124,28 @@
}
/**
+ * gplugin_plugin_info_get_settings_schema:
+ * @info: The plugin info instance.
+ *
+ * Returns the ID of the [class@Gio.Settings] schema as specified in @info.
+ *
+ * Since: 0.39.0
+ *
+ * Returns: The schema ID from @info.
+ */
+const gchar *
+gplugin_plugin_info_get_settings_schema(GPluginPluginInfo *info)
+{
+ GPluginPluginInfoPrivate *priv = NULL;
+
+ g_return_val_if_fail(GPLUGIN_IS_PLUGIN_INFO(info), NULL);
+
+ priv = gplugin_plugin_info_get_instance_private(info);
+
+ return priv->settings_schema;
+}
+
+/**
* gplugin_plugin_info_get_license_id:
* @info: The plugin info instance.
*
--- a/gplugin/gplugin-plugin-info.h Mon Sep 12 04:33:39 2022 -0500
+++ b/gplugin/gplugin-plugin-info.h Mon Sep 12 04:34:25 2022 -0500
@@ -63,6 +63,7 @@
gboolean gplugin_plugin_info_get_load_on_query(GPluginPluginInfo *info);
const gchar *gplugin_plugin_info_get_name(GPluginPluginInfo *info);
const gchar *gplugin_plugin_info_get_version(GPluginPluginInfo *info);
+const gchar *gplugin_plugin_info_get_settings_schema(GPluginPluginInfo *info);
const gchar *gplugin_plugin_info_get_license_id(GPluginPluginInfo *info);
const gchar *gplugin_plugin_info_get_license_text(GPluginPluginInfo *info);
const gchar *gplugin_plugin_info_get_license_url(GPluginPluginInfo *info);