[gnome-photos] application, base-item: Rework photos_base_item_save_async
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] application, base-item: Rework photos_base_item_save_async
- Date: Mon, 28 Dec 2015 18:16:46 +0000 (UTC)
commit 5bcbe9bd90d4680a3b06e2c5423561f17c68b0a8
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Dec 22 20:17:50 2015 +0100
application, base-item: Rework photos_base_item_save_async
The UX design expects the user to specify the sub-directory within
which the item will be saved. Plus, we can simplify things a bit by
using the BaseItem's filename, which must be present if it is
editable, instead of trying to generate one.
Therefore, we rework the API to accept the sub-directory and not the
complete path to the final image.
https://bugzilla.gnome.org/show_bug.cgi?id=759363
src/photos-application.c | 27 +--------------------------
src/photos-base-item.c | 6 +++---
src/photos-base-item.h | 2 +-
3 files changed, 5 insertions(+), 30 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 09ea791..77121af 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -901,18 +901,11 @@ static void
photos_application_save (PhotosApplication *self)
{
PhotosApplicationPrivate *priv = self->priv;
- GDateTime *now = NULL;
GError *error = NULL;
GFile *parent = NULL;
PhotosBaseItem *item;
- const gchar *mime_type;
const gchar *pictures_path;
- gchar *filename = NULL;
- gchar *extension = NULL;
- gchar *origin = NULL;
gchar *parent_path = NULL;
- gchar *path = NULL;
- gchar *uri = NULL;
item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (priv->state->item_mngr));
g_return_if_fail (item != NULL);
@@ -927,29 +920,11 @@ photos_application_save (PhotosApplication *self)
goto out;
}
- now = g_date_time_new_now_local ();
- origin = g_date_time_format (now, "%Y-%m-%d %H-%M-%S");
-
- mime_type = photos_base_item_get_mime_type (item);
- extension = photos_utils_get_extension_from_mime_type (mime_type);
-
- filename = g_strdup_printf ("%s.%s", origin, extension);
- path = g_build_filename (parent_path, filename, NULL);
- uri = photos_utils_convert_path_to_uri (path);
-
g_application_hold (G_APPLICATION (self));
- photos_base_item_save_async (item, uri, NULL, photos_application_save_save, self);
+ photos_base_item_save_async (item, parent, NULL, photos_application_save_save, self);
out:
- if (now != NULL)
- g_date_time_unref (now);
-
- g_free (extension);
- g_free (filename);
- g_free (origin);
g_free (parent_path);
- g_free (path);
- g_free (uri);
g_clear_object (&parent);
}
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 0cc9956..9ee8fef 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -2012,7 +2012,7 @@ photos_base_item_refresh (PhotosBaseItem *self)
void
photos_base_item_save_async (PhotosBaseItem *self,
- const gchar *uri,
+ GFile *dir,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -2025,7 +2025,7 @@ photos_base_item_save_async (PhotosBaseItem *self,
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
priv = self->priv;
- g_return_if_fail (uri != NULL && uri[0] != '\0');
+ g_return_if_fail (G_IS_FILE (dir));
g_return_if_fail (priv->edit_graph != NULL);
g_return_if_fail (priv->load_graph != NULL);
g_return_if_fail (priv->processor != NULL);
@@ -2038,7 +2038,7 @@ photos_base_item_save_async (PhotosBaseItem *self,
g_task_set_source_tag (task, photos_base_item_save_async);
g_task_set_task_data (task, g_strdup (type), g_free);
- file = g_file_new_for_uri (uri);
+ file = g_file_get_child (dir, priv->filename);
g_file_replace_async (file,
NULL,
TRUE,
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 3f67281..e9069e3 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -218,7 +218,7 @@ gboolean photos_base_item_process_finish (PhotosBaseItem *se
void photos_base_item_refresh (PhotosBaseItem *self);
void photos_base_item_save_async (PhotosBaseItem *self,
- const gchar *uri,
+ GFile *dir,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]