[gnome-photos/wip/rishi/thumbnailer: 1/20] Split out the utility GIO wrappers into a separate file



commit 48d620f84429ed254765f657376193d4214cd5b5
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 13 23:11:07 2017 +0100

    Split out the utility GIO wrappers into a separate file
    
    We will need some of them in both the application and thumbnailer
    processes. Moving them into a separate file keeps the build
    dependencies of the thumbnailer in control.

 src/Makefile.am                |    2 +
 src/photos-application.c       |    5 +-
 src/photos-base-item.c         |   19 ++--
 src/photos-glib.c              |  293 ++++++++++++++++++++++++++++++++++++++++
 src/photos-glib.h              |   53 +++++++
 src/photos-local-item.c        |    3 +-
 src/photos-share-point-email.c |    3 +-
 src/photos-utils.c             |  265 ------------------------------------
 src/photos-utils.h             |   21 ---
 9 files changed, 365 insertions(+), 299 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c5a9bce..c1e1327 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -98,6 +98,8 @@ gnome_photos_SOURCES = \
        photos-flickr-item.h \
        photos-gegl.c \
        photos-gegl.h \
+       photos-glib.c \
+       photos-glib.h \
        photos-google-item.c \
        photos-google-item.h \
        photos-header-bar.c \
diff --git a/src/photos-application.c b/src/photos-application.c
index bf36828..97dcc67 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -45,6 +45,7 @@
 #include "photos-export-dialog.h"
 #include "photos-export-notification.h"
 #include "photos-filterable.h"
+#include "photos-glib.h"
 #include "photos-item-manager.h"
 #include "photos-main-window.h"
 #include "photos-properties-dialog.h"
@@ -1232,7 +1233,7 @@ photos_application_save_response (GtkDialog *dialog, gint response_id, gpointer
   export = g_file_new_for_path (export_path);
 
   error = NULL;
-  if (!photos_utils_make_directory_with_parents (export, NULL, &error))
+  if (!photos_glib_make_directory_with_parents (export, NULL, &error))
     {
       g_warning ("Unable to create %s: %s", export_path, error->message);
       photos_export_notification_new_with_error (error);
@@ -1256,7 +1257,7 @@ photos_application_save_response (GtkDialog *dialog, gint response_id, gpointer
   export = tmp;
 
   error = NULL;
-  if (!photos_utils_make_directory_with_parents (export, NULL, &error))
+  if (!photos_glib_make_directory_with_parents (export, NULL, &error))
     {
       g_warning ("Unable to create %s: %s", export_path, error->message);
       photos_export_notification_new_with_error (error);
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 4c95d0e..3584957 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -48,6 +48,7 @@
 #include "photos-error.h"
 #include "photos-filterable.h"
 #include "photos-gegl.h"
+#include "photos-glib.h"
 #include "photos-icons.h"
 #include "photos-local-item.h"
 #include "photos-pipeline.h"
@@ -572,7 +573,7 @@ photos_base_item_default_open (PhotosBaseItem *self, GdkScreen *screen, guint32
   if (priv->default_app != NULL)
     {
       error = NULL;
-      photos_utils_app_info_launch_uri (priv->default_app, priv->uri, NULL, &error);
+      photos_glib_app_info_launch_uri (priv->default_app, priv->uri, NULL, &error);
       if (error != NULL)
         {
           g_warning ("Unable to show URI %s: %s", priv->uri, error->message);
@@ -1864,7 +1865,7 @@ photos_base_item_save_file_create (GObject *source_object, GAsyncResult *res, gp
   cancellable = g_task_get_cancellable (task);
   data = (PhotosBaseItemSaveData *) g_task_get_task_data (task);
 
-  stream = photos_utils_file_create_finish (file, res, &unique_file, &error);
+  stream = photos_glib_file_create_finish (file, res, &unique_file, &error);
   if (error != NULL)
     {
       g_task_return_error (task, error);
@@ -1923,17 +1924,17 @@ photos_base_item_save_buffer_zoom (GObject *source_object, GAsyncResult *res, gp
   g_assert_null (data->buffer);
   data->buffer = g_object_ref (buffer_zoomed);
 
-  basename = photos_utils_filename_strip_extension (priv->filename);
+  basename = photos_glib_filename_strip_extension (priv->filename);
   extension = g_strcmp0 (priv->mime_type, "image/png") == 0 ? ".png" : ".jpg";
   filename = g_strconcat (basename, extension, NULL);
 
   file = g_file_get_child (data->dir, filename);
-  photos_utils_file_create_async (file,
-                                  G_FILE_CREATE_NONE,
-                                  G_PRIORITY_DEFAULT,
-                                  cancellable,
-                                  photos_base_item_save_file_create,
-                                  g_object_ref (task));
+  photos_glib_file_create_async (file,
+                                 G_FILE_CREATE_NONE,
+                                 G_PRIORITY_DEFAULT,
+                                 cancellable,
+                                 photos_base_item_save_file_create,
+                                 g_object_ref (task));
 
  out:
   g_free (basename);
diff --git a/src/photos-glib.c b/src/photos-glib.c
new file mode 100644
index 0000000..ed634c7
--- /dev/null
+++ b/src/photos-glib.c
@@ -0,0 +1,293 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 – 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include <string.h>
+
+#include "photos-error.h"
+#include "photos-glib.h"
+
+
+typedef struct _PhotosGLibFileCreateData PhotosGLibFileCreateData;
+
+struct _PhotosGLibFileCreateData
+{
+  GFile *dir;
+  GFileCreateFlags flags;
+  gchar *basename;
+  gchar *extension;
+  gint io_priority;
+  guint count;
+};
+
+
+gboolean
+photos_glib_app_info_launch_uri (GAppInfo *appinfo,
+                                 const gchar *uri,
+                                 GAppLaunchContext *launch_context,
+                                 GError **error)
+{
+  GList *uris = NULL;
+  gboolean ret_val;
+
+  g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
+  g_return_val_if_fail (uri != NULL && uri[0] != '\0', FALSE);
+  g_return_val_if_fail (launch_context == NULL || G_IS_APP_LAUNCH_CONTEXT (launch_context), FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  uris = g_list_prepend (uris, g_strdup (uri));
+  ret_val = g_app_info_launch_uris (appinfo, uris, launch_context, error);
+  g_list_free_full (uris, g_free);
+  return ret_val;
+}
+
+
+static gchar *
+photos_glib_filename_get_extension_offset (const gchar *filename)
+{
+  gchar *end;
+  gchar *end2;
+
+  end = strrchr (filename, '.');
+
+  if (end != NULL && end != filename)
+    {
+      if (g_strcmp0 (end, ".gz") == 0
+          || g_strcmp0 (end, ".bz2") == 0
+          || g_strcmp0 (end, ".sit") == 0
+          || g_strcmp0 (end, ".Z") == 0)
+        {
+          end2 = end - 1;
+          while (end2 > filename && *end2 != '.')
+            end2--;
+          if (end2 != filename)
+            end = end2;
+        }
+  }
+
+  return end;
+}
+
+
+static void
+photos_glib_file_create_data_free (PhotosGLibFileCreateData *data)
+{
+  g_object_unref (data->dir);
+  g_free (data->basename);
+  g_free (data->extension);
+  g_slice_free (PhotosGLibFileCreateData, data);
+}
+
+
+static gchar *
+photos_glib_file_create_data_get_filename (PhotosGLibFileCreateData *data)
+{
+  gchar *ret_val;
+
+  if (data->count > 0)
+    ret_val = g_strdup_printf ("%s(%u)%s", data->basename, data->count, data->extension);
+  else
+    ret_val = g_strdup_printf ("%s%s", data->basename, data->extension);
+
+  return ret_val;
+}
+
+
+static PhotosGLibFileCreateData *
+photos_glib_file_create_data_new (GFile *file, GFileCreateFlags flags, gint io_priority)
+{
+  PhotosGLibFileCreateData *data;
+  gchar *filename;
+
+  data = g_slice_new0 (PhotosGLibFileCreateData);
+
+  filename = g_file_get_basename (file);
+  data->dir = g_file_get_parent (file);
+  data->basename = photos_glib_filename_strip_extension (filename);
+  data->extension = g_strdup (photos_glib_filename_get_extension_offset (filename));
+  data->count = 0;
+  data->flags = flags;
+  data->io_priority = io_priority;
+
+  g_free (filename);
+
+  return data;
+}
+
+
+static void
+photos_glib_file_create_create (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+  GCancellable *cancellable;
+  GError *error = NULL;
+  GFile *file = G_FILE (source_object);
+  GFile *unique_file = NULL;
+  GFileOutputStream *stream = NULL;
+  GTask *task = G_TASK (user_data);
+  PhotosGLibFileCreateData *data;
+  gchar *filename = NULL;
+
+  cancellable = g_task_get_cancellable (task);
+  data = (PhotosGLibFileCreateData *) g_task_get_task_data (task);
+
+  stream = g_file_create_finish (file, res, &error);
+  if (error != NULL)
+    {
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+        {
+          g_task_return_error (task, error);
+          goto out;
+        }
+
+      if (data->count == G_MAXUINT)
+        {
+          g_task_return_new_error (task, PHOTOS_ERROR, 0, "Exceeded number of copies of a file");
+          goto out;
+        }
+
+      data->count++;
+
+      filename = photos_glib_file_create_data_get_filename (data);
+      unique_file = g_file_get_child (data->dir, filename);
+
+      g_file_create_async (unique_file,
+                           data->flags,
+                           data->io_priority,
+                           cancellable,
+                           photos_glib_file_create_create,
+                           g_object_ref (task));
+
+      goto out;
+    }
+
+  g_task_return_pointer (task, g_object_ref (stream), g_object_unref);
+
+ out:
+  g_free (filename);
+  g_clear_object (&stream);
+  g_clear_object (&unique_file);
+  g_object_unref (task);
+}
+
+
+void
+photos_glib_file_create_async (GFile *file,
+                                GFileCreateFlags flags,
+                                gint io_priority,
+                                GCancellable *cancellable,
+                                GAsyncReadyCallback callback,
+                                gpointer user_data)
+{
+  GTask *task;
+  PhotosGLibFileCreateData *data;
+
+  task = g_task_new (file, cancellable, callback, user_data);
+  g_task_set_source_tag (task, photos_glib_file_create_async);
+
+  data = photos_glib_file_create_data_new (file, flags, io_priority);
+  g_task_set_task_data (task, data, (GDestroyNotify) photos_glib_file_create_data_free);
+
+  g_file_create_async (file,
+                       data->flags,
+                       data->io_priority,
+                       cancellable,
+                       photos_glib_file_create_create,
+                       g_object_ref (task));
+
+  g_object_unref (task);
+}
+
+
+GFileOutputStream *
+photos_glib_file_create_finish (GFile *file, GAsyncResult *res, GFile **out_unique_file, GError **error)
+{
+  GTask *task = G_TASK (res);
+  GFileOutputStream *ret_val = NULL;
+  PhotosGLibFileCreateData *data;
+
+  g_return_val_if_fail (g_task_is_valid (res, file), NULL);
+  g_return_val_if_fail (g_task_get_source_tag (task) == photos_glib_file_create_async, NULL);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+  data = (PhotosGLibFileCreateData *) g_task_get_task_data (task);
+  g_return_val_if_fail (data != NULL, NULL);
+
+  ret_val = g_task_propagate_pointer (task, error);
+  if (ret_val == NULL)
+    goto out;
+
+  if (out_unique_file != NULL)
+    {
+      GFile *unique_file;
+      gchar *filename = NULL;
+
+      filename = photos_glib_file_create_data_get_filename (data);
+      unique_file = g_file_get_child (data->dir, filename);
+      *out_unique_file = unique_file;
+      g_free (filename);
+    }
+
+ out:
+  return ret_val;
+}
+
+
+gchar *
+photos_glib_filename_strip_extension (const gchar *filename_with_extension)
+{
+  gchar *end;
+  gchar *filename;
+
+  if (filename_with_extension == NULL)
+    return NULL;
+
+  filename = g_strdup (filename_with_extension);
+  end = photos_glib_filename_get_extension_offset (filename);
+
+  if (end != NULL && end != filename)
+    *end = '\0';
+
+  return filename;
+}
+
+
+gboolean
+photos_glib_make_directory_with_parents (GFile *file, GCancellable *cancellable, GError **error)
+{
+  GError *local_error = NULL;
+  gboolean ret_val;
+
+  ret_val = g_file_make_directory_with_parents (file, cancellable, &local_error);
+  if (local_error != NULL)
+    {
+      if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+        {
+          g_clear_error (&local_error);
+          ret_val = TRUE;
+        }
+    }
+
+  if (local_error != NULL)
+    g_propagate_error (error, local_error);
+
+  return ret_val;
+}
diff --git a/src/photos-glib.h b/src/photos-glib.h
new file mode 100644
index 0000000..afb85fa
--- /dev/null
+++ b/src/photos-glib.h
@@ -0,0 +1,53 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 – 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_GLIB_H
+#define PHOTOS_GLIB_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+gboolean              photos_glib_app_info_launch_uri            (GAppInfo *appinfo,
+                                                                  const gchar *uri,
+                                                                  GAppLaunchContext *launch_context,
+                                                                  GError **error);
+
+void                  photos_glib_file_create_async              (GFile *file,
+                                                                  GFileCreateFlags flags,
+                                                                  gint io_priority,
+                                                                  GCancellable *cancellable,
+                                                                  GAsyncReadyCallback callback,
+                                                                  gpointer user_data);
+
+GFileOutputStream    *photos_glib_file_create_finish             (GFile *file,
+                                                                  GAsyncResult *res,
+                                                                  GFile **out_unique_file,
+                                                                  GError **error);
+
+gchar                *photos_glib_filename_strip_extension       (const gchar *filename_with_extension);
+
+gboolean              photos_glib_make_directory_with_parents    (GFile *file,
+                                                                  GCancellable *cancellable,
+                                                                  GError **error);
+
+G_END_DECLS
+
+#endif /* PHOTOS_GLIB_H */
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index 0fbc860..9079155 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -32,6 +32,7 @@
 #include <glib/gi18n.h>
 
 #include "photos-error.h"
+#include "photos-glib.h"
 #include "photos-local-item.h"
 #include "photos-utils.h"
 
@@ -66,7 +67,7 @@ photos_local_item_create_name_fallback (PhotosBaseItem *item)
   gchar *ret_val;
 
   filename = photos_base_item_get_filename (item);
-  ret_val = photos_utils_filename_strip_extension (filename);
+  ret_val = photos_glib_filename_strip_extension (filename);
   return ret_val;
 }
 
diff --git a/src/photos-share-point-email.c b/src/photos-share-point-email.c
index 357299e..44ca848 100644
--- a/src/photos-share-point-email.c
+++ b/src/photos-share-point-email.c
@@ -28,6 +28,7 @@
 #include "photos-base-item.h"
 #include "photos-error.h"
 #include "photos-filterable.h"
+#include "photos-glib.h"
 #include "photos-share-point-email.h"
 #include "photos-utils.h"
 
@@ -107,7 +108,7 @@ photos_share_point_email_share_save (GObject *source_object, GAsyncResult *res,
   uri = g_strconcat ("mailto:?attach=";, escaped_path, NULL);
 
   error = NULL;
-  if (!photos_utils_app_info_launch_uri (self->default_app, uri, NULL, &error))
+  if (!photos_glib_app_info_launch_uri (self->default_app, uri, NULL, &error))
     {
       g_task_return_error (task, error);
       goto out;
diff --git a/src/photos-utils.c b/src/photos-utils.c
index db90ea3..c83b1cc 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -76,39 +76,6 @@
 
 static const gdouble EPSILON = 1e-5;
 
-typedef struct _PhotosUtilsFileCreateData PhotosUtilsFileCreateData;
-
-struct _PhotosUtilsFileCreateData
-{
-  GFile *dir;
-  GFileCreateFlags flags;
-  gchar *basename;
-  gchar *extension;
-  gint io_priority;
-  guint count;
-};
-
-
-gboolean
-photos_utils_app_info_launch_uri (GAppInfo *appinfo,
-                                  const gchar *uri,
-                                  GAppLaunchContext *launch_context,
-                                  GError **error)
-{
-  GList *uris = NULL;
-  gboolean ret_val;
-
-  g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
-  g_return_val_if_fail (uri != NULL && uri[0] != '\0', FALSE);
-  g_return_val_if_fail (launch_context == NULL || G_IS_APP_LAUNCH_CONTEXT (launch_context), FALSE);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  uris = g_list_prepend (uris, g_strdup (uri));
-  ret_val = g_app_info_launch_uris (appinfo, uris, launch_context, error);
-  g_list_free_full (uris, g_free);
-  return ret_val;
-}
-
 
 static void
 photos_utils_put_pixel (guchar *p)
@@ -821,215 +788,6 @@ photos_utils_get_controller (PhotosWindowMode mode,
 }
 
 
-static gchar *
-photos_utils_filename_get_extension_offset (const gchar *filename)
-{
-  gchar *end;
-  gchar *end2;
-
-  end = strrchr (filename, '.');
-
-  if (end != NULL && end != filename)
-    {
-      if (g_strcmp0 (end, ".gz") == 0
-          || g_strcmp0 (end, ".bz2") == 0
-          || g_strcmp0 (end, ".sit") == 0
-          || g_strcmp0 (end, ".Z") == 0)
-        {
-          end2 = end - 1;
-          while (end2 > filename && *end2 != '.')
-            end2--;
-          if (end2 != filename)
-            end = end2;
-        }
-  }
-
-  return end;
-}
-
-
-gchar *
-photos_utils_filename_strip_extension (const gchar *filename_with_extension)
-{
-  gchar *end;
-  gchar *filename;
-
-  if (filename_with_extension == NULL)
-    return NULL;
-
-  filename = g_strdup (filename_with_extension);
-  end = photos_utils_filename_get_extension_offset (filename);
-
-  if (end != NULL && end != filename)
-    *end = '\0';
-
-  return filename;
-}
-
-
-static void
-photos_utils_file_create_data_free (PhotosUtilsFileCreateData *data)
-{
-  g_object_unref (data->dir);
-  g_free (data->basename);
-  g_free (data->extension);
-  g_slice_free (PhotosUtilsFileCreateData, data);
-}
-
-
-static gchar *
-photos_utils_file_create_data_get_filename (PhotosUtilsFileCreateData *data)
-{
-  gchar *ret_val;
-
-  if (data->count > 0)
-    ret_val = g_strdup_printf ("%s(%u)%s", data->basename, data->count, data->extension);
-  else
-    ret_val = g_strdup_printf ("%s%s", data->basename, data->extension);
-
-  return ret_val;
-}
-
-
-static PhotosUtilsFileCreateData *
-photos_utils_file_create_data_new (GFile *file, GFileCreateFlags flags, gint io_priority)
-{
-  PhotosUtilsFileCreateData *data;
-  gchar *filename;
-
-  data = g_slice_new0 (PhotosUtilsFileCreateData);
-
-  filename = g_file_get_basename (file);
-  data->dir = g_file_get_parent (file);
-  data->basename = photos_utils_filename_strip_extension (filename);
-  data->extension = g_strdup (photos_utils_filename_get_extension_offset (filename));
-  data->count = 0;
-  data->flags = flags;
-  data->io_priority = io_priority;
-
-  g_free (filename);
-
-  return data;
-}
-
-
-static void
-photos_utils_file_create_create (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-  GCancellable *cancellable;
-  GError *error = NULL;
-  GFile *file = G_FILE (source_object);
-  GFile *unique_file = NULL;
-  GFileOutputStream *stream = NULL;
-  GTask *task = G_TASK (user_data);
-  PhotosUtilsFileCreateData *data;
-  gchar *filename = NULL;
-
-  cancellable = g_task_get_cancellable (task);
-  data = (PhotosUtilsFileCreateData *) g_task_get_task_data (task);
-
-  stream = g_file_create_finish (file, res, &error);
-  if (error != NULL)
-    {
-      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
-        {
-          g_task_return_error (task, error);
-          goto out;
-        }
-
-      if (data->count == G_MAXUINT)
-        {
-          g_task_return_new_error (task, PHOTOS_ERROR, 0, "Exceeded number of copies of a file");
-          goto out;
-        }
-
-      data->count++;
-
-      filename = photos_utils_file_create_data_get_filename (data);
-      unique_file = g_file_get_child (data->dir, filename);
-
-      g_file_create_async (unique_file,
-                           data->flags,
-                           data->io_priority,
-                           cancellable,
-                           photos_utils_file_create_create,
-                           g_object_ref (task));
-
-      goto out;
-    }
-
-  g_task_return_pointer (task, g_object_ref (stream), g_object_unref);
-
- out:
-  g_free (filename);
-  g_clear_object (&stream);
-  g_clear_object (&unique_file);
-  g_object_unref (task);
-}
-
-
-void
-photos_utils_file_create_async (GFile *file,
-                                GFileCreateFlags flags,
-                                gint io_priority,
-                                GCancellable *cancellable,
-                                GAsyncReadyCallback callback,
-                                gpointer user_data)
-{
-  GTask *task;
-  PhotosUtilsFileCreateData *data;
-
-  task = g_task_new (file, cancellable, callback, user_data);
-  g_task_set_source_tag (task, photos_utils_file_create_async);
-
-  data = photos_utils_file_create_data_new (file, flags, io_priority);
-  g_task_set_task_data (task, data, (GDestroyNotify) photos_utils_file_create_data_free);
-
-  g_file_create_async (file,
-                       data->flags,
-                       data->io_priority,
-                       cancellable,
-                       photos_utils_file_create_create,
-                       g_object_ref (task));
-
-  g_object_unref (task);
-}
-
-
-GFileOutputStream *
-photos_utils_file_create_finish (GFile *file, GAsyncResult *res, GFile **out_unique_file, GError **error)
-{
-  GTask *task = G_TASK (res);
-  GFileOutputStream *ret_val = NULL;
-  PhotosUtilsFileCreateData *data;
-
-  g_return_val_if_fail (g_task_is_valid (res, file), NULL);
-  g_return_val_if_fail (g_task_get_source_tag (task) == photos_utils_file_create_async, NULL);
-  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
-  data = (PhotosUtilsFileCreateData *) g_task_get_task_data (task);
-  g_return_val_if_fail (data != NULL, NULL);
-
-  ret_val = g_task_propagate_pointer (task, error);
-  if (ret_val == NULL)
-    goto out;
-
-  if (out_unique_file != NULL)
-    {
-      GFile *unique_file;
-      gchar *filename = NULL;
-
-      filename = photos_utils_file_create_data_get_filename (data);
-      unique_file = g_file_get_child (data->dir, filename);
-      *out_unique_file = unique_file;
-      g_free (filename);
-    }
-
- out:
-  return ret_val;
-}
-
-
 GQuark
 photos_utils_flash_off_quark (void)
 {
@@ -1217,29 +975,6 @@ photos_utils_list_box_header_func (GtkListBoxRow *row, GtkListBoxRow *before, gp
 }
 
 
-gboolean
-photos_utils_make_directory_with_parents (GFile *file, GCancellable *cancellable, GError **error)
-{
-  GError *local_error = NULL;
-  gboolean ret_val;
-
-  ret_val = g_file_make_directory_with_parents (file, cancellable, &local_error);
-  if (local_error != NULL)
-    {
-      if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
-        {
-          g_clear_error (&local_error);
-          ret_val = TRUE;
-        }
-    }
-
-  if (local_error != NULL)
-    g_propagate_error (error, local_error);
-
-  return ret_val;
-}
-
-
 void
 photos_utils_object_list_free_full (GList *objects)
 {
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 53923d9..ed7dc78 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -60,11 +60,6 @@ G_BEGIN_DECLS
   "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#image-category-screenshot";
 #define PHOTOS_EXPORT_SUBPATH "Exports"
 
-gboolean         photos_utils_app_info_launch_uri         (GAppInfo *appinfo,
-                                                           const gchar *uri,
-                                                           GAppLaunchContext *launch_context,
-                                                           GError **error);
-
 void             photos_utils_border_pixbuf               (GdkPixbuf *pixbuf);
 
 GdkPixbuf       *photos_utils_center_pixbuf               (GdkPixbuf *pixbuf, gint size);
@@ -113,20 +108,6 @@ gdouble          photos_utils_eval_radial_line            (gdouble crop_center_x
                                                            gdouble corner_y,
                                                            gdouble event_x);
 
-void             photos_utils_file_create_async           (GFile *file,
-                                                           GFileCreateFlags flags,
-                                                           gint io_priority,
-                                                           GCancellable *cancellable,
-                                                           GAsyncReadyCallback callback,
-                                                           gpointer user_data);
-
-GFileOutputStream *photos_utils_file_create_finish        (GFile *file,
-                                                           GAsyncResult *res,
-                                                           GFile **out_unique_file,
-                                                           GError **error);
-
-gchar           *photos_utils_filename_strip_extension    (const gchar *filename_with_extension);
-
 GQuark           photos_utils_flash_off_quark             (void);
 
 GQuark           photos_utils_flash_on_quark              (void);
@@ -156,8 +137,6 @@ void             photos_utils_list_box_header_func        (GtkListBoxRow *row,
                                                            GtkListBoxRow *before,
                                                            gpointer user_data);
 
-gboolean         photos_utils_make_directory_with_parents (GFile *file, GCancellable *cancellable, GError 
**error);
-
 void             photos_utils_object_list_free_full       (GList *objects);
 
 GQuark           photos_utils_orientation_bottom_quark    (void);


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