[gnome-photos/wip/rishi/collection: 27/42] application, base-model: Handle app.search-* more globally
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/collection: 27/42] application, base-model: Handle app.search-* more globally
- Date: Thu, 25 Jan 2018 03:18:09 +0000 (UTC)
commit b8e450c384abc510a42c35ce94315120bd0c9e90
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jan 16 16:21:04 2018 +0100
application, base-model: Handle app.search-* more globally
So far, only the BaseModels used by Dropdown used the app.search-*
GActions to change the active SearchMatch, SearchType and Source used
by SEARCH. Going forward, they are also going to be used to select the
attached device from which to import. Therefore, it makes sense to
handle their state changes in a more global location than BaseModel.
https://bugzilla.gnome.org/show_bug.cgi?id=751212
src/photos-application.c | 33 +++++++++++++++++++++++++++++++++
src/photos-base-model.c | 23 -----------------------
2 files changed, 33 insertions(+), 23 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index a997edff..bd78fde7 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1761,6 +1761,27 @@ photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMod
}
+static void
+photos_application_search_notify_state (GSimpleAction *simple, GParamSpec *pspec, gpointer user_data)
+{
+ PhotosBaseManager *mngr = PHOTOS_BASE_MANAGER (user_data);
+ g_autoptr (GVariant) state = NULL;
+ const gchar *action_id;
+ const gchar *id;
+ const gchar *name;
+
+ action_id = photos_base_manager_get_action_id (mngr);
+ name = g_action_get_name (G_ACTION (simple));
+ g_return_if_fail (g_strcmp0 (action_id, name) == 0);
+
+ state = g_action_get_state (G_ACTION (simple));
+ g_return_if_fail (state != NULL);
+
+ id = g_variant_get_string (state, NULL);
+ photos_base_manager_set_active_object_by_id (mngr, id);
+}
+
+
static void
photos_application_selection_changed (PhotosApplication *self)
{
@@ -2147,14 +2168,26 @@ photos_application_startup (GApplication *application)
state = g_variant_new ("s", PHOTOS_SEARCH_MATCH_STOCK_ALL);
self->search_match_action = g_simple_action_new_stateful ("search-match", G_VARIANT_TYPE_STRING, state);
+ g_signal_connect (self->search_match_action,
+ "notify::state",
+ G_CALLBACK (photos_application_search_notify_state),
+ self->state->srch_mtch_mngr);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->search_match_action));
state = g_variant_new ("s", PHOTOS_SOURCE_STOCK_ALL);
self->search_source_action = g_simple_action_new_stateful ("search-source", G_VARIANT_TYPE_STRING, state);
+ g_signal_connect (self->search_source_action,
+ "notify::state",
+ G_CALLBACK (photos_application_search_notify_state),
+ self->state->src_mngr);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->search_source_action));
state = g_variant_new ("s", PHOTOS_SEARCH_TYPE_STOCK_ALL);
self->search_type_action = g_simple_action_new_stateful ("search-type", G_VARIANT_TYPE_STRING, state);
+ g_signal_connect (self->search_type_action,
+ "notify::state",
+ G_CALLBACK (photos_application_search_notify_state),
+ self->state->srch_typ_mngr);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->search_type_action));
self->sel_all_action = g_simple_action_new ("select-all", NULL);
diff --git a/src/photos-base-model.c b/src/photos-base-model.c
index 077ad487..929599f9 100644
--- a/src/photos-base-model.c
+++ b/src/photos-base-model.c
@@ -47,16 +47,6 @@ enum
G_DEFINE_TYPE (PhotosBaseModel, photos_base_model, G_TYPE_OBJECT);
-static void
-photos_base_model_action_state_changed (PhotosBaseModel *self, const gchar *action_name, GVariant *value)
-{
- const gchar *id;
-
- id = g_variant_get_string (value, NULL);
- photos_base_manager_set_active_object_by_id (self->mngr, id);
-}
-
-
static void
photos_base_model_active_changed (PhotosBaseModel *self, GObject *active_object)
{
@@ -116,9 +106,6 @@ static void
photos_base_model_constructed (GObject *object)
{
PhotosBaseModel *self = PHOTOS_BASE_MODEL (object);
- GApplication *app;
- const gchar *action_id;
- g_autofree gchar *detailed_signal = NULL;
G_OBJECT_CLASS (photos_base_model_parent_class)->constructed (object);
@@ -134,16 +121,6 @@ photos_base_model_constructed (GObject *object)
G_CALLBACK (photos_base_model_refresh),
self,
G_CONNECT_SWAPPED);
-
- app = g_application_get_default ();
- action_id = photos_base_manager_get_action_id (self->mngr);
- detailed_signal = g_strconcat ("action-state-changed::", action_id, NULL);
- g_signal_connect_object (app,
- detailed_signal,
- G_CALLBACK (photos_base_model_action_state_changed),
- self,
- G_CONNECT_SWAPPED);
-
g_signal_connect_object (self->mngr,
"active-changed",
G_CALLBACK (photos_base_model_active_changed),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]