[gthumb] made other extensions mandatory
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] made other extensions mandatory
- Date: Sun, 29 Mar 2015 17:34:51 +0000 (UTC)
commit b4f3ff1d32d8f448d3a01f55459a3e350be7702e
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Mar 29 19:26:45 2015 +0200
made other extensions mandatory
jpeg_utils, image_viewer and file_tools are mandatory to make
the application useful even when no extension is loaded.
extensions/cairo_io/cairo_io.extension.in.in | 2 +-
extensions/file_tools/file_tools.extension.in.in | 8 +---
.../image_viewer/image_viewer.extension.in.in | 8 +---
extensions/jpeg_utils/jpeg_utils.extension.in.in | 2 +-
gthumb/glib-utils.c | 19 +++++++
gthumb/glib-utils.h | 2 +
gthumb/gth-main.c | 50 +++++++++++---------
7 files changed, 53 insertions(+), 38 deletions(-)
---
diff --git a/extensions/cairo_io/cairo_io.extension.in.in b/extensions/cairo_io/cairo_io.extension.in.in
index 5dc53c6..9cdc5a4 100644
--- a/extensions/cairo_io/cairo_io.extension.in.in
+++ b/extensions/cairo_io/cairo_io.extension.in.in
@@ -1,5 +1,5 @@
[Extension]
-Hidden=true
+Mandatory=true
[Loader]
Type=module
diff --git a/extensions/file_tools/file_tools.extension.in.in
b/extensions/file_tools/file_tools.extension.in.in
index 7f4a7eb..168f639 100644
--- a/extensions/file_tools/file_tools.extension.in.in
+++ b/extensions/file_tools/file_tools.extension.in.in
@@ -1,11 +1,5 @@
[Extension]
-_Name=Image tools
-_Description=Basic tools to modify images.
-_Authors=gthumb development team
-Copyright=Copyright © 2009-2013 The Free Software Foundation, Inc.
-Version=%VERSION%
-Icon=palette
-Category=File-Tool
+Mandatory=true
[Loader]
Type=module
diff --git a/extensions/image_viewer/image_viewer.extension.in.in
b/extensions/image_viewer/image_viewer.extension.in.in
index 1c367c4..b409f0e 100644
--- a/extensions/image_viewer/image_viewer.extension.in.in
+++ b/extensions/image_viewer/image_viewer.extension.in.in
@@ -1,11 +1,5 @@
[Extension]
-_Name=Image viewer
-_Description=Basic image viewing.
-_Authors=gthumb development team
-Copyright=Copyright © 2009-2013 The Free Software Foundation, Inc.
-Version=%VERSION%
-Icon=image-x-generic
-Category=Viewer
+Mandatory=true
[Loader]
Type=module
diff --git a/extensions/jpeg_utils/jpeg_utils.extension.in.in
b/extensions/jpeg_utils/jpeg_utils.extension.in.in
index ad8b8db..f53d1be 100644
--- a/extensions/jpeg_utils/jpeg_utils.extension.in.in
+++ b/extensions/jpeg_utils/jpeg_utils.extension.in.in
@@ -1,5 +1,5 @@
[Extension]
-Hidden=true
+Mandatory=true
[Loader]
Type=module
diff --git a/gthumb/glib-utils.c b/gthumb/glib-utils.c
index 82a5d43..cd74a8f 100644
--- a/gthumb/glib-utils.c
+++ b/gthumb/glib-utils.c
@@ -1338,6 +1338,25 @@ _g_strv_prepend (char **str_array,
}
+char **
+_g_strv_concat (const char *const *strv1,
+ const char *const *strv2)
+{
+ char **result;
+ int i, j;
+
+ result = g_new (char *, g_strv_length (strv1) + g_strv_length (strv2) + 1);
+ i = 0;
+ for (j = 0; strv1[j] != NULL; j++)
+ result[i++] = g_strdup (strv1[j]);
+ for (j = 0; strv2[j] != NULL; j++)
+ result[i++] = g_strdup (strv2[j]);
+ result[i] = NULL;
+
+ return result;
+}
+
+
gboolean
_g_strv_remove (char **str_array,
const char *str)
diff --git a/gthumb/glib-utils.h b/gthumb/glib-utils.h
index de249bf..af3b340 100644
--- a/gthumb/glib-utils.h
+++ b/gthumb/glib-utils.h
@@ -213,6 +213,8 @@ int _g_strv_find (char **v,
const char *s);
char ** _g_strv_prepend (char **str_array,
const char *str);
+char ** _g_strv_concat (const char *const *strv1,
+ const char *const *strv2);
gboolean _g_strv_remove (char **str_array,
const char *str);
char * _g_str_remove_suffix (const char *s,
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index 470083c..4a70138 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -1202,8 +1202,13 @@ gth_main_get_default_extension_manager (void)
void
gth_main_activate_extensions (void)
{
- const char *mandatory_extensions[] = { "file_viewer",
+ const char *mandatory_extensions[] = { "file_viewer", /* keep the file viewer before any other
viewer (see comment in gth-browser:file_metadata_ready_cb). */
+#ifdef HAVE_LIBJPEG
+ "jpeg_utils", /* mandatory if jpeg support is activated at
compile time */
+#endif
"cairo_io",
+ "image_viewer",
+ "file_tools",
NULL };
const char *default_extensions[] = { "23hq",
"bookmarks",
@@ -1218,14 +1223,12 @@ gth_main_activate_extensions (void)
"exiv2_tools",
"facebook",
"file_manager",
- "file_tools",
"find_duplicates",
"flicker",
"gstreamer_tools",
"gstreamer_utils",
"image_print",
"image_rotation",
- "image_viewer",
"importer",
"jpeg_utils",
"list_tools",
@@ -1245,7 +1248,8 @@ gth_main_activate_extensions (void)
int i;
GError *error = NULL;
GSettings *settings;
- char **active_extensions;
+ char **user_actived_extensions;
+ char **actived_extensions;
GList *ordered_extensions;
GthExtensionManager *manager;
GList *scan;
@@ -1253,43 +1257,45 @@ gth_main_activate_extensions (void)
if (Main->priv->extension_manager == NULL)
Main->priv->extension_manager = gth_extension_manager_new ();
- for (i = 0; mandatory_extensions[i] != NULL; i++) {
- if (! gth_extension_manager_activate (Main->priv->extension_manager, mandatory_extensions[i],
&error)) {
- g_critical ("Could not load the mandatory extension '%s': %s",
mandatory_extensions[i], error->message);
- abort ();
- }
- }
-
settings = g_settings_new (GTHUMB_GENERAL_SCHEMA);
- active_extensions = g_settings_get_strv (settings, PREF_GENERAL_ACTIVE_EXTENSIONS);
- if ((active_extensions != NULL)
- && (active_extensions[1] == NULL)
- && (g_strcmp0 (active_extensions[0], "default") == 0))
+ user_actived_extensions = g_settings_get_strv (settings, PREF_GENERAL_ACTIVE_EXTENSIONS);
+ if ((user_actived_extensions != NULL)
+ && (user_actived_extensions[1] == NULL)
+ && (g_strcmp0 (user_actived_extensions[0], "default") == 0))
{
- g_strfreev (active_extensions);
- active_extensions = g_strdupv ((char **) default_extensions);
- g_settings_set_strv (settings, PREF_GENERAL_ACTIVE_EXTENSIONS, (const char *const *)
active_extensions);
+ g_strfreev (user_actived_extensions);
+ user_actived_extensions = g_strdupv ((char **) default_extensions);
+ g_settings_set_strv (settings, PREF_GENERAL_ACTIVE_EXTENSIONS, (const char *const *)
user_actived_extensions);
}
- ordered_extensions = gth_extension_manager_order_extensions (Main->priv->extension_manager,
active_extensions);
+ actived_extensions = _g_strv_concat (mandatory_extensions, (const char *const *)
user_actived_extensions);
+ ordered_extensions = gth_extension_manager_order_extensions (Main->priv->extension_manager,
actived_extensions);
manager = gth_main_get_default_extension_manager ();
for (scan = ordered_extensions; scan; scan = scan->next) {
char *name = scan->data;
+ gboolean mandatory;
GthExtensionDescription *description;
GError *error = NULL;
+ mandatory = g_strv_contains (mandatory_extensions, name);
description = gth_extension_manager_get_description (manager, name);
- if ((description != NULL) && (description->hidden || description->mandatory))
+ if (! mandatory && (description != NULL) && description->hidden)
continue;
if (! gth_extension_manager_activate (Main->priv->extension_manager, name, &error)) {
- g_warning ("Could not load the '%s' extension: %s", name, error->message);
+ if (mandatory) {
+ g_critical ("Could not load the mandatory extension '%s': %s", name,
error->message);
+ abort ();
+ }
+ else
+ g_warning ("Could not load the '%s' extension: %s", name, error->message);
g_clear_error (&error);
}
}
_g_string_list_free (ordered_extensions);
- g_strfreev (active_extensions);
+ g_strfreev (actived_extensions);
+ g_strfreev (user_actived_extensions);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]