[gnome-software] trivial: Add gs_plugin_set_name()



commit 2b4ffb47eca78476bd4712b2e4928c86d0891b38
Author: Richard Hughes <richard hughsie com>
Date:   Fri May 5 20:51:01 2017 +0100

    trivial: Add gs_plugin_set_name()
    
    Plugins are not expected to use this.

 lib/gs-plugin-private.h |    2 ++
 lib/gs-plugin.c         |   24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/lib/gs-plugin-private.h b/lib/gs-plugin-private.h
index b3853d0..f83d428 100644
--- a/lib/gs-plugin-private.h
+++ b/lib/gs-plugin-private.h
@@ -49,6 +49,8 @@ void           gs_plugin_set_order                    (GsPlugin       *plugin,
 guint           gs_plugin_get_priority                 (GsPlugin       *plugin);
 void            gs_plugin_set_priority                 (GsPlugin       *plugin,
                                                         guint           priority);
+void            gs_plugin_set_name                     (GsPlugin       *plugin,
+                                                        const gchar    *name);
 void            gs_plugin_set_locale                   (GsPlugin       *plugin,
                                                         const gchar    *locale);
 void            gs_plugin_set_language                 (GsPlugin       *plugin,
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 3fb3f9a..a8f2f04 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -134,6 +134,28 @@ gs_plugin_status_to_string (GsPluginStatus status)
                return "removing";
        return "unknown";
 }
+
+/**
+ * gs_plugin_set_name:
+ * @plugin: a #GsPlugin
+ * @name: a plugin name
+ *
+ * Sets the name of the plugin.
+ *
+ * Plugins are not required to set the plugin name as it is automatically set
+ * from the `.so` filename.
+ *
+ * Since: 3.26
+ **/
+void
+gs_plugin_set_name (GsPlugin *plugin, const gchar *name)
+{
+       GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+       if (priv->name != NULL)
+               g_free (priv->name);
+       priv->name = g_strdup (name);
+}
+
 /**
  * gs_plugin_create:
  * @filename: an absolute filename
@@ -167,7 +189,6 @@ gs_plugin_create (const gchar *filename, GError **error)
        /* create new plugin */
        plugin = gs_plugin_new ();
        priv = gs_plugin_get_instance_private (plugin);
-       priv->name = g_strdup (basename + 13);
        priv->module = g_module_open (filename, 0);
        if (priv->module == NULL) {
                g_set_error (error,
@@ -177,6 +198,7 @@ gs_plugin_create (const gchar *filename, GError **error)
                             filename, g_module_error ());
                return NULL;
        }
+       gs_plugin_set_name (plugin, basename + 13);
        return plugin;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]