[frogr] Refactor some code into helper functions



commit 6fa1b9ee3f6dad901ba50e6a11de84a890a55402
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Fri Aug 19 12:10:24 2011 +0200

    Refactor some code into helper functions

 src/frogr-picture-loader.c   |   35 ++++++++++++++++++-----------------
 src/frogr-picture-uploader.c |   25 +++++++++++++++++--------
 2 files changed, 35 insertions(+), 25 deletions(-)
---
diff --git a/src/frogr-picture-loader.c b/src/frogr-picture-loader.c
index c40f91f..413e9e3 100644
--- a/src/frogr-picture-loader.c
+++ b/src/frogr-picture-loader.c
@@ -104,6 +104,7 @@ static FspDataLocation *get_location_from_exif (ExifData *exif_data);
 
 static gchar *remove_spaces_from_keyword (const gchar *keyword);
 static gchar *import_tags_from_xmp_keywords (const char *buffer, size_t len);
+static void _finish_task_and_self_destruct (FrogrPictureLoader *self);
 
 /* Private API */
 
@@ -193,15 +194,9 @@ _load_next_picture (FrogrPictureLoader *self)
     }
   else
     {
-      /* Update status and progress */
+      /* Update status and progress and finish */
       _update_status_and_progress (self);
-
-      /* Execute final callback */
-      if (priv->pictures_loaded_cb)
-        priv->pictures_loaded_cb (priv->object);
-
-      /* Process finished, self-destruct */
-      g_object_unref (self);
+      _finish_task_and_self_destruct (self);
     }
 }
 
@@ -396,17 +391,9 @@ _load_next_picture_cb (GObject *object,
   if (keep_going)
     _load_next_picture (self);
   else
-    {
-      /* Execute final callback */
-      if (priv->pictures_loaded_cb)
-        priv->pictures_loaded_cb (priv->object);
-
-      /* Process finished, self-destruct */
-      g_object_unref (self);
-    }
+    _finish_task_and_self_destruct (self);
 }
 
-
 /* This function was taken from tracker, licensed under the GNU Lesser
  * General Public License Version 2.1 (Copyright 2009, Nokia Corp.) */
 static gboolean
@@ -569,6 +556,20 @@ import_tags_from_xmp_keywords (const char *buffer, size_t len)
 }
 
 static void
+_finish_task_and_self_destruct (FrogrPictureLoader *self)
+{
+  FrogrPictureLoaderPrivate *priv =
+    FROGR_PICTURE_LOADER_GET_PRIVATE (self);
+
+  /* Execute final callback */
+  if (priv->pictures_loaded_cb)
+    priv->pictures_loaded_cb (priv->object);
+
+  /* Process finished, self-destruct */
+  g_object_unref (self);
+}
+
+static void
 _frogr_picture_loader_dispose (GObject* object)
 {
   FrogrPictureLoaderPrivate *priv =
diff --git a/src/frogr-picture-uploader.c b/src/frogr-picture-uploader.c
index 5daea70..964be7f 100644
--- a/src/frogr-picture-uploader.c
+++ b/src/frogr-picture-uploader.c
@@ -62,6 +62,7 @@ static void _upload_next_picture (FrogrPictureUploader *self);
 static void _upload_next_picture_cb (FrogrPictureUploader *self,
                                      FrogrPicture *picture,
                                      GError *error);
+static void _finish_task_and_self_destruct (FrogrPictureUploader *self);
 
 /* Private API */
 
@@ -112,15 +113,9 @@ _upload_next_picture (FrogrPictureUploader *self)
     }
   else
     {
-      /* Hide progress bar dialog */
+      /* Hide progress bar dialog and finish */
       frogr_main_view_hide_progress (priv->mainview);
-
-      /* Execute final callback */
-      if (priv->pictures_uploaded_cb)
-        priv->pictures_uploaded_cb (priv->object, priv->error);
-
-      /* Process finished, self-destruct */
-      g_object_unref (self);
+      _finish_task_and_self_destruct (self);
     }
 }
 
@@ -155,6 +150,20 @@ _upload_next_picture_cb (FrogrPictureUploader *self,
 }
 
 static void
+_finish_task_and_self_destruct (FrogrPictureUploader *self)
+{
+  FrogrPictureUploaderPrivate *priv =
+    FROGR_PICTURE_UPLOADER_GET_PRIVATE (self);
+
+  /* Execute final callback */
+  if (priv->pictures_uploaded_cb)
+    priv->pictures_uploaded_cb (priv->object, priv->error);
+
+  /* Process finished, self-destruct */
+  g_object_unref (self);
+}
+
+static void
 _frogr_picture_uploader_dispose (GObject* object)
 {
   FrogrPictureUploaderPrivate *priv =



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]