[goffice] GOFileServer: pick most capable saver for given extension
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOFileServer: pick most capable saver for given extension
- Date: Thu, 10 May 2018 23:26:00 +0000 (UTC)
commit 05159ba77e5834b025decb4a60a9de543956905c
Author: Morten Welinder <terra gnome org>
Date: Thu May 10 19:25:04 2018 -0400
GOFileServer: pick most capable saver for given extension
HTML has multiple versions.
ChangeLog | 5 +++++
goffice/app/file.c | 26 +++++++++++++++++++-------
2 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 842a8c7..01e10eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-10 Morten Welinder <terra gnome org>
+
+ * goffice/app/file.c (go_file_saver_for_file_name): Pick the most
+ capable saver if multiple are possible.
+
2018-05-07 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/goffice/app/file.c b/goffice/app/file.c
index 0d5c892..250a3a3 100644
--- a/goffice/app/file.c
+++ b/goffice/app/file.c
@@ -1260,16 +1260,28 @@ GOFileSaver *
go_file_saver_for_file_name (char const *file_name)
{
GList *l;
+ GOFileSaver *best_saver = NULL;
char const *extension = gsf_extension_pointer (file_name);
- for (l = default_file_saver_list ; l != NULL; l = l->next)
- if (!strcmp (go_file_saver_get_extension (((DefaultFileSaver *)(l->data))->saver), extension))
- return ((DefaultFileSaver *)(l->data))->saver;
+ for (l = default_file_saver_list; l != NULL; l = l->next) {
+ DefaultFileSaver *def_saver = l->data;
+ GOFileSaver *saver = def_saver->saver;
+ if (g_strcmp0 (go_file_saver_get_extension (saver), extension))
+ continue;
+ return saver;
+ }
- for (l = file_saver_list; l != NULL; l = l->next)
- if (!strcmp (go_file_saver_get_extension (l->data), extension))
- return l->data;
- return NULL;
+ for (l = file_saver_list; l != NULL; l = l->next) {
+ GOFileSaver *saver = l->data;
+ if (g_strcmp0 (go_file_saver_get_extension (saver), extension))
+ continue;
+
+ if (!best_saver ||
+ (saver->save_scope < best_saver->save_scope))
+ best_saver = saver;
+ }
+
+ return best_saver;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]