[gthumb/ext] correctly compute the extension name for installed extensions
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] correctly compute the extension name for installed extensions
- Date: Sun, 2 Aug 2009 21:31:30 +0000 (UTC)
commit 3bd583d60f819fe30876acf77db4e0c18ef2085e
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Aug 2 23:30:32 2009 +0200
correctly compute the extension name for installed extensions
gthumb/glib-utils.c | 22 ++++++++++++++++++++++
gthumb/glib-utils.h | 2 ++
gthumb/gth-extensions.c | 8 +++++++-
3 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/gthumb/glib-utils.c b/gthumb/glib-utils.c
index fb8c1b4..ae83f03 100644
--- a/gthumb/glib-utils.c
+++ b/gthumb/glib-utils.c
@@ -968,6 +968,28 @@ _g_strv_find (char **v,
}
+char *
+_g_str_remove_suffix (const char *s,
+ const char *suffix)
+{
+ int s_len;
+ int suffix_len;
+
+ if (s == NULL)
+ return NULL;
+ if (suffix == NULL)
+ return g_strdup (s);
+
+ s_len = strlen (s);
+ suffix_len = strlen (suffix);
+
+ if (suffix_len >= s_len)
+ return g_strdup ("");
+ else
+ return g_strndup (s, s_len - suffix_len);
+}
+
+
/* Regexp utils */
static char **
diff --git a/gthumb/glib-utils.h b/gthumb/glib-utils.h
index bb9620c..fb4e29d 100644
--- a/gthumb/glib-utils.h
+++ b/gthumb/glib-utils.h
@@ -172,6 +172,8 @@ const char * get_static_string (const char *s);
char * _g_rand_string (int len);
int _g_strv_find (char **v,
const char *s);
+char * _g_str_remove_suffix (const char *s,
+ const char *suffix);
/* Regexp utils */
diff --git a/gthumb/gth-extensions.c b/gthumb/gth-extensions.c
index 69a664e..2c2e7b1 100644
--- a/gthumb/gth-extensions.c
+++ b/gthumb/gth-extensions.c
@@ -649,6 +649,7 @@ gth_extension_manager_load_extensions (GthExtensionManager *self)
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) {
const char *name;
GFile *ext_file;
+ char *ext_name;
GthExtensionDescription *ext_desc;
name = g_file_info_get_name (info);
@@ -661,18 +662,23 @@ gth_extension_manager_load_extensions (GthExtensionManager *self)
basename = g_strconcat (name, EXTENSION_SUFFIX, NULL);
path = g_build_filename (GTHUMB_EXTENSIONS_DIR, name, basename, NULL);
ext_file = g_file_new_for_path (path);
+ ext_name = g_strdup (name);
g_free (path);
g_free (basename);
}
#else
+ if (! g_str_has_suffix (name, EXTENSION_SUFFIX))
+ continue;
ext_file = g_file_get_child (extensions_dir, name);
+ ext_name = _g_str_remove_suffix (name, EXTENSION_SUFFIX);
#endif
ext_desc = gth_extension_description_new (ext_file);
if (ext_desc != NULL)
- g_hash_table_insert (self->priv->extensions, g_strdup (name), ext_desc);
+ g_hash_table_insert (self->priv->extensions, g_strdup (ext_name), ext_desc);
+ g_free (ext_name);
g_object_unref (ext_file);
g_object_unref (info);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]