[gnome-photos/wip/rishi/collection: 20/24] application, base-model: ...



commit 99e4d11a5bef3a83a805c26dd383038658ca2bb7
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 16 16:21:04 2018 +0100

    application, base-model: ...
    
    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 17d018ca..7730ac95 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1765,6 +1765,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)
 {
@@ -2155,14 +2176,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]