[dia: 55/105] #19: Simplify dia_register_plugins_in_dir.
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia: 55/105] #19: Simplify dia_register_plugins_in_dir.
- Date: Mon, 28 Jan 2019 19:23:57 +0000 (UTC)
commit 8aee8c7d95f3f76b3746aed7f1f4c1d67b99ba50
Author: Eduard Nicodei <eddnicodei gmail com>
Date: Fri Jan 4 00:03:02 2019 +0000
#19: Simplify dia_register_plugins_in_dir.
- This actually fixes some issues with `ninja run` not detecting all
plugins.
lib/plug-ins.c | 38 ++++++++------------------------------
1 file changed, 8 insertions(+), 30 deletions(-)
---
diff --git a/lib/plug-ins.c b/lib/plug-ins.c
index 10f6afbd..478e845a 100644
--- a/lib/plug-ins.c
+++ b/lib/plug-ins.c
@@ -253,6 +253,8 @@ dia_register_plugin(const gchar *filename)
GList *tmp;
PluginInfo *info;
+ g_debug("Loading %s\n", filename);
+
/* check if plugin has already been registered */
for (tmp = plugins; tmp != NULL; tmp = tmp->next) {
info = tmp->data;
@@ -280,12 +282,6 @@ dia_register_plugin(const gchar *filename)
plugins = g_list_prepend(plugins, info);
}
-static gboolean
-this_is_a_plugin(const gchar *name)
-{
- return g_str_has_suffix(name, G_MODULE_SUFFIX);
-}
-
typedef void (*ForEachInDirDoFunc)(const gchar *name);
typedef gboolean (*ForEachInDirFilterFunc)(const gchar *name);
@@ -326,35 +322,17 @@ directory_filter(const gchar *name)
static gboolean
dia_plugin_filter(const gchar *name)
{
- if (!g_file_test (name, G_FILE_TEST_IS_REGULAR))
- return FALSE;
-
- return this_is_a_plugin(name);
-}
-
-static void
-walk_dirs_for_plugins(const gchar *dirname)
-{
- for_each_in_dir(dirname,walk_dirs_for_plugins,directory_filter);
- for_each_in_dir(dirname,dia_register_plugin,dia_plugin_filter);
+ return g_str_has_suffix(name, G_MODULE_SUFFIX)
+ && g_file_test(name, G_FILE_TEST_IS_REGULAR);
}
-#define RECURSE (G_DIR_SEPARATOR_S G_DIR_SEPARATOR_S)
-
void
dia_register_plugins_in_dir(const gchar *directory)
{
- guint reclen = strlen(RECURSE);
- guint len = strlen(directory);
-
- if ((len >= reclen) &&
- (0 == strcmp(&directory[len-reclen],RECURSE))) {
- gchar *dirbase = g_strndup(directory,len-reclen);
- for_each_in_dir(dirbase,walk_dirs_for_plugins,directory_filter);
- g_free(dirbase);
- };
- /* intentional fallback. */
- for_each_in_dir(directory,dia_register_plugin,dia_plugin_filter);
+ g_debug("Registering plugins in %s\n", directory);
+
+ for_each_in_dir(directory, dia_register_plugin, dia_plugin_filter);
+ for_each_in_dir(directory, dia_register_plugins_in_dir, directory_filter);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]