[Xfce4-commits] [apps/xfdashboard] 02/03: The plugin ID should be unique but not configurable by developer. So let ID be determine from filename - exactly: Get basename of filename and strip off the file extension. This way it's the old behaviour but the ID is set automatically.

noreply at xfce.org noreply at xfce.org
Thu Feb 18 16:16:28 CET 2016


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit 914f710112122c7ebcdea088a48ad2a9630428de
Author: Stephan Haller <nomad at froevel.de>
Date:   Thu Feb 18 16:11:59 2016 +0100

    The plugin ID should be unique but not configurable by developer. So let ID be determine from filename - exactly: Get basename of filename and strip off the file extension. This way it's the old behaviour but the ID is set automatically.
---
 libxfdashboard/plugin.c                         | 51 ++++++++++++++++++++++++-
 libxfdashboard/plugin.h                         |  2 +
 plugins/clock-view/Makefile.am                  |  5 ++-
 plugins/clock-view/plugin.c                     |  1 -
 plugins/gnome-shell-search-provider/Makefile.am |  5 ++-
 plugins/gnome-shell-search-provider/plugin.c    |  1 -
 plugins/hot-corner/Makefile.am                  |  5 ++-
 plugins/hot-corner/plugin.c                     |  1 -
 8 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/libxfdashboard/plugin.c b/libxfdashboard/plugin.c
