[gnome-photos/wip/rishi/collection] Add a new mode for importing items from an attached device



commit 84381375f513f50c8ee84012b661f1a2b3bcf83c
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 16 20:43:35 2018 +0100

    Add a new mode for importing items from an attached device
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751212

 src/photos-application.c       | 34 +++++++++++++++++++---------------
 src/photos-embed.c             | 25 +++++++++++++++++++++++++
 src/photos-empty-results-box.c |  2 ++
 src/photos-item-manager.c      |  9 +++++++++
 src/photos-item-manager.h      |  1 +
 src/photos-utils.c             |  8 ++++++++
 6 files changed, 64 insertions(+), 15 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index b87e9c87..97396639 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -328,12 +328,14 @@ photos_application_actions_update (PhotosApplication *self)
   PhotosBaseItem *item;
   GList *l;
   GList *selection;
+  PhotosBaseManager *item_mngr_chld;
   PhotosLoadState load_state;
   PhotosWindowMode mode;
   gboolean can_open;
   gboolean can_trash;
   gboolean enable;
   gboolean selection_mode;
+  guint n_items;
 
   item = photos_application_get_selection_or_active_item (self);
   load_state = photos_item_manager_get_load_state (self->state->item_mngr);
@@ -341,6 +343,9 @@ photos_application_actions_update (PhotosApplication *self)
   selection = photos_selection_controller_get_selection (self->sel_cntrlr);
   selection_mode = photos_utils_get_selection_mode ();
 
+  item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), mode);
+  n_items = g_list_model_get_n_items (G_LIST_MODEL (item_mngr_chld));
+
   g_simple_action_set_enabled (self->zoom_best_fit_action, FALSE);
   g_simple_action_set_enabled (self->zoom_end_action, FALSE);
   g_simple_action_set_enabled (self->zoom_out_action, FALSE);
@@ -357,25 +362,24 @@ photos_application_actions_update (PhotosApplication *self)
   g_simple_action_set_enabled (self->shadows_highlights_action, enable);
   g_simple_action_set_enabled (self->sharpen_action, enable);
 
-  enable = FALSE;
-  if (mode == PHOTOS_WINDOW_MODE_COLLECTION_VIEW
-      || mode == PHOTOS_WINDOW_MODE_COLLECTIONS
-      || mode == PHOTOS_WINDOW_MODE_FAVORITES
-      || mode == PHOTOS_WINDOW_MODE_OVERVIEW
-      || mode == PHOTOS_WINDOW_MODE_SEARCH)
-    {
-      PhotosBaseManager *item_mngr_chld;
-      guint n_items;
-
-      item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), mode);
-      n_items = g_list_model_get_n_items (G_LIST_MODEL (item_mngr_chld));
-      enable = n_items > 0;
-    }
-
+  enable = ((mode == PHOTOS_WINDOW_MODE_COLLECTION_VIEW
+             || mode == PHOTOS_WINDOW_MODE_COLLECTIONS
+             || mode == PHOTOS_WINDOW_MODE_FAVORITES
+             || mode == PHOTOS_WINDOW_MODE_OVERVIEW
+             || mode == PHOTOS_WINDOW_MODE_SEARCH)
+            && n_items > 0);
   g_simple_action_set_enabled (self->search_action, enable);
   g_simple_action_set_enabled (self->search_match_action, enable);
   g_simple_action_set_enabled (self->search_source_action, enable);
   g_simple_action_set_enabled (self->search_type_action, enable);
+
+  enable = ((mode == PHOTOS_WINDOW_MODE_COLLECTION_VIEW
+             || mode == PHOTOS_WINDOW_MODE_COLLECTIONS
+             || mode == PHOTOS_WINDOW_MODE_FAVORITES
+             || mode == PHOTOS_WINDOW_MODE_IMPORT
+             || mode == PHOTOS_WINDOW_MODE_OVERVIEW
+             || mode == PHOTOS_WINDOW_MODE_SEARCH)
+            && n_items > 0);
   g_simple_action_set_enabled (self->sel_all_action, enable);
   g_simple_action_set_enabled (self->sel_none_action, enable);
   g_simple_action_set_enabled (self->selection_mode_action, enable);
diff --git a/src/photos-embed.c b/src/photos-embed.c
index f2ac01be..ff4824e1 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -73,6 +73,7 @@ struct _PhotosEmbed
   GtkWidget *collection_view;
   GtkWidget *collections;
   GtkWidget *favorites;
