[gnome-photos] Use g_signal_connect_swapped to simplify the callbacks



commit 7d1c3fffed7e388b0b5cd532cc00a8abdeff8cdf
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Jan 4 13:05:39 2014 +0100

    Use g_signal_connect_swapped to simplify the callbacks

 src/photos-embed.c              |   13 ++++++-------
 src/photos-item-manager.c       |    8 +++++---
 src/photos-tracker-controller.c |   30 ++++++++++++++----------------
 3 files changed, 25 insertions(+), 26 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 77db8d4..e9ff756 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -389,9 +389,8 @@ photos_embed_query_error (PhotosEmbed *self, const gchar *primary, const gchar *
 
 
 static void
-photos_embed_query_status_changed (PhotosTrackerController *trk_cntrlr, gboolean querying, gpointer 
user_data)
+photos_embed_query_status_changed (PhotosEmbed *self, gboolean querying)
 {
-  PhotosEmbed *self = PHOTOS_EMBED (user_data);
   PhotosEmbedPrivate *priv = self->priv;
 
   if (querying)
@@ -541,10 +540,10 @@ photos_embed_init (PhotosEmbed *self)
 
   priv->trk_ovrvw_cntrlr = photos_tracker_overview_controller_dup_singleton ();
   g_signal_connect_swapped (priv->trk_ovrvw_cntrlr, "query-error", G_CALLBACK (photos_embed_query_error), 
self);
-  g_signal_connect (priv->trk_ovrvw_cntrlr,
-                    "query-status-changed",
-                    G_CALLBACK (photos_embed_query_status_changed),
-                    self);
+  g_signal_connect_swapped (priv->trk_ovrvw_cntrlr,
+                            "query-status-changed",
+                            G_CALLBACK (photos_embed_query_status_changed),
+                            self);
 
   priv->offset_cntrlr = photos_offset_overview_controller_dup_singleton ();
   g_signal_connect_swapped (priv->offset_cntrlr, "count-changed", G_CALLBACK (photos_embed_count_changed), 
self);
@@ -553,7 +552,7 @@ photos_embed_init (PhotosEmbed *self)
   g_signal_connect (priv->item_mngr, "active-changed", G_CALLBACK (photos_embed_active_changed), self);
 
   querying = photos_tracker_controller_get_query_status (priv->trk_ovrvw_cntrlr);
-  photos_embed_query_status_changed (priv->trk_ovrvw_cntrlr, querying, self);
+  photos_embed_query_status_changed (self, querying);
 
   priv->monitor = photos_tracker_change_monitor_dup_singleton (NULL, NULL);
 
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index b5ee500..906f862 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -119,9 +119,8 @@ photos_item_manager_changes_pending_foreach (gpointer key, gpointer value, gpoin
 
 
 static void
-photos_item_manager_changes_pending (PhotosTrackerChangeMonitor *monitor, GHashTable *changes, gpointer 
user_data)
+photos_item_manager_changes_pending (PhotosItemManager *self, GHashTable *changes)
 {
-  PhotosItemManager *self = PHOTOS_ITEM_MANAGER (user_data);
   g_hash_table_foreach (changes, photos_item_manager_changes_pending_foreach, self);
 }
 
@@ -224,7 +223,10 @@ photos_item_manager_init (PhotosItemManager *self)
 
   priv->monitor = photos_tracker_change_monitor_dup_singleton (NULL, NULL);
   if (G_LIKELY (priv->monitor != NULL))
-    g_signal_connect (priv->monitor, "changes-pending", G_CALLBACK (photos_item_manager_changes_pending), 
self);
+    g_signal_connect_swapped (priv->monitor,
+                              "changes-pending",
+                              G_CALLBACK (photos_item_manager_changes_pending),
+                              self);
 }
 
 
diff --git a/src/photos-tracker-controller.c b/src/photos-tracker-controller.c
index 1ffc6d5..ecbbf00 100644
--- a/src/photos-tracker-controller.c
+++ b/src/photos-tracker-controller.c
@@ -201,17 +201,15 @@ photos_tracker_controller_perform_current_query (PhotosTrackerController *self)
 
 
 static void
-photos_tracker_controller_offset_changed (PhotosOffsetController *offset_cntrlr, gint offset, gpointer 
user_data)
+photos_tracker_controller_offset_changed (PhotosTrackerController *self)
 {
-  PhotosTrackerController *self = PHOTOS_TRACKER_CONTROLLER (user_data);
   photos_tracker_controller_perform_current_query (self);
 }
 
 
 static void
-photos_tracker_controller_refresh_for_object (PhotosBaseManager *manager, GObject *object, gpointer 
user_data)
+photos_tracker_controller_refresh_for_object (PhotosTrackerController *self)
 {
-  PhotosTrackerController *self = PHOTOS_TRACKER_CONTROLLER (user_data);
   photos_tracker_controller_refresh_internal (self, PHOTOS_TRACKER_REFRESH_FLAGS_RESET_OFFSET);
 }
 
@@ -325,10 +323,10 @@ photos_tracker_controller_constructed (GObject *object)
                             self);
 
   priv->offset_cntrlr = PHOTOS_TRACKER_CONTROLLER_GET_CLASS (self)->get_offset_controller ();
-  g_signal_connect (priv->offset_cntrlr,
-                    "offset-changed",
-                    G_CALLBACK (photos_tracker_controller_offset_changed),
-                    self);
+  g_signal_connect_swapped (priv->offset_cntrlr,
+                            "offset-changed",
+                            G_CALLBACK (photos_tracker_controller_offset_changed),
+                            self);
 }
 
 
@@ -394,10 +392,10 @@ photos_tracker_controller_init (PhotosTrackerController *self)
   priv->item_mngr = photos_item_manager_dup_singleton ();
 
   priv->col_mngr = photos_collection_manager_dup_singleton ();
-  g_signal_connect (priv->col_mngr,
-                    "active-changed",
-                    G_CALLBACK (photos_tracker_controller_refresh_for_object),
-                    self);
+  g_signal_connect_swapped (priv->col_mngr,
+                            "active-changed",
+                            G_CALLBACK (photos_tracker_controller_refresh_for_object),
+                            self);
 
   priv->src_mngr = photos_source_manager_dup_singleton ();
   g_signal_connect_swapped (priv->src_mngr,
@@ -408,10 +406,10 @@ photos_tracker_controller_init (PhotosTrackerController *self)
                             "object-removed",
                             G_CALLBACK (photos_tracker_controller_source_object_added_removed),
                             self);
-  g_signal_connect (priv->src_mngr,
-                    "active-changed",
-                    G_CALLBACK (photos_tracker_controller_refresh_for_object),
-                    self);
+  g_signal_connect_swapped (priv->src_mngr,
+                            "active-changed",
+                            G_CALLBACK (photos_tracker_controller_refresh_for_object),
+                            self);
 
   priv->queue = photos_tracker_queue_dup_singleton (NULL, &priv->queue_error);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]