index 6076d6f..69d54fd 100644
--- a/libxfdashboard/plugin.c
+++ b/libxfdashboard/plugin.c
@@ -826,9 +826,9 @@ static void xfdashboard_plugin_class_init(XfdashboardPluginClass *klass)
 	XfdashboardPluginProperties[PROP_ID]=
 		g_param_spec_string("id",
 							_("ID"),
-							_("The unique ID used to register this plugin"),
+							_("The unique ID for this plugin"),
 							NULL,
-							G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+							G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
 
 	XfdashboardPluginProperties[PROP_NAME]=
 		g_param_spec_string("name",
@@ -966,13 +966,40 @@ GQuark xfdashboard_plugin_error_quark(void)
 XfdashboardPlugin* xfdashboard_plugin_new(const gchar *inPluginFilename, GError **outError)
 {
 	GObject			*plugin;
+	gchar			*pluginBasename;
+	gchar			*pluginID;
 
 	g_return_val_if_fail(inPluginFilename && *inPluginFilename, NULL);
 	g_return_val_if_fail(outError==NULL || *outError==NULL, FALSE);
 
+	/* Get plugin ID from filename */
+	pluginBasename=g_filename_display_basename(inPluginFilename);
+	if(!pluginBasename)
+	{
+		/* Set error */
+		g_set_error(outError,
+					XFDASHBOARD_PLUGIN_ERROR,
+					XFDASHBOARD_PLUGIN_ERROR_ERROR,
+					_("Could not get plugin ID for file %s"),
+					inPluginFilename);
+
+		/* Return NULL to indicate failure */
+		return(NULL);
+	}
+
+	if(g_str_has_suffix(pluginBasename, G_MODULE_SUFFIX))
+	{
+		pluginID=g_strndup(pluginBasename, strlen(pluginBasename)-strlen(G_MODULE_SUFFIX)-1);
+	}
+		else
+		{
+			pluginID=g_strdup(pluginBasename);
+		}
+
 	/* Create object instance */
 	plugin=g_object_new(XFDASHBOARD_TYPE_PLUGIN,
 						"filename", inPluginFilename,
+						"id", pluginID,
 						NULL);
 	if(!plugin)
 	{
@@ -982,6 +1009,10 @@ XfdashboardPlugin* xfdashboard_plugin_new(const gchar *inPluginFilename, GError
 					XFDASHBOARD_PLUGIN_ERROR_ERROR,
 					_("Could not create plugin instance"));
 
+		/* Release allocated resources */
+		if(pluginID) g_free(pluginID);
+		if(pluginBasename) g_free(pluginBasename);
+
 		/* Return NULL to indicate failure */
 		return(NULL);
 	}
@@ -996,6 +1027,10 @@ XfdashboardPlugin* xfdashboard_plugin_new(const gchar *inPluginFilename, GError
 					"%s",
 					_xfdashboard_plugin_get_loading_error(XFDASHBOARD_PLUGIN(plugin)));
 
+		/* Release allocated resources */
+		if(pluginID) g_free(pluginID);
+		if(pluginBasename) g_free(pluginBasename);
+
 		/* At this point we return NULL to indicate failure although the object
 		 * instance (subclassing GTypeModule) now exists and it was tried to
 		 * use it (via g_type_module_use). As describe in GObject documentation
@@ -1006,10 +1041,22 @@ XfdashboardPlugin* xfdashboard_plugin_new(const gchar *inPluginFilename, GError
 		return(NULL);
 	}
 
+	/* Release allocated resources */
+	if(pluginID) g_free(pluginID);
+	if(pluginBasename) g_free(pluginBasename);
+
 	/* Plugin loaded so return it */
 	return(XFDASHBOARD_PLUGIN(plugin));
 }
 
+/* Get ID of plugin */
+const gchar* xfdashboard_plugin_get_id(XfdashboardPlugin *self)
+{
+	g_return_val_if_fail(XFDASHBOARD_IS_PLUGIN(self), NULL);
+
+	return(self->priv->id);
+}
+
 /* Set plugin information */
 void xfdashboard_plugin_set_info(XfdashboardPlugin *self,
 									const gchar *inFirstPropertyName, ...)
diff --git a/libxfdashboard/plugin.h b/libxfdashboard/plugin.h
index 7640efa..1a6ce16 100644
--- a/libxfdashboard/plugin.h
+++ b/libxfdashboard/plugin.h
@@ -99,6 +99,8 @@ GType xfdashboard_plugin_get_type(void) G_GNUC_CONST;
 
 XfdashboardPlugin* xfdashboard_plugin_new(const gchar *inPluginFilename, GError **outError);
 
+const gchar* xfdashboard_plugin_get_id(XfdashboardPlugin *self);
+
 void xfdashboard_plugin_set_info(XfdashboardPlugin *self,
 									const gchar *inFirstPropertyName, ...)
 									G_GNUC_NULL_TERMINATED;
diff --git a/plugins/clock-view/Makefile.am b/plugins/clock-view/Makefile.am
index 3658385..4b4a45f 100644
--- a/plugins/clock-view/Makefile.am
+++ b/plugins/clock-view/Makefile.am
@@ -1,4 +1,5 @@
 plugindir = $(libdir)/xfdashboard/plugins
+PLUGIN_ID = clock-view
 
 AM_CPPFLAGS = \
 	-I$(top_builddir) \
@@ -6,7 +7,7 @@ AM_CPPFLAGS = \
 	-DG_LOG_DOMAIN=\"xfdashboard-plugin-clock_view\" \
 	-DLIBEXECDIR=\"$(libexecdir)\" \
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-	-DPLUGIN_ID=\"de.froevel.xfdashboard.clock\"
+	-DPLUGIN_ID=\"$(PLUGIN_ID)\"
 
 plugin_LTLIBRARIES = \
 	clock-view.la
@@ -26,8 +27,10 @@ clock_view_la_CFLAGS = \
 clock_view_la_LDFLAGS = \
 	-avoid-version \
 	-export-dynamic \
+	-export-symbols-regex '^plugin_init$$' \
 	-no-undefined \
 	-module \
+	-shared \
 	$(PLATFORM_LDFLAGS)
 
 clock_view_la_LIBADD = \
diff --git a/plugins/clock-view/plugin.c b/plugins/clock-view/plugin.c
index 1d48751..c8a0243 100644
--- a/plugins/clock-view/plugin.c
+++ b/plugins/clock-view/plugin.c
@@ -76,7 +76,6 @@ G_MODULE_EXPORT void plugin_init(XfdashboardPlugin *self)
 
 	/* Set plugin info */
 	xfdashboard_plugin_set_info(self,
-								"id", PLUGIN_ID,
 								"name", _("Clock"),
 								"description", _("Adds new a view showing a clock"),
 								"author", "Stephan Haller <nomad at froevel.de>",
diff --git a/plugins/gnome-shell-search-provider/Makefile.am b/plugins/gnome-shell-search-provider/Makefile.am
index 918eb0f..25d386d 100644
--- a/plugins/gnome-shell-search-provider/Makefile.am
+++ b/plugins/gnome-shell-search-provider/Makefile.am
@@ -1,4 +1,5 @@
 plugindir = $(libdir)/xfdashboard/plugins
+PLUGIN_ID = gnome-shell-search-provider
 
 AM_CPPFLAGS = \
 	-I$(top_builddir) \
@@ -6,7 +7,7 @@ AM_CPPFLAGS = \
 	-DG_LOG_DOMAIN=\"xfdashboard-plugin-gnome_shell_search_provider\" \
 	-DLIBEXECDIR=\"$(libexecdir)\" \
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-	-DPLUGIN_ID=\"de.froevel.xfdashboard.gnome-shell-search-provider\" \
+	-DPLUGIN_ID=\"$(PLUGIN_ID)\" \
 	-DGNOME_SHELL_PROVIDERS_PATH=\"$(prefix)/share/gnome-shell/search-providers\"
 
 plugin_LTLIBRARIES = \
@@ -27,8 +28,10 @@ gnome_shell_search_provider_la_CFLAGS = \
 gnome_shell_search_provider_la_LDFLAGS = \
 	-avoid-version \
 	-export-dynamic \
+	-export-symbols-regex '^plugin_init$$' \
 	-no-undefined \
 	-module \
+	-shared \
 	$(PLATFORM_LDFLAGS)
 
 gnome_shell_search_provider_la_LIBADD = \
diff --git a/plugins/gnome-shell-search-provider/plugin.c b/plugins/gnome-shell-search-provider/plugin.c
index 7d5d307..1b6e217 100644
--- a/plugins/gnome-shell-search-provider/plugin.c
+++ b/plugins/gnome-shell-search-provider/plugin.c
@@ -437,7 +437,6 @@ G_MODULE_EXPORT void plugin_init(XfdashboardPlugin *self)
 
 	/* Set plugin info */
 	xfdashboard_plugin_set_info(self,
-								"id", PLUGIN_ID,
 								"name", _("Gnome-Shell search provider"),
 								"description", _("Uses Gnome-Shell search providers as source for searches"),
 								"author", "Stephan Haller <nomad at froevel.de>",
diff --git a/plugins/hot-corner/Makefile.am b/plugins/hot-corner/Makefile.am
index fd22494..f4f1f0c 100644
--- a/plugins/hot-corner/Makefile.am
+++ b/plugins/hot-corner/Makefile.am
@@ -1,4 +1,5 @@
 plugindir = $(libdir)/xfdashboard/plugins
+PLUGIN_ID = hot-corner
 
 AM_CPPFLAGS = \
 	-I$(top_builddir) \
@@ -6,7 +7,7 @@ AM_CPPFLAGS = \
 	-DG_LOG_DOMAIN=\"xfdashboard-plugin-hot_corner\" \
 	-DLIBEXECDIR=\"$(libexecdir)\" \
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-	-DPLUGIN_ID=\"de.froevel.xfdashboard.hot-corner\"
+	-DPLUGIN_ID=\"$(PLUGIN_ID)\"
 
 plugin_LTLIBRARIES = \
 	hot-corner.la
@@ -26,8 +27,10 @@ hot_corner_la_CFLAGS = \
 hot_corner_la_LDFLAGS = \
 	-avoid-version \
 	-export-dynamic \
+	-export-symbols-regex '^plugin_init$$' \
 	-no-undefined \
 	-module \
+	-shared \
 	$(PLATFORM_LDFLAGS)
 
 hot_corner_la_LIBADD = \
diff --git a/plugins/hot-corner/plugin.c b/plugins/hot-corner/plugin.c
index a594eb9..5cb9450 100644
--- a/plugins/hot-corner/plugin.c
+++ b/plugins/hot-corner/plugin.c
@@ -72,7 +72,6 @@ G_MODULE_EXPORT void plugin_init(XfdashboardPlugin *self)
 
 	/* Set plugin info */
 	xfdashboard_plugin_set_info(self,
-								"id", PLUGIN_ID,
 								"name", _("Hot corner"),
 								"description", _("Activates xfdashboard when pointer is moved to a configured corner of monitor"),
 								"author", "Stephan Haller <nomad at froevel.de>",

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list