+  GtkWidget *import;
   GtkWidget *no_results;
   GtkWidget *ntfctn_mngr;
   GtkWidget *overview;
@@ -160,6 +161,10 @@ photos_embed_get_view_container_from_mode (PhotosEmbed *self, PhotosWindowMode m
       view_container = self->favorites;
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      view_container = self->import;
+      break;
+
     case PHOTOS_WINDOW_MODE_OVERVIEW:
       view_container = self->overview;
       break;
@@ -415,6 +420,7 @@ photos_embed_prepare_for_collection_view (PhotosEmbed *self, PhotosWindowMode ol
     case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
     case PHOTOS_WINDOW_MODE_EDIT:
     case PHOTOS_WINDOW_MODE_FAVORITES:
+    case PHOTOS_WINDOW_MODE_IMPORT:
     case PHOTOS_WINDOW_MODE_OVERVIEW:
     default:
       g_assert_not_reached ();
@@ -448,6 +454,17 @@ photos_embed_prepare_for_favorites (PhotosEmbed *self, PhotosWindowMode old_mode
 }
 
 
+static void
+photos_embed_prepare_for_import (PhotosEmbed *self, PhotosWindowMode old_mode)
+{
+  if (old_mode == PHOTOS_WINDOW_MODE_PREVIEW)
+    photos_embed_tracker_controllers_set_frozen (self, FALSE);
+
+  photos_spinner_box_stop (PHOTOS_SPINNER_BOX (self->spinner_box));
+  gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "import");
+}
+
+
 static void
 photos_embed_prepare_for_overview (PhotosEmbed *self, PhotosWindowMode old_mode)
 {
@@ -631,6 +648,7 @@ photos_embed_window_mode_changed (PhotosModeController *mode_cntrlr,
 
     case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
     case PHOTOS_WINDOW_MODE_EDIT:
+    case PHOTOS_WINDOW_MODE_IMPORT:
     case PHOTOS_WINDOW_MODE_PREVIEW:
     case PHOTOS_WINDOW_MODE_SEARCH:
       break;
@@ -660,6 +678,10 @@ photos_embed_window_mode_changed (PhotosModeController *mode_cntrlr,
       photos_embed_prepare_for_favorites (self, old_mode);
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      photos_embed_prepare_for_import (self, old_mode);
+      break;
+
     case PHOTOS_WINDOW_MODE_OVERVIEW:
       photos_embed_prepare_for_overview (self, old_mode);
       break;
@@ -751,6 +773,9 @@ photos_embed_init (PhotosEmbed *self)
   name = photos_view_container_get_name (PHOTOS_VIEW_CONTAINER (self->favorites));
   gtk_stack_add_titled (GTK_STACK (self->stack), self->favorites, "favorites", name);
 
+  self->import = photos_view_container_new (PHOTOS_WINDOW_MODE_IMPORT, _("Import"));
+  gtk_stack_add_named (GTK_STACK (self->stack), self->import, "import");
+
   self->search = photos_view_container_new (PHOTOS_WINDOW_MODE_SEARCH, _("Search"));
   gtk_stack_add_named (GTK_STACK (self->stack), self->search, "search");
 
diff --git a/src/photos-empty-results-box.c b/src/photos-empty-results-box.c
index 99656b74..8d1cf4e5 100644
--- a/src/photos-empty-results-box.c
+++ b/src/photos-empty-results-box.c
@@ -197,6 +197,7 @@ photos_empty_results_box_constructed (GObject *object)
 
     case PHOTOS_WINDOW_MODE_NONE:
     case PHOTOS_WINDOW_MODE_EDIT:
+    case PHOTOS_WINDOW_MODE_IMPORT:
     case PHOTOS_WINDOW_MODE_PREVIEW:
     default:
       g_assert_not_reached ();
@@ -245,6 +246,7 @@ photos_empty_results_box_constructed (GObject *object)
 
     case PHOTOS_WINDOW_MODE_NONE:
     case PHOTOS_WINDOW_MODE_EDIT:
+    case PHOTOS_WINDOW_MODE_IMPORT:
     case PHOTOS_WINDOW_MODE_PREVIEW:
     default:
       g_assert_not_reached ();
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 9ed0e10a..dcf86ab1 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -1359,6 +1359,10 @@ photos_mode_controller_go_back (PhotosModeController *self)
       g_return_if_fail (old_mode != PHOTOS_WINDOW_MODE_PREVIEW);
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      g_return_if_fail (old_mode == PHOTOS_WINDOW_MODE_COLLECTIONS || old_mode == 
PHOTOS_WINDOW_MODE_OVERVIEW);
+      break;
+
     case PHOTOS_WINDOW_MODE_PREVIEW:
       g_return_if_fail (PHOTOS_IS_BASE_ITEM (self->active_object));
       g_return_if_fail (self->active_object != (GObject *) self->active_collection);
@@ -1393,6 +1397,7 @@ photos_mode_controller_go_back (PhotosModeController *self)
       break;
 
     case PHOTOS_WINDOW_MODE_EDIT:
+    case PHOTOS_WINDOW_MODE_IMPORT:
       break;
 
     case PHOTOS_WINDOW_MODE_PREVIEW:
@@ -1470,6 +1475,10 @@ photos_mode_controller_set_window_mode (PhotosModeController *self, PhotosWindow
       g_return_if_fail (self->load_state == PHOTOS_LOAD_STATE_FINISHED);
       g_return_if_fail (self->mode == PHOTOS_WINDOW_MODE_PREVIEW);
     }
+  else if (mode == PHOTOS_WINDOW_MODE_IMPORT)
+    {
+      g_return_if_fail (self->mode == PHOTOS_WINDOW_MODE_COLLECTIONS || self->mode == 
PHOTOS_WINDOW_MODE_OVERVIEW);
+    }
   else
     {
       g_return_if_fail (self->mode != PHOTOS_WINDOW_MODE_PREVIEW);
diff --git a/src/photos-item-manager.h b/src/photos-item-manager.h
index 22fa3426..8383cc87 100644
--- a/src/photos-item-manager.h
+++ b/src/photos-item-manager.h
@@ -62,6 +62,7 @@ typedef enum
   PHOTOS_WINDOW_MODE_COLLECTIONS,
   PHOTOS_WINDOW_MODE_EDIT,
   PHOTOS_WINDOW_MODE_FAVORITES,
+  PHOTOS_WINDOW_MODE_IMPORT,
   PHOTOS_WINDOW_MODE_OVERVIEW,
   PHOTOS_WINDOW_MODE_PREVIEW,
   PHOTOS_WINDOW_MODE_SEARCH
diff --git a/src/photos-utils.c b/src/photos-utils.c
index e4609bec..d581a458 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -46,6 +46,7 @@
 #include "photos-offset-collection-view-controller.h"
 #include "photos-offset-collections-controller.h"
 #include "photos-offset-favorites-controller.h"
+#include "photos-offset-import-controller.h"
 #include "photos-offset-overview-controller.h"
 #include "photos-offset-search-controller.h"
 #include "photos-query.h"
@@ -63,6 +64,7 @@
 #include "photos-tracker-collection-view-controller.h"
 #include "photos-tracker-collections-controller.h"
 #include "photos-tracker-favorites-controller.h"
+#include "photos-tracker-import-controller.h"
 #include "photos-tracker-overview-controller.h"
 #include "photos-tracker-queue.h"
 #include "photos-tracker-search-controller.h"
@@ -722,6 +724,7 @@ photos_utils_ensure_builtins (void)
       g_type_ensure (PHOTOS_TYPE_TRACKER_COLLECTION_VIEW_CONTROLLER);
       g_type_ensure (PHOTOS_TYPE_TRACKER_COLLECTIONS_CONTROLLER);
       g_type_ensure (PHOTOS_TYPE_TRACKER_FAVORITES_CONTROLLER);
+      g_type_ensure (PHOTOS_TYPE_TRACKER_IMPORT_CONTROLLER);
       g_type_ensure (PHOTOS_TYPE_TRACKER_OVERVIEW_CONTROLLER);
       g_type_ensure (PHOTOS_TYPE_TRACKER_SEARCH_CONTROLLER);
 
@@ -1018,6 +1021,11 @@ photos_utils_get_controller (PhotosWindowMode mode,
       trk_cntrlr = photos_tracker_favorites_controller_dup_singleton ();
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      offset_cntrlr = photos_offset_import_controller_dup_singleton ();
+      trk_cntrlr = photos_tracker_import_controller_dup_singleton ();
+      break;
+
     case PHOTOS_WINDOW_MODE_OVERVIEW:
       offset_cntrlr = photos_offset_overview_controller_dup_singleton ();
       trk_cntrlr = photos_tracker_overview_controller_dup_singleton ();


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