[gnome-photos/wip/rishi/collection: 4/51] Don't limit SetCollectionJob to just the current selection
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/collection: 4/51] Don't limit SetCollectionJob to just the current selection
- Date: Wed, 7 Feb 2018 23:58:58 +0000 (UTC)
commit fe0a3ca319866dc316c5e7d1ac50582cb4cbfbd9
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 8 00:49:01 2018 +0100
Don't limit SetCollectionJob to just the current selection
A subsequent commit will add content imported from attached devices to
a collection. This list of URNs representing the imported content is
not going to be the current selection held by SelectionController.
https://gitlab.gnome.org/GNOME/gnome-photos/issues/29
src/photos-organize-collection-view.c | 24 ++++++++++++++++++++++--
src/photos-set-collection-job.c | 14 ++------------
src/photos-set-collection-job.h | 4 ++++
3 files changed, 28 insertions(+), 14 deletions(-)
---
diff --git a/src/photos-organize-collection-view.c b/src/photos-organize-collection-view.c
index aeb1fff2..73508193 100644
--- a/src/photos-organize-collection-view.c
+++ b/src/photos-organize-collection-view.c
@@ -35,6 +35,7 @@
#include "photos-organize-collection-view.h"
#include "photos-query.h"
#include "photos-search-context.h"
+#include "photos-selection-controller.h"
#include "photos-set-collection-job.h"
#include "photos-utils.h"
@@ -50,6 +51,7 @@ struct _PhotosOrganizeCollectionView
GtkTreeViewColumn *view_col;
PhotosBaseManager *item_mngr;
PhotosBaseManager *src_mngr;
+ PhotosSelectionController *sel_cntrlr;
gboolean choice_confirmed;
};
@@ -112,19 +114,28 @@ photos_organize_collection_view_set_collection_executed (GObject *source_object,
static void
photos_organize_collection_view_check_toggled (PhotosOrganizeCollectionView *self, gchar *path)
{
+ GApplication *app;
+ GList *urns;
GtkTreeIter iter;
GtkTreePath *tree_path;
+ PhotosSearchContextState *state;
PhotosSetCollectionJob *job;
gboolean active;
gchar *coll_urn;
+ app = g_application_get_default ();
+ state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
tree_path = gtk_tree_path_new_from_string (path);
gtk_tree_model_get_iter (GTK_TREE_MODEL (self->model), &iter, tree_path);
gtk_tree_model_get (GTK_TREE_MODEL (self->model), &iter, PHOTOS_ORGANIZE_MODEL_ID, &coll_urn, -1);
active = gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (self->renderer_check));
- job = photos_set_collection_job_new (coll_urn, !state);
+ job = photos_set_collection_job_new (coll_urn, !active);
+ urns = photos_selection_controller_get_selection (self->sel_cntrlr);
photos_set_collection_job_run (job,
+ state,
+ urns,
self->cancellable,
photos_organize_collection_view_set_collection_executed,
self);
@@ -140,9 +151,12 @@ photos_organize_collection_view_create_collection_executed (GObject *source_obje
PhotosOrganizeCollectionView *self;
PhotosCreateCollectionJob *col_job = PHOTOS_CREATE_COLLECTION_JOB (source_object);
PhotosSetCollectionJob *set_job = NULL;
+ GApplication *app;
GError *error;
+ GList *urns;
GtkTreeIter iter;
GtkTreePath *path = NULL;
+ PhotosSearchContextState *state;
gchar *created_urn = NULL;
error = NULL;
@@ -173,11 +187,15 @@ photos_organize_collection_view_create_collection_executed (GObject *source_obje
if (path == NULL)
goto out;
+ app = g_application_get_default ();
+ state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
gtk_tree_model_get_iter (GTK_TREE_MODEL (self->model), &iter, path);
gtk_list_store_set (self->model, &iter, PHOTOS_ORGANIZE_MODEL_ID, created_urn, -1);
set_job = photos_set_collection_job_new (created_urn, TRUE);
- photos_set_collection_job_run (set_job, NULL, NULL, NULL);
+ urns = photos_selection_controller_get_selection (self->sel_cntrlr);
+ photos_set_collection_job_run (set_job, state, urns, NULL, NULL, NULL);
out:
g_clear_object (&set_job);
@@ -320,6 +338,7 @@ photos_organize_collection_view_dispose (GObject *object)
g_clear_object (&self->model);
g_clear_object (&self->item_mngr);
g_clear_object (&self->src_mngr);
+ g_clear_object (&self->sel_cntrlr);
G_OBJECT_CLASS (photos_organize_collection_view_parent_class)->dispose (object);
}
@@ -378,6 +397,7 @@ photos_organize_collection_view_init (PhotosOrganizeCollectionView *self)
self->item_mngr = g_object_ref (state->item_mngr);
self->src_mngr = g_object_ref (state->src_mngr);
+ self->sel_cntrlr = photos_selection_controller_dup_singleton ();
gtk_widget_show (GTK_WIDGET (self));
}
diff --git a/src/photos-set-collection-job.c b/src/photos-set-collection-job.c
index 1e8b6832..eab2091b 100644
--- a/src/photos-set-collection-job.c
+++ b/src/photos-set-collection-job.c
@@ -28,8 +28,6 @@
#include "photos-query.h"
#include "photos-query-builder.h"
-#include "photos-search-context.h"
-#include "photos-selection-controller.h"
#include "photos-set-collection-job.h"
#include "photos-tracker-queue.h"
#include "photos-update-mtime-job.h"
@@ -39,7 +37,6 @@ struct _PhotosSetCollectionJob
{
GObject parent_instance;
GError *queue_error;
- PhotosSelectionController *sel_cntrlr;
PhotosTrackerQueue *queue;
gboolean setting;
gchar *collection_urn;
@@ -124,7 +121,6 @@ photos_set_collection_job_dispose (GObject *object)
{
PhotosSetCollectionJob *self = PHOTOS_SET_COLLECTION_JOB (object);
- g_clear_object (&self->sel_cntrlr);
g_clear_object (&self->queue);
G_OBJECT_CLASS (photos_set_collection_job_parent_class)->dispose (object);
@@ -168,7 +164,6 @@ photos_set_collection_job_set_property (GObject *object, guint prop_id, const GV
static void
photos_set_collection_job_init (PhotosSetCollectionJob *self)
{
- self->sel_cntrlr = photos_selection_controller_dup_singleton ();
self->queue = photos_tracker_queue_dup_singleton (NULL, &self->queue_error);
}
@@ -230,15 +225,14 @@ photos_set_collection_job_finish (PhotosSetCollectionJob *self, GAsyncResult *re
void
photos_set_collection_job_run (PhotosSetCollectionJob *self,
+ PhotosSearchContextState *state,
+ GList *urns,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GApplication *app;
GList *l;
- GList *urns;
GTask *task = NULL;
- PhotosSearchContextState *state;
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, photos_set_collection_job_run);
@@ -249,10 +243,6 @@ photos_set_collection_job_run (PhotosSetCollectionJob *self,
goto out;
}
- app = g_application_get_default ();
- state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
-
- urns = photos_selection_controller_get_selection (self->sel_cntrlr);
for (l = urns; l != NULL; l = l->next)
{
PhotosQuery *query = NULL;
diff --git a/src/photos-set-collection-job.h b/src/photos-set-collection-job.h
index f8bb2f96..7ff52614 100644
--- a/src/photos-set-collection-job.h
+++ b/src/photos-set-collection-job.h
@@ -25,6 +25,8 @@
#include <gio/gio.h>
+#include "photos-search-context.h"
+
G_BEGIN_DECLS
#define PHOTOS_TYPE_SET_COLLECTION_JOB (photos_set_collection_job_get_type ())
@@ -37,6 +39,8 @@ gboolean photos_set_collection_job_finish (PhotosSetCollec
GError **error);
void photos_set_collection_job_run (PhotosSetCollectionJob *self,
+ PhotosSearchContextState *state,
+ GList *urns,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]