[gnome-photos/wip/rishi/misc-fixes: 16/24] application, base-item: Simplify photos_base_item_save_async
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/misc-fixes: 16/24] application, base-item: Simplify photos_base_item_save_async
- Date: Wed, 23 Dec 2015 09:24:06 +0000 (UTC)
commit a5a0fb02d339071e93fafe48c9c19c1393bd9b21
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Dec 22 20:09:28 2015 +0100
application, base-item: Simplify photos_base_item_save_async
There is no need for the caller to pass the type. A BaseItem instance
can figure it out on its own.
src/photos-application.c | 6 +-----
src/photos-base-item.c | 7 +++++--
src/photos-base-item.h | 1 -
3 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 116f2a6..069ee00 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -918,7 +918,6 @@ photos_application_save (PhotosApplication *self)
gchar *origin = NULL;
gchar *parent_path = NULL;
gchar *path = NULL;
- gchar *type = NULL;
gchar *uri = NULL;
item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (priv->state->item_mngr));
@@ -954,10 +953,8 @@ photos_application_save (PhotosApplication *self)
path = g_build_filename (parent_path, filename, NULL);
uri = photos_utils_convert_path_to_uri (path);
- type = photos_utils_get_pixbuf_type_from_mime_type (mime_type);
-
g_application_hold (G_APPLICATION (self));
- photos_base_item_save_async (item, uri, type, NULL, photos_application_save_save, self);
+ photos_base_item_save_async (item, uri, NULL, photos_application_save_save, self);
out:
if (now != NULL)
@@ -967,7 +964,6 @@ photos_application_save (PhotosApplication *self)
g_free (origin);
g_free (parent_path);
g_free (path);
- g_free (type);
g_free (uri);
g_clear_object (&parent);
}
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index be8b1a2..ca5c089 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -2007,7 +2007,6 @@ photos_base_item_refresh (PhotosBaseItem *self)
void
photos_base_item_save_async (PhotosBaseItem *self,
const gchar *uri,
- const gchar *type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -2015,17 +2014,20 @@ photos_base_item_save_async (PhotosBaseItem *self,
PhotosBaseItemPrivate *priv;
GFile *file;
GTask *task;
+ gchar *type = NULL;
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 (type != NULL && type[0] != '\0');
g_return_if_fail (priv->edit_graph != NULL);
g_return_if_fail (priv->load_graph != NULL);
g_return_if_fail (priv->processor != NULL);
g_return_if_fail (!gegl_processor_work (priv->processor, NULL));
+ type = photos_utils_get_pixbuf_type_from_mime_type (priv->mime_type);
+ g_return_if_fail (type != NULL);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, photos_base_item_save_async);
g_task_set_task_data (task, g_strdup (type), g_free);
@@ -2040,6 +2042,7 @@ photos_base_item_save_async (PhotosBaseItem *self,
photos_base_item_save_replace,
g_object_ref (task));
+ g_free (type);
g_object_unref (file);
g_object_unref (task);
}
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index ee2702d..ae5153b 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -219,7 +219,6 @@ void photos_base_item_refresh (PhotosBaseItem *se
void photos_base_item_save_async (PhotosBaseItem *self,
const gchar *uri,
- const gchar *type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]