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



commit 3e78187ab0f1352473fbb6f5da53022f2976e733
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      | 63 +++++++++++++++++++++++++++++++--
 src/photos-item-manager.h      |  1 +
 src/photos-main-toolbar.c      | 79 ++++++++++++++++++++++++++++++++++++------
 src/photos-main-window.c       |  2 ++
 src/photos-preview-view.c      |  4 +++
 src/photos-utils.c             |  8 +++++
 src/photos-view-container.c    |  4 +++
 10 files changed, 194 insertions(+), 28 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 3bbcc58c..1df0ef71 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..02e7215c 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -49,6 +49,7 @@
 struct _PhotosItemManager
 {
   PhotosBaseManager parent_instance;
+  GAction *selection_mode_action;
   GObject *active_object;
   GCancellable *loader_cancellable;
   GHashTable *collections;
@@ -693,6 +694,7 @@ photos_item_manager_set_active_object (PhotosBaseManager *manager, GObject *obje
 
   g_return_val_if_fail (object != NULL, FALSE);
   g_return_val_if_fail (PHOTOS_IS_BASE_ITEM (object), FALSE);
+  g_return_val_if_fail (self->mode == PHOTOS_WINDOW_MODE_IMPORT, FALSE);
 
   is_collection = photos_base_item_is_collection (PHOTOS_BASE_ITEM (object));
   if (is_collection)
@@ -832,11 +834,15 @@ photos_item_manager_finalize (GObject *object)
 static void
 photos_item_manager_init (PhotosItemManager *self)
 {
+  GApplication *app;
   GEnumClass *window_mode_class;
   guint i;
 
   EGG_COUNTER_INC (instances);
 
+  app = g_application_get_default ();
+  self->selection_mode_action = g_action_map_lookup_action (G_ACTION_MAP (app), "selection-mode");
+
   self->collections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
   self->hidden_items = g_hash_table_new_full (g_str_hash,
                                               g_str_equal,
@@ -1323,6 +1329,7 @@ photos_mode_controller_go_back (PhotosModeController *self)
   PhotosWindowMode tmp;
   gboolean active_changed = FALSE;
   gboolean active_collection_changed = FALSE;
+  gboolean unset_selection_mode = FALSE;
 
   g_return_if_fail (PHOTOS_IS_MODE_CONTROLLER (self));
   g_return_if_fail (!g_queue_is_empty (self->history));
@@ -1359,6 +1366,18 @@ photos_mode_controller_go_back (PhotosModeController *self)
       g_return_if_fail (old_mode != PHOTOS_WINDOW_MODE_PREVIEW);
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      {
+        g_autoptr (GVariant) state = NULL;
+
+        g_return_if_fail (old_mode == PHOTOS_WINDOW_MODE_COLLECTIONS || old_mode == 
PHOTOS_WINDOW_MODE_OVERVIEW);
+
+        state = g_action_get_state (self->selection_mode_action);
+        g_return_if_fail (state != NULL);
+        g_return_if_fail (g_variant_get_boolean (state));
+        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);
@@ -1395,6 +1414,10 @@ photos_mode_controller_go_back (PhotosModeController *self)
     case PHOTOS_WINDOW_MODE_EDIT:
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      unset_selection_mode = TRUE;
+      break;
+
     case PHOTOS_WINDOW_MODE_PREVIEW:
       self->load_state = PHOTOS_LOAD_STATE_NONE;
       g_set_object (&self->active_object, G_OBJECT (self->active_collection));
@@ -1423,6 +1446,14 @@ photos_mode_controller_go_back (PhotosModeController *self)
       break;
     }
 
+  if (unset_selection_mode)
+    {
+      GVariant *state;
+
+      state = g_variant_new_boolean (FALSE);
+      g_action_change_state (self->selection_mode_action, state);
+    }
+
   if (active_changed)
     g_signal_emit_by_name (self, "active-changed", self->active_object);
 
@@ -1458,7 +1489,9 @@ void
 photos_mode_controller_set_window_mode (PhotosModeController *self, PhotosWindowMode mode)
 {
   PhotosWindowMode old_mode;
+  gboolean active_changed = FALSE;
   gboolean active_collection_changed = FALSE;
+  gboolean set_selection_mode = FALSE;
 
   g_return_if_fail (PHOTOS_IS_MODE_CONTROLLER (self));
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_NONE);
@@ -1470,6 +1503,16 @@ 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_autoptr (GVariant) state = NULL;
+
+      g_return_if_fail (self->mode == PHOTOS_WINDOW_MODE_COLLECTIONS || self->mode == 
PHOTOS_WINDOW_MODE_OVERVIEW);
+
+      state = g_action_get_state (self->selection_mode_action);
+      g_return_if_fail (state != NULL);
+      g_return_if_fail (!g_variant_get_boolean (state));
+    }
   else
     {
       g_return_if_fail (self->mode != PHOTOS_WINDOW_MODE_PREVIEW);
@@ -1492,11 +1535,25 @@ photos_mode_controller_set_window_mode (PhotosModeController *self, PhotosWindow
         }
 
       g_clear_object (&self->active_object);
-      g_signal_emit_by_name (self, "active-changed", self->active_object);
+      active_changed = TRUE;
+    }
+
+  if (mode == PHOTOS_WINDOW_MODE_IMPORT)
+    set_selection_mode = TRUE;
+
+  if (set_selection_mode)
+    {
+      GVariant *state;
 
-      if (active_collection_changed)
-        g_signal_emit (self, signals[ACTIVE_COLLECTION_CHANGED], 0, self->active_collection);
+      state = g_variant_new_boolean (TRUE);
+      g_action_change_state (self->selection_mode_action, state);
     }
 
+  if (active_changed)
+    g_signal_emit_by_name (self, "active-changed", self->active_object);
+
+  if (active_collection_changed)
+    g_signal_emit (self, signals[ACTIVE_COLLECTION_CHANGED], 0, self->active_collection);
+
   g_signal_emit (self, signals[WINDOW_MODE_CHANGED], 0, mode, old_mode);
 }
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-main-toolbar.c b/src/photos-main-toolbar.c
index 769d647b..08906f78 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -30,6 +30,7 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
+#include "photos-base-manager.h"
 #include "photos-dlna-renderers-manager.h"
 #include "photos-dropdown.h"
 #include "photos-icons.h"
@@ -55,6 +56,7 @@ struct _PhotosMainToolbar
   GtkWidget *selection_menu;
   GtkWidget *stack_switcher;
   PhotosBaseManager *item_mngr;
+  PhotosBaseManager *src_mngr;
   PhotosModeController *mode_cntrlr;
   PhotosRemoteDisplayManager *remote_mngr;
   PhotosSelectionController *sel_cntrlr;
@@ -68,7 +70,9 @@ static void photos_main_toolbar_favorite_button_update (PhotosMainToolbar *self,
 
 
 static gchar *
-photos_main_toolbar_create_selection_mode_label (PhotosMainToolbar *self, PhotosBaseItem *active_collection)
+photos_main_toolbar_create_selection_mode_label (PhotosMainToolbar *self,
+                                                 PhotosBaseItem *active_collection,
+                                                 PhotosSource *source)
 {
   GList *selection;
   g_autofree gchar *label = NULL;
@@ -83,9 +87,20 @@ photos_main_toolbar_create_selection_mode_label (PhotosMainToolbar *self, Photos
     label = g_strdup_printf (ngettext ("%d selected", "%d selected", length), length);
 
   if (active_collection != NULL)
-    ret_val = g_markup_printf_escaped ("<b>%s</b> (%s)", photos_base_item_get_name (active_collection), 
label);
+    {
+      ret_val = g_markup_printf_escaped ("<b>%s</b> (%s)", photos_base_item_get_name (active_collection), 
label);
+    }
+  else if (source != NULL)
+    {
+      const gchar *name;
+
+      name = photos_source_get_name (source);
+      ret_val = g_markup_printf_escaped ("<b>%s</b> (%s)", name, label);
+    }
   else
-    ret_val = g_steal_pointer (&label);
+    {
+      ret_val = g_steal_pointer (&label);
+    }
 
   return ret_val;
 }
@@ -95,6 +110,7 @@ static void
 photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
 {
   PhotosBaseItem *active_collection;
+  PhotosSource *source;
   PhotosWindowMode window_mode;
   gboolean selection_mode;
   g_autofree gchar *primary = NULL;
@@ -107,6 +123,7 @@ photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
       g_return_if_fail (window_mode == PHOTOS_WINDOW_MODE_COLLECTION_VIEW
                         || window_mode == PHOTOS_WINDOW_MODE_COLLECTIONS
                         || window_mode == PHOTOS_WINDOW_MODE_FAVORITES
+                        || window_mode == PHOTOS_WINDOW_MODE_IMPORT
                         || window_mode == PHOTOS_WINDOW_MODE_OVERVIEW
                         || window_mode == PHOTOS_WINDOW_MODE_SEARCH);
     }
@@ -115,12 +132,24 @@ photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
     g_return_if_fail (!selection_mode);
 
   active_collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (self->item_mngr));
+  source = PHOTOS_SOURCE (photos_base_manager_get_active_object (self->src_mngr));
+
+  if (window_mode == PHOTOS_WINDOW_MODE_IMPORT)
+    {
+      GMount *mount;
+
+      g_return_if_fail (active_collection == NULL);
+      g_return_if_fail (PHOTOS_IS_SOURCE (source));
+
+      mount = photos_source_get_mount (source);
+      g_return_if_fail (G_IS_MOUNT (mount));
+    }
 
   switch (window_mode)
     {
     case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
       if (selection_mode)
-        primary = photos_main_toolbar_create_selection_mode_label (self, active_collection);
+        primary = photos_main_toolbar_create_selection_mode_label (self, active_collection, NULL);
       else
         primary = g_strdup (photos_base_item_get_name (active_collection));
       break;
@@ -130,7 +159,7 @@ photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
     case PHOTOS_WINDOW_MODE_OVERVIEW:
     case PHOTOS_WINDOW_MODE_SEARCH:
       if (selection_mode)
-        primary = photos_main_toolbar_create_selection_mode_label (self, NULL);
+        primary = photos_main_toolbar_create_selection_mode_label (self, NULL, NULL);
       break;
 
     case PHOTOS_WINDOW_MODE_EDIT:
@@ -145,6 +174,10 @@ photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
         break;
       }
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      primary = photos_main_toolbar_create_selection_mode_label (self, NULL, source);
+      break;
+
     case PHOTOS_WINDOW_MODE_NONE:
     default:
       break;
@@ -585,6 +618,7 @@ photos_main_toolbar_dispose (GObject *object)
   g_clear_object (&self->remote_mngr);
   g_clear_object (&self->sel_cntrlr);
   g_clear_object (&self->selection_menu);
+  g_clear_object (&self->src_mngr);
   g_clear_object (&self->stack_switcher);
 
   G_OBJECT_CLASS (photos_main_toolbar_parent_class)->dispose (object);
@@ -655,6 +689,7 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
   self->item_mngr = g_object_ref (state->item_mngr);
   self->mode_cntrlr = g_object_ref (state->mode_cntrlr);
   self->sel_cntrlr = photos_selection_controller_dup_singleton ();
+  self->src_mngr = g_object_ref (state->src_mngr);
 
   self->remote_mngr = photos_remote_display_manager_dup_singleton ();
   g_signal_connect_object (self->remote_mngr,
@@ -729,21 +764,44 @@ photos_main_toolbar_is_focus (PhotosMainToolbar *self)
 void
 photos_main_toolbar_reset_toolbar_mode (PhotosMainToolbar *self)
 {
+  PhotosWindowMode window_mode;
   gboolean selection_mode;
 
   photos_main_toolbar_clear_toolbar (self);
+  window_mode = photos_mode_controller_get_window_mode (self->mode_cntrlr);
   selection_mode = photos_utils_get_selection_mode ();
 
   if (selection_mode)
-    photos_main_toolbar_populate_for_selection_mode (self);
-  else
     {
-      PhotosWindowMode window_mode;
+      switch (window_mode)
+        {
+        case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
+        case PHOTOS_WINDOW_MODE_COLLECTIONS:
+        case PHOTOS_WINDOW_MODE_FAVORITES:
+        case PHOTOS_WINDOW_MODE_OVERVIEW:
+        case PHOTOS_WINDOW_MODE_SEARCH:
+          photos_main_toolbar_populate_for_selection_mode (self);
+          break;
 
-      window_mode = photos_mode_controller_get_window_mode (self->mode_cntrlr);
+        case PHOTOS_WINDOW_MODE_IMPORT:
+          photos_main_toolbar_populate_for_import_view (self);
+          break;
 
+        case PHOTOS_WINDOW_MODE_NONE:
+        case PHOTOS_WINDOW_MODE_EDIT:
+        case PHOTOS_WINDOW_MODE_PREVIEW:
+        default:
+          g_assert_not_reached ();
+          break;
+        }
+    }
+  else
+    {
       switch (window_mode)
         {
+        case PHOTOS_WINDOW_MODE_NONE:
+          break;
+
         case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
           photos_main_toolbar_populate_for_collection_view (self);
           break;
@@ -772,8 +830,9 @@ photos_main_toolbar_reset_toolbar_mode (PhotosMainToolbar *self)
           photos_main_toolbar_populate_for_search (self);
           break;
 
-        case PHOTOS_WINDOW_MODE_NONE:
+        case PHOTOS_WINDOW_MODE_IMPORT:
         default:
+          g_assert_not_reached ();
           break;
         }
     }
diff --git a/src/photos-main-window.c b/src/photos-main-window.c
index 10b0f9c2..fb7f99e9 100644
--- a/src/photos-main-window.c
+++ b/src/photos-main-window.c
@@ -160,6 +160,7 @@ photos_main_window_go_back (PhotosMainWindow *self)
   switch (mode)
     {
     case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
+    case PHOTOS_WINDOW_MODE_IMPORT:
     case PHOTOS_WINDOW_MODE_PREVIEW:
       photos_mode_controller_go_back (self->mode_cntrlr);
       break;
@@ -278,6 +279,7 @@ photos_main_window_key_press_event (GtkWidget *widget, GdkEventKey *event)
     case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
     case PHOTOS_WINDOW_MODE_COLLECTIONS:
     case PHOTOS_WINDOW_MODE_FAVORITES:
+    case PHOTOS_WINDOW_MODE_IMPORT:
     case PHOTOS_WINDOW_MODE_OVERVIEW:
     case PHOTOS_WINDOW_MODE_SEARCH:
       handled = GDK_EVENT_PROPAGATE;
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 3d7ef35e..089d0d3c 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -910,6 +910,9 @@ photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMo
       photos_preview_nav_buttons_hide (self->nav_buttons);
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      break;
+
     case PHOTOS_WINDOW_MODE_PREVIEW:
       gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), FALSE);
       photos_edit_palette_hide_details (PHOTOS_EDIT_PALETTE (self->palette));
@@ -1429,6 +1432,7 @@ photos_preview_view_set_mode (PhotosPreviewView *self, PhotosWindowMode old_mode
   g_return_if_fail (PHOTOS_IS_PREVIEW_VIEW (self));
   g_return_if_fail (old_mode != PHOTOS_WINDOW_MODE_NONE);
   g_return_if_fail (old_mode != PHOTOS_WINDOW_MODE_EDIT);
+  g_return_if_fail (old_mode != PHOTOS_WINDOW_MODE_IMPORT);
   g_return_if_fail (old_mode != PHOTOS_WINDOW_MODE_PREVIEW);
 
   photos_preview_nav_buttons_set_auto_hide (self->nav_buttons, TRUE);
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 ();
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index 7fda7686..68a73b55 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -122,6 +122,10 @@ photos_view_container_get_show_primary_text (PhotosViewContainer *self)
       ret_val = FALSE;
       break;
 
+    case PHOTOS_WINDOW_MODE_IMPORT:
+      ret_val = FALSE;
+      break;
+
     case PHOTOS_WINDOW_MODE_OVERVIEW:
       ret_val = FALSE;
       break;


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