[gnome-photos/wip/rishi/collection: 22/25] embed: React to SearchMatch changes; include it in the search state
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/collection: 22/25] embed: React to SearchMatch changes; include it in the search state
- Date: Thu, 18 Jan 2018 09:00:01 +0000 (UTC)
commit 61eb59c453611fd7698c1b800c6d0a059679adf0
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jan 16 17:54:33 2018 +0100
embed: React to SearchMatch changes; include it in the search state
src/photos-embed.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 791d9fcb..f2ac01be 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -41,6 +41,7 @@
#include "photos-selection-toolbar.h"
#include "photos-spinner-box.h"
#include "photos-search-context.h"
+#include "photos-search-match.h"
#include "photos-search-type.h"
#include "photos-search-type-manager.h"
#include "photos-source.h"
@@ -56,6 +57,7 @@ typedef struct _PhotosEmbedSearchState PhotosEmbedSearchState;
struct _PhotosEmbedSearchState
{
+ GObject *search_match;
GObject *search_type;
GObject *source;
gboolean saved;
@@ -82,6 +84,7 @@ struct _PhotosEmbed
GtkWidget *toolbar;
PhotosBaseManager *item_mngr;
PhotosBaseManager *src_mngr;
+ PhotosBaseManager *srch_mtch_mngr;
PhotosBaseManager *srch_typ_mngr;
PhotosEmbedSearchState search_state;
PhotosModeController *mode_cntrlr;
@@ -103,6 +106,7 @@ photos_embed_block_search_changed (PhotosEmbed *self)
{
g_signal_handlers_block_by_func (self->src_mngr, photos_embed_search_changed, self);
g_signal_handlers_block_by_func (self->srch_cntrlr, photos_embed_search_changed, self);
+ g_signal_handlers_block_by_func (self->srch_mtch_mngr, photos_embed_search_changed, self);
g_signal_handlers_block_by_func (self->srch_typ_mngr, photos_embed_search_changed, self);
}
@@ -112,6 +116,7 @@ photos_embed_unblock_search_changed (PhotosEmbed *self)
{
g_signal_handlers_unblock_by_func (self->src_mngr, photos_embed_search_changed, self);
g_signal_handlers_unblock_by_func (self->srch_cntrlr, photos_embed_search_changed, self);
+ g_signal_handlers_unblock_by_func (self->srch_mtch_mngr, photos_embed_search_changed, self);
g_signal_handlers_unblock_by_func (self->srch_typ_mngr, photos_embed_search_changed, self);
}
@@ -198,6 +203,7 @@ photos_embed_restore_search (PhotosEmbed *self)
photos_embed_block_search_changed (self);
photos_base_manager_set_active_object (self->src_mngr, self->search_state.source);
+ photos_base_manager_set_active_object (self->srch_mtch_mngr, self->search_state.search_match);
photos_base_manager_set_active_object (self->srch_typ_mngr, self->search_state.search_type);
photos_search_controller_set_string (self->srch_cntrlr, self->search_state.str);
photos_embed_unblock_search_changed (self);
@@ -221,6 +227,7 @@ photos_embed_save_search (PhotosEmbed *self)
photos_embed_clear_search (self);
self->search_state.source = g_object_ref (photos_base_manager_get_active_object (self->src_mngr));
+ self->search_state.search_match = g_object_ref (photos_base_manager_get_active_object
(self->srch_mtch_mngr));
self->search_state.search_type = g_object_ref (photos_base_manager_get_active_object
(self->srch_typ_mngr));
self->search_state.str = g_strdup (photos_search_controller_get_string (self->srch_cntrlr));
self->search_state.saved = TRUE;
@@ -479,6 +486,7 @@ static void
photos_embed_search_changed (PhotosEmbed *self)
{
GObject *object;
+ const gchar *search_match_id;
const gchar *search_type_id;
const gchar *source_id;
const gchar *str;
@@ -502,12 +510,16 @@ photos_embed_search_changed (PhotosEmbed *self)
object = photos_base_manager_get_active_object (self->src_mngr);
source_id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
+ object = photos_base_manager_get_active_object (self->srch_mtch_mngr);
+ search_match_id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
+
object = photos_base_manager_get_active_object (self->srch_typ_mngr);
search_type_id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
str = photos_search_controller_get_string (self->srch_cntrlr);
- if (g_strcmp0 (search_type_id, PHOTOS_SEARCH_TYPE_STOCK_ALL) == 0
+ if (g_strcmp0 (search_match_id, PHOTOS_SEARCH_MATCH_STOCK_ALL) == 0
+ && g_strcmp0 (search_type_id, PHOTOS_SEARCH_TYPE_STOCK_ALL) == 0
&& g_strcmp0 (source_id, PHOTOS_SOURCE_STOCK_ALL) == 0
&& (str == NULL || str [0] == '\0'))
{
@@ -681,6 +693,7 @@ photos_embed_dispose (GObject *object)
g_clear_object (&self->ntfctn_mngr);
g_clear_object (&self->item_mngr);
g_clear_object (&self->src_mngr);
+ g_clear_object (&self->srch_mtch_mngr);
g_clear_object (&self->srch_typ_mngr);
g_clear_object (&self->mode_cntrlr);
g_clear_object (&self->srch_cntrlr);
@@ -808,6 +821,13 @@ photos_embed_init (PhotosEmbed *self)
photos_embed_source_manager_notification_show (self, source);
}
+ self->srch_mtch_mngr = g_object_ref (state->srch_mtch_mngr);
+ g_signal_connect_object (self->srch_mtch_mngr,
+ "active-changed",
+ G_CALLBACK (photos_embed_search_changed),
+ self,
+ G_CONNECT_SWAPPED);
+
self->srch_typ_mngr = g_object_ref (state->srch_typ_mngr);
g_signal_connect_object (self->srch_typ_mngr,
"active-changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]