[gnome-photos/wip/rishi/collection: 29/33] 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: 29/33] embed: React to SearchMatch changes; include it in the search state
- Date: Sun, 21 Jan 2018 23:49:51 +0000 (UTC)
commit 4ed211910086ef13854295d1f5fd8a8852f09af8
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 1969579c..2106567d 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -39,6 +39,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"
@@ -54,6 +55,7 @@ typedef struct _PhotosEmbedSearchState PhotosEmbedSearchState;
struct _PhotosEmbedSearchState
{
+ GObject *search_match;
GObject *search_type;
GObject *source;
gboolean saved;
@@ -80,6 +82,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;
@@ -101,6 +104,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);
}
@@ -110,6 +114,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);
}
@@ -196,6 +201,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);
@@ -219,6 +225,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;
@@ -477,6 +484,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;
@@ -500,12 +508,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'))
{
@@ -679,6 +691,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);
@@ -806,6 +819,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]