[gnome-photos] 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] application, base-item: Simplify photos_base_item_save_async
- Date: Wed, 23 Dec 2015 19:27:42 +0000 (UTC)
commit a11475e123bc95514b6d1885db5aa345f1deed98
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 ecac58f..693a306 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -869,7 +869,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));
@@ -905,10 +904,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)
@@ -918,7 +915,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 d627f4c..0e65abe 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -1880,7 +1880,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)
@@ -1888,15 +1887,18 @@ photos_base_item_save_async (PhotosBaseItem *self,
PhotosBaseItemPrivate *priv = self->priv;
GFile *file;
GTask *task;
+ gchar *type = NULL;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
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);
@@ -1911,6 +1913,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 f349610..1aea7d3 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -207,7 +207,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]