[gnome-photos] application, preview-view: Move the "edit-done" implementation



commit 554856ac6e6e956fa04e9fa0b431cc2389ff9bd7
Author: Umang Jain <mailumangjain gmail com>
Date:   Wed Feb 3 10:17:36 2016 +0530

    application, preview-view: Move the "edit-done" implementation
    
    In the following patch, we want to ensure that the current tool is
    deactivated before we leave the edit mode. Otherwise, tools like
    ToolCrop won't get a chance to apply their changes.
    
    To do this we need to access objects that are local to PreviewView and
    are not visible to the Application. Therefore, we need to move the
    implementation of the "edit-done" GAction to a more suitable spot.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760931

 src/photos-application.c  |   40 --------------------------------------
 src/photos-preview-view.c |   47 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 40 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index bf0f7b8..b622a47 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -704,42 +704,6 @@ photos_application_edit_cancel (PhotosApplication *self)
 
 
 static void
-photos_application_edit_done_pipeline_save (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-  PhotosApplication *self = PHOTOS_APPLICATION (user_data);
-  PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
-  GError *error;
-
-  error = NULL;
-  if (!photos_base_item_pipeline_save_finish (item, res, &error))
-    {
-      g_warning ("Unable to save pipeline: %s", error->message);
-      g_error_free (error);
-      goto out;
-    }
-
-  photos_mode_controller_go_back (self->priv->state->mode_cntrlr);
-
- out:
-  g_application_release (G_APPLICATION (self));
-}
-
-
-static void
-photos_application_edit_done (PhotosApplication *self)
-{
-  PhotosApplicationPrivate *priv = self->priv;
-  PhotosBaseItem *item;
-
-  item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (priv->state->item_mngr));
-  g_return_if_fail (item != NULL);
-
-  g_application_hold (G_APPLICATION (self));
-  photos_base_item_pipeline_save_async (item, NULL, photos_application_edit_done_pipeline_save, self);
-}
-
-
-static void
 photos_application_edit_current (PhotosApplication *self)
 {
   PhotosApplicationPrivate *priv = self->priv;
@@ -1428,10 +1392,6 @@ photos_application_startup (GApplication *application)
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->edit_action));
 
   priv->edit_done_action = g_simple_action_new ("edit-done", NULL);
-  g_signal_connect_swapped (priv->edit_done_action,
-                            "activate",
-                            G_CALLBACK (photos_application_edit_done),
-                            self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->edit_done_action));
 
   priv->fs_action = g_simple_action_new ("fullscreen", NULL);
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 8caa74b..6a50b41 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -478,6 +478,50 @@ photos_preview_view_undo (PhotosPreviewView *self)
 
 
 static void
+photos_preview_view_edit_done_pipeline_save (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+  PhotosPreviewView *self = PHOTOS_PREVIEW_VIEW (user_data);
+  PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
+  GApplication *app;
+  GError *error;
+
+  error = NULL;
+  if (!photos_base_item_pipeline_save_finish (item, res, &error))
+    {
+      g_warning ("Unable to save pipeline: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  photos_mode_controller_go_back (self->mode_cntrlr);
+
+ out:
+  app = g_application_get_default ();
+  g_application_release (G_APPLICATION (app));
+  g_object_unref (self);
+}
+
+
+static void
+photos_preview_view_edit_done (PhotosPreviewView *self)
+{
+  PhotosBaseItem *item;
+  GApplication *app;
+
+  item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->item_mngr));
+  g_return_if_fail (item != NULL);
+
+  app = g_application_get_default ();
+  g_application_hold (app);
+
+  photos_base_item_pipeline_save_async (item,
+                                        NULL,
+                                        photos_preview_view_edit_done_pipeline_save,
+                                        g_object_ref (self));
+}
+
+
+static void
 photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMode mode, PhotosWindowMode 
old_mode)
 {
   switch (mode)
@@ -634,6 +678,9 @@ photos_preview_view_init (PhotosPreviewView *self)
   action = g_action_map_lookup_action (G_ACTION_MAP (app), "denoise-current");
   g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_denoise), self, 
G_CONNECT_SWAPPED);
 
+  action = g_action_map_lookup_action (G_ACTION_MAP (app), "edit-done");
+  g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_edit_done), self, 
G_CONNECT_SWAPPED);
+
   action = g_action_map_lookup_action (G_ACTION_MAP (app), "insta-current");
   g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_insta), self, 
G_CONNECT_SWAPPED);
 


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