[gnome-photos/wip/rishi/collection: 31/31] Add a new mode for importing items from an attached device
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/collection: 31/31] Add a new mode for importing items from an attached device
- Date: Sat, 20 Jan 2018 23:05:36 +0000 (UTC)
commit 299e0100bc245df3d5a9f454299719280738464e
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/Makefile.am | 4 +
src/photos-application.c | 36 ++++---
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 | 101 ++++++++++++++++--
src/photos-main-window.c | 2 +
src/photos-offset-import-controller.c | 127 ++++++++++++++++++++++
src/photos-offset-import-controller.h | 41 ++++++++
src/photos-preview-view.c | 4 +
src/photos-tracker-import-controller.c | 186 +++++++++++++++++++++++++++++++++
src/photos-tracker-import-controller.h | 41 ++++++++
src/photos-utils.c | 8 ++
src/photos-view-container.c | 4 +
15 files changed, 617 insertions(+), 28 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index dc3d8a86..8e113866 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -148,6 +148,8 @@ gnome_photos_SOURCES = \
photos-offset-controller.h \
photos-offset-favorites-controller.c \
photos-offset-favorites-controller.h \
+ photos-offset-import-controller.c \
+ photos-offset-import-controller.h \
photos-offset-overview-controller.c \
photos-offset-overview-controller.h \
photos-offset-search-controller.c \
@@ -287,6 +289,8 @@ gnome_photos_SOURCES = \
photos-tracker-controller.h \
photos-tracker-favorites-controller.c \
photos-tracker-favorites-controller.h \
+ photos-tracker-import-controller.c \
+ photos-tracker-import-controller.h \
photos-tracker-overview-controller.c \
photos-tracker-overview-controller.h \
photos-tracker-search-controller.c \
diff --git a/src/photos-application.c b/src/photos-application.c
index 5bd565b7..cd30435c 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -326,12 +326,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);
@@ -339,6 +341,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);
@@ -355,25 +360,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);
@@ -1622,6 +1626,7 @@ photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMod
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:
item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr),
old_mode);
@@ -1640,6 +1645,7 @@ photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMod
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:
item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), mode);
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 2106567d..500fd697 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -71,6 +71,7 @@ struct _PhotosEmbed
GtkWidget *collection_view;
GtkWidget *collections;
GtkWidget *favorites;
+ GtkWidget *import;
GtkWidget *no_results;
GtkWidget *ntfctn_mngr;
GtkWidget *overview;
@@ -158,6 +159,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;
@@ -413,6 +418,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 ();
@@ -446,6 +452,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)
{
@@ -629,6 +646,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;
@@ -658,6 +676,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;
@@ -749,6 +771,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 62918d2c..b7090310 100644
--- a/src/photos-empty-results-box.c
+++ b/src/photos-empty-results-box.c
@@ -177,6 +177,7 @@ photos_empty_results_box_constructed (GObject *object)
* the relevant locations.
*/
case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
+ case PHOTOS_WINDOW_MODE_IMPORT:
case PHOTOS_WINDOW_MODE_OVERVIEW:
case PHOTOS_WINDOW_MODE_SEARCH:
image = gtk_image_new_from_icon_name ("emblem-photos-symbolic", GTK_ICON_SIZE_INVALID);
@@ -217,6 +218,7 @@ photos_empty_results_box_constructed (GObject *object)
*/
case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
case PHOTOS_WINDOW_MODE_FAVORITES:
+ case PHOTOS_WINDOW_MODE_IMPORT:
case PHOTOS_WINDOW_MODE_SEARCH:
gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER);
break;
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 9be3b4ab..b0cd04ac 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -47,6 +47,7 @@
struct _PhotosItemManager
{
PhotosBaseManager parent_instance;
+ GAction *selection_mode_action;
GObject *active_object;
GCancellable *loader_cancellable;
GHashTable *collections;
@@ -691,6 +692,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)
@@ -830,11 +832,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,
@@ -1321,6 +1327,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));
@@ -1357,6 +1364,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);
@@ -1393,6 +1412,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));
@@ -1421,6 +1444,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);
@@ -1456,7 +1487,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);
@@ -1468,6 +1501,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);
@@ -1490,11 +1533,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 fe203c02..f007c461 100644
--- a/src/photos-item-manager.h
+++ b/src/photos-item-manager.h
@@ -60,6 +60,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 c4fd549c..0ff23ab7 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -28,6 +28,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-item-manager.h"
@@ -52,6 +53,7 @@ struct _PhotosMainToolbar
GtkWidget *selection_menu;
GtkWidget *stack_switcher;
PhotosBaseManager *item_mngr;
+ PhotosBaseManager *src_mngr;
PhotosModeController *mode_cntrlr;
PhotosRemoteDisplayManager *remote_mngr;
PhotosSelectionController *sel_cntrlr;
@@ -65,7 +67,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;
@@ -80,9 +84,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;
}
@@ -92,6 +107,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;
@@ -104,6 +120,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);
}
@@ -112,12 +129,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;
@@ -127,7 +156,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:
@@ -142,6 +171,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;
@@ -450,6 +483,28 @@ photos_main_toolbar_populate_for_favorites (PhotosMainToolbar *self)
}
+static void
+photos_main_toolbar_populate_for_import (PhotosMainToolbar *self)
+{
+ GtkWidget *back_button;
+ GtkStyleContext *context;
+
+ gtk_header_bar_set_custom_title (GTK_HEADER_BAR (self->header_bar), self->selection_menu);
+ context = gtk_widget_get_style_context (self->header_bar);
+ gtk_style_context_add_class (context, "selection-mode");
+
+ back_button = gtk_button_new_with_label (_("Cancel"));
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (self->header_bar), back_button);
+ g_signal_connect_swapped (back_button, "clicked", G_CALLBACK (photos_main_toolbar_back_button_clicked),
self);
+
+ g_signal_connect_object (self->sel_cntrlr,
+ "selection-changed",
+ G_CALLBACK (photos_main_toolbar_set_toolbar_title),
+ self,
+ G_CONNECT_SWAPPED);
+}
+
+
static void
photos_main_toolbar_populate_for_overview (PhotosMainToolbar *self)
{
@@ -582,6 +637,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);
@@ -652,6 +708,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,
@@ -726,21 +783,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 (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;
@@ -769,8 +849,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 d14e90f3..d9b7a7da 100644
--- a/src/photos-main-window.c
+++ b/src/photos-main-window.c
@@ -158,6 +158,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;
@@ -276,6 +277,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-offset-import-controller.c b/src/photos-offset-import-controller.c
new file mode 100644
index 00000000..f8c57dd8
--- /dev/null
+++ b/src/photos-offset-import-controller.c
@@ -0,0 +1,127 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Based on code from:
+ * + Documents
+ */
+
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "photos-base-manager.h"
+#include "photos-offset-import-controller.h"
+#include "photos-query-builder.h"
+#include "photos-search-context.h"
+#include "photos-source.h"
+
+
+struct _PhotosOffsetImportController
+{
+ PhotosOffsetController parent_instance;
+ PhotosBaseManager *src_mngr;
+};
+
+
+G_DEFINE_TYPE (PhotosOffsetImportController, photos_offset_import_controller, PHOTOS_TYPE_OFFSET_CONTROLLER);
+
+
+static PhotosQuery *
+photos_offset_import_controller_get_query (PhotosOffsetController *offset_cntrlr)
+{
+ PhotosOffsetImportController *self = PHOTOS_OFFSET_IMPORT_CONTROLLER (offset_cntrlr);
+ GApplication *app;
+ GMount *mount;
+ PhotosSearchContextState *state;
+ PhotosSource *source;
+
+ source = PHOTOS_SOURCE (photos_base_manager_get_active_object (self->src_mngr));
+ g_return_val_if_fail (PHOTOS_IS_SOURCE (source), NULL);
+
+ mount = photos_source_get_mount (source);
+ g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
+
+ app = g_application_get_default ();
+ state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
+ return photos_query_builder_count_query (state, PHOTOS_QUERY_FLAGS_NONE);
+}
+
+
+static GObject *
+photos_offset_import_controller_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ static GObject *self = NULL;
+
+ if (self == NULL)
+ {
+ self = G_OBJECT_CLASS (photos_offset_import_controller_parent_class)->constructor (type,
+ n_construct_params,
+ construct_params);
+ g_object_add_weak_pointer (self, (gpointer) &self);
+ return self;
+ }
+
+ return g_object_ref (self);
+}
+
+
+static void
+photos_offset_import_controller_dispose (GObject *object)
+{
+ PhotosOffsetImportController *self = PHOTOS_OFFSET_IMPORT_CONTROLLER (object);
+
+ g_clear_object (&self->src_mngr);
+
+ G_OBJECT_CLASS (photos_offset_import_controller_parent_class)->dispose (object);
+}
+
+
+static void
+photos_offset_import_controller_init (PhotosOffsetImportController *self)
+{
+ GApplication *app;
+ PhotosSearchContextState *state;
+
+ app = g_application_get_default ();
+ state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
+ self->src_mngr = g_object_ref (state->src_mngr);
+}
+
+
+static void
+photos_offset_import_controller_class_init (PhotosOffsetImportControllerClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ PhotosOffsetControllerClass *offset_controller_class = PHOTOS_OFFSET_CONTROLLER_CLASS (class);
+
+ object_class->constructor = photos_offset_import_controller_constructor;
+ object_class->dispose = photos_offset_import_controller_dispose;
+ offset_controller_class->get_query = photos_offset_import_controller_get_query;
+}
+
+
+PhotosOffsetController *
+photos_offset_import_controller_dup_singleton (void)
+{
+ return g_object_new (PHOTOS_TYPE_OFFSET_IMPORT_CONTROLLER, NULL);
+}
diff --git a/src/photos-offset-import-controller.h b/src/photos-offset-import-controller.h
new file mode 100644
index 00000000..c4623434
--- /dev/null
+++ b/src/photos-offset-import-controller.h
@@ -0,0 +1,41 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Based on code from:
+ * + Documents
+ */
+
+#ifndef PHOTOS_OFFSET_IMPORT_CONTROLLER_H
+#define PHOTOS_OFFSET_IMPORT_CONTROLLER_H
+
+#include "photos-offset-controller.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_OFFSET_IMPORT_CONTROLLER (photos_offset_import_controller_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosOffsetImportController,
+ photos_offset_import_controller,
+ PHOTOS,
+ OFFSET_IMPORT_CONTROLLER,
+ PhotosOffsetController);
+
+PhotosOffsetController *photos_offset_import_controller_dup_singleton (void);
+
+G_END_DECLS
+
+#endif /* PHOTOS_OFFSET_IMPORT_CONTROLLER_H */
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 7e078dcd..9009330c 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -908,6 +908,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));
@@ -1427,6 +1430,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-tracker-import-controller.c b/src/photos-tracker-import-controller.c
new file mode 100644
index 00000000..bbc453a2
--- /dev/null
+++ b/src/photos-tracker-import-controller.c
@@ -0,0 +1,186 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2018 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Based on code from:
+ * + Documents
+ */
+
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "photos-base-manager.h"
+#include "photos-item-manager.h"
+#include "photos-offset-import-controller.h"
+#include "photos-query-builder.h"
+#include "photos-search-context.h"
+#include "photos-tracker-import-controller.h"
+#include "photos-utils.h"
+
+
+struct _PhotosTrackerImportController
+{
+ PhotosTrackerController parent_instance;
+ PhotosBaseManager *item_mngr;
+ PhotosBaseManager *src_mngr;
+ PhotosOffsetController *offset_cntrlr;
+};
+
+
+G_DEFINE_TYPE_WITH_CODE (PhotosTrackerImportController,
+ photos_tracker_import_controller,
+ PHOTOS_TYPE_TRACKER_CONTROLLER,
+ photos_utils_ensure_extension_points ();
+ g_io_extension_point_implement (PHOTOS_TRACKER_CONTROLLER_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "import",
+ 0));
+
+
+static void
+photos_tracker_import_controller_source_active_changed (PhotosTrackerImportController *self, GObject *source)
+{
+ GMount *mount;
+ gboolean frozen;
+
+ g_return_if_fail (PHOTOS_IS_TRACKER_IMPORT_CONTROLLER (self));
+ g_return_if_fail (PHOTOS_IS_SOURCE (source));
+ g_return_if_fail (PHOTOS_IS_ITEM_MANAGER (self->item_mngr));
+
+ mount = photos_source_get_mount (PHOTOS_SOURCE (source));
+ frozen = mount == NULL;
+ photos_tracker_controller_set_frozen (PHOTOS_TRACKER_CONTROLLER (self), frozen);
+
+ if (mount == NULL)
+ photos_item_manager_clear (PHOTOS_ITEM_MANAGER (self->item_mngr), PHOTOS_WINDOW_MODE_IMPORT);
+ else
+ photos_tracker_controller_refresh_for_object (PHOTOS_TRACKER_CONTROLLER (self));
+}
+
+
+static PhotosOffsetController *
+photos_tracker_import_controller_get_offset_controller (PhotosTrackerController *trk_cntrlr)
+{
+ PhotosTrackerImportController *self = PHOTOS_TRACKER_IMPORT_CONTROLLER (trk_cntrlr);
+ return g_object_ref (self->offset_cntrlr);
+}
+
+
+static PhotosQuery *
+photos_tracker_import_controller_get_query (PhotosTrackerController *trk_cntrlr)
+{
+ PhotosTrackerImportController *self = PHOTOS_TRACKER_IMPORT_CONTROLLER (trk_cntrlr);
+ GApplication *app;
+ PhotosSearchContextState *state;
+
+ app = g_application_get_default ();
+ state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
+ return photos_query_builder_global_query (state, PHOTOS_QUERY_FLAGS_SEARCH, self->offset_cntrlr);
+}
+
+
+static GObject *
+photos_tracker_import_controller_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ static GObject *self = NULL;
+
+ if (self == NULL)
+ {
+ self = G_OBJECT_CLASS (photos_tracker_import_controller_parent_class)->constructor (type,
+ n_construct_params,
+ construct_params);
+ g_object_add_weak_pointer (self, (gpointer) &self);
+ return self;
+ }
+
+ return g_object_ref (self);
+}
+
+
+static void
+photos_tracker_import_controller_dispose (GObject *object)
+{
+ PhotosTrackerImportController *self = PHOTOS_TRACKER_IMPORT_CONTROLLER (object);
+
+ g_clear_object (&self->src_mngr);
+ g_clear_object (&self->offset_cntrlr);
+
+ G_OBJECT_CLASS (photos_tracker_import_controller_parent_class)->dispose (object);
+}
+
+
+static void
+photos_tracker_import_controller_finalize (GObject *object)
+{
+ PhotosTrackerImportController *self = PHOTOS_TRACKER_IMPORT_CONTROLLER (object);
+
+ if (self->item_mngr != NULL)
+ g_object_remove_weak_pointer (G_OBJECT (self->item_mngr), (gpointer *) &self->item_mngr);
+
+ G_OBJECT_CLASS (photos_tracker_import_controller_parent_class)->finalize (object);
+}
+
+
+static void
+photos_tracker_import_controller_init (PhotosTrackerImportController *self)
+{
+ GApplication *app;
+ PhotosSearchContextState *state;
+
+ app = g_application_get_default ();
+ state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
+ self->item_mngr = state->item_mngr;
+ g_object_add_weak_pointer (G_OBJECT (self->item_mngr), (gpointer *) &self->item_mngr);
+
+ self->src_mngr = g_object_ref (state->src_mngr);
+ g_signal_connect_swapped (self->src_mngr,
+ "active-changed",
+ G_CALLBACK (photos_tracker_import_controller_source_active_changed),
+ self);
+
+ self->offset_cntrlr = photos_offset_import_controller_dup_singleton ();
+}
+
+
+static void
+photos_tracker_import_controller_class_init (PhotosTrackerImportControllerClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ PhotosTrackerControllerClass *tracker_controller_class = PHOTOS_TRACKER_CONTROLLER_CLASS (class);
+
+ object_class->constructor = photos_tracker_import_controller_constructor;
+ object_class->dispose = photos_tracker_import_controller_dispose;
+ object_class->finalize = photos_tracker_import_controller_finalize;
+ tracker_controller_class->get_offset_controller = photos_tracker_import_controller_get_offset_controller;
+ tracker_controller_class->get_query = photos_tracker_import_controller_get_query;
+}
+
+
+PhotosTrackerController *
+photos_tracker_import_controller_dup_singleton (void)
+{
+ return g_object_new (PHOTOS_TYPE_TRACKER_IMPORT_CONTROLLER,
+ "delay-start", TRUE,
+ "mode", PHOTOS_WINDOW_MODE_SEARCH,
+ NULL);
+}
diff --git a/src/photos-tracker-import-controller.h b/src/photos-tracker-import-controller.h
new file mode 100644
index 00000000..3c9ada8a
--- /dev/null
+++ b/src/photos-tracker-import-controller.h
@@ -0,0 +1,41 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2018 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Based on code from:
+ * + Documents
+ */
+
+#ifndef PHOTOS_TRACKER_IMPORT_CONTROLLER_H
+#define PHOTOS_TRACKER_IMPORT_CONTROLLER_H
+
+#include "photos-tracker-controller.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_TRACKER_IMPORT_CONTROLLER (photos_tracker_import_controller_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosTrackerImportController,
+ photos_tracker_import_controller,
+ PHOTOS,
+ TRACKER_IMPORT_CONTROLLER,
+ PhotosTrackerController);
+
+PhotosTrackerController *photos_tracker_import_controller_dup_singleton (void);
+
+G_END_DECLS
+
+#endif /* PHOTOS_TRACKER_IMPORT_CONTROLLER_H */
diff --git a/src/photos-utils.c b/src/photos-utils.c
index a0bb452e..2333f95a 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -45,6 +45,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"
@@ -62,6 +63,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"
@@ -721,6 +723,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);
@@ -1017,6 +1020,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 1679bf1e..da5bd854 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -120,6 +120,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]