[gthumb] selections: return an error if the selection number is invalid
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] selections: return an error if the selection number is invalid
- Date: Mon, 26 Mar 2012 15:56:26 +0000 (UTC)
commit 41940ea53ad15bf0ae9901861b3494dd10695954
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Mar 26 17:52:57 2012 +0200
selections: return an error if the selection number is invalid
extensions/selections/gth-file-source-selections.c | 9 ++++
extensions/selections/gth-selections-manager.c | 43 ++++++++++---------
extensions/selections/gth-selections-manager.h | 4 ++
3 files changed, 36 insertions(+), 20 deletions(-)
---
diff --git a/extensions/selections/gth-file-source-selections.c b/extensions/selections/gth-file-source-selections.c
index bbd0f7c..35a2236 100644
--- a/extensions/selections/gth-file-source-selections.c
+++ b/extensions/selections/gth-file-source-selections.c
@@ -129,6 +129,15 @@ gth_file_source_selections_read_metadata (GthFileSource *file_source,
ReadyCallback callback,
gpointer user_data)
{
+ int n_selection;
+
+ n_selection = _g_file_get_n_selection (file_data->file);
+ if (n_selection < 0) {
+ GError *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Invalid location." /* FIXME: mark as translatable after string freeze */);
+ object_ready_with_error (file_source, callback, user_data, error);
+ return;
+ }
+
update_file_info (file_source, file_data->file, file_data->info);
object_ready_with_error (file_source, callback, user_data, NULL);
}
diff --git a/extensions/selections/gth-selections-manager.c b/extensions/selections/gth-selections-manager.c
index 03de1ac..b08af35 100644
--- a/extensions/selections/gth-selections-manager.c
+++ b/extensions/selections/gth-selections-manager.c
@@ -187,26 +187,6 @@ selections_manager_fec_done_cb (GObject *object,
}
-static int
-_g_file_get_n_selection (GFile *file)
-{
- char *uri;
- int n = -1;
-
- uri = g_file_get_uri (file);
- if (! g_str_has_prefix (uri, "selection:///"))
- n = -1;
- else if (strcmp (uri, "selection:///") == 0)
- n = 0;
- else
- n = atoi (uri + strlen ("selection:///"));
-
- g_free (uri);
-
- return n;
-}
-
-
void
gth_selections_manager_update_file_info (GFile *file,
GFileInfo *info)
@@ -435,3 +415,26 @@ gth_selections_manager_reorder (GFile *folder,
{
/* FIXME */
}
+
+
+int
+_g_file_get_n_selection (GFile *file)
+{
+ char *uri;
+ int n = -1;
+
+ uri = g_file_get_uri (file);
+ if (! g_str_has_prefix (uri, "selection:///"))
+ n = -1;
+ else if (strcmp (uri, "selection:///") == 0)
+ n = 0;
+ else
+ n = atoi (uri + strlen ("selection:///"));
+
+ g_free (uri);
+
+ if (n > N_SELECTIONS)
+ n = -1;
+
+ return n;
+}
diff --git a/extensions/selections/gth-selections-manager.h b/extensions/selections/gth-selections-manager.h
index 6fd06a7..08ac363 100644
--- a/extensions/selections/gth-selections-manager.h
+++ b/extensions/selections/gth-selections-manager.h
@@ -68,6 +68,10 @@ void gth_selections_manager_reorder (GFile *folder,
void gth_selections_manager_update_file_info (GFile *file,
GFileInfo *info);
+/* utilities */
+
+int _g_file_get_n_selection (GFile *file);
+
G_END_DECLS
#endif /* GTH_SELECTIONS_MANAGER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]