[gnome-photos] selection-toolbar: Exit the mode when an action has been performed



commit e4d88a8bebef70fde30ba60c925126c87b5ad963
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Aug 7 02:22:36 2013 +0200

    selection-toolbar: Exit the mode when an action has been performed
    
    If the action opens a modal dialog then we only exit the mode when the
    "response" from the dialog has been positive
    
    Fixes: https://bugzilla.gnome.org/699914

 src/photos-base-item.c         |   19 +++++++++++++++++++
 src/photos-selection-toolbar.c |   12 ++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 95b1ec8..1c8e842 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -36,6 +36,7 @@
 #include "photos-delete-item-job.h"
 #include "photos-print-operation.h"
 #include "photos-query.h"
+#include "photos-selection-controller.h"
 #include "photos-single-item-job.h"
 #include "photos-utils.h"
 
@@ -51,6 +52,7 @@ struct _PhotosBaseItemPrivate
   GMutex mutex_download;
   GMutex mutex;
   PhotosCollectionIconWatcher *watcher;
+  PhotosSelectionController *sel_cntrlr;
   TrackerSparqlCursor *cursor;
   gboolean collection;
   gboolean failed_thumbnailing;
@@ -734,6 +736,14 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
 
 
 static void
+photos_base_item_print_operation_done (PhotosBaseItem *self, GtkPrintOperationResult result)
+{
+  if (result == GTK_PRINT_OPERATION_RESULT_APPLY)
+      photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, FALSE);
+}
+
+
+static void
 photos_base_item_print_load (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   PhotosBaseItem *self = PHOTOS_BASE_ITEM (source_object);
@@ -746,6 +756,12 @@ photos_base_item_print_load (GObject *source_object, GAsyncResult *res, gpointer
     goto out;
 
   print_op = photos_print_operation_new (self, node);
+  g_signal_connect_data (print_op,
+                         "done",
+                         G_CALLBACK (photos_base_item_print_operation_done),
+                         g_object_ref (self),
+                         (GClosureNotify) g_object_unref,
+                         G_CONNECT_SWAPPED);
   gtk_print_operation_run (print_op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, toplevel, NULL);
 
  out:
@@ -789,6 +805,7 @@ photos_base_item_dispose (GObject *object)
   g_clear_object (&priv->icon);
   g_clear_object (&priv->pristine_icon);
   g_clear_object (&priv->watcher);
+  g_clear_object (&priv->sel_cntrlr);
   g_clear_object (&priv->cursor);
 
   G_OBJECT_CLASS (photos_base_item_parent_class)->dispose (object);
@@ -872,6 +889,8 @@ photos_base_item_init (PhotosBaseItem *self)
   g_mutex_init (&priv->mutex_create_thumbnail);
   g_mutex_init (&priv->mutex_download);
   g_mutex_init (&priv->mutex);
+
+  priv->sel_cntrlr = photos_selection_controller_new ();
 }
 
 
diff --git a/src/photos-selection-toolbar.c b/src/photos-selection-toolbar.c
index a259a7f..e782bc3 100644
--- a/src/photos-selection-toolbar.c
+++ b/src/photos-selection-toolbar.c
@@ -71,7 +71,7 @@ photos_selection_toolbar_dialog_response (GtkDialog *dialog, gint response_id, g
     return;
 
   gtk_widget_destroy (GTK_WIDGET (dialog));
-  gtk_revealer_set_reveal_child (GTK_REVEALER (self), TRUE);
+  photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, FALSE);
 }
 
 
@@ -88,7 +88,6 @@ photos_selection_toolbar_collection_clicked (GtkButton *button, gpointer user_da
 
   dialog = photos_organize_collection_dialog_new (GTK_WINDOW (toplevel));
   gtk_widget_show_all (dialog);
-  gtk_revealer_set_reveal_child (GTK_REVEALER (self), FALSE);
   g_signal_connect (dialog, "response", G_CALLBACK (photos_selection_toolbar_dialog_response), self);
 }
 
@@ -123,6 +122,8 @@ photos_selection_toolbar_favorite_clicked (GtkButton *button, gpointer user_data
       favorite = photos_base_item_is_favorite (item);
       photos_base_item_set_favorite (item, !favorite);
     }
+
+  photos_selection_controller_set_selection_mode (priv->sel_cntrlr, FALSE);
 }
 
 
@@ -147,6 +148,8 @@ photos_selection_toolbar_open_clicked (GtkButton *button, gpointer user_data)
       time = gtk_get_current_event_time ();
       photos_base_item_open (item, screen, time);
     }
+
+  photos_selection_controller_set_selection_mode (priv->sel_cntrlr, FALSE);
 }
 
 
@@ -177,7 +180,7 @@ photos_selection_toolbar_properties_response (GtkDialog *dialog, gint response_i
   PhotosSelectionToolbar *self = PHOTOS_SELECTION_TOOLBAR (user_data);
 
   gtk_widget_destroy (GTK_WIDGET (dialog));
-  gtk_revealer_set_reveal_child (GTK_REVEALER (self), TRUE);
+  photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, FALSE);
 }
 
 
@@ -200,7 +203,6 @@ photos_selection_toolbar_properties_clicked (GtkButton *button, gpointer user_da
 
   dialog = photos_properties_dialog_new (GTK_WINDOW (windows->data), urn);
   gtk_widget_show_all (dialog);
-  gtk_revealer_set_reveal_child (GTK_REVEALER (self), FALSE);
 
   g_object_unref (app);
 
@@ -385,6 +387,8 @@ photos_selection_toolbar_trash_clicked (GtkButton *button, gpointer user_data)
       item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, urn));
       photos_base_item_trash (item);
     }
+
+  photos_selection_controller_set_selection_mode (priv->sel_cntrlr, FALSE);
 }
 
 


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