[gnome-photos] main-toolbar: Use g_signal_connect_swapped to simplify the callbacks
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] main-toolbar: Use g_signal_connect_swapped to simplify the callbacks
- Date: Fri, 1 Aug 2014 17:17:17 +0000 (UTC)
commit 81964552e1b56331736fac16c90d07fe22ad3f12
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Aug 1 18:54:57 2014 +0200
main-toolbar: Use g_signal_connect_swapped to simplify the callbacks
src/photos-main-toolbar.c | 63 +++++++++++++++++++++++---------------------
1 files changed, 33 insertions(+), 30 deletions(-)
---
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 6c268bd..0d4cd43 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -168,17 +168,15 @@ photos_main_toolbar_add_back_button (PhotosMainToolbar *self)
static void
-photos_main_toolbar_coll_back_button_clicked (GtkButton *button, gpointer user_data)
+photos_main_toolbar_coll_back_button_clicked (PhotosMainToolbar *self)
{
- PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
photos_item_manager_activate_previous_collection (PHOTOS_ITEM_MANAGER (self->priv->item_mngr));
}
static void
-photos_main_toolbar_col_active_changed (PhotosBaseManager *manager, GObject *object, gpointer user_data)
+photos_main_toolbar_col_active_changed (PhotosMainToolbar *self, GObject *object)
{
- PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
PhotosMainToolbarPrivate *priv = self->priv;
PhotosHeaderBarMode mode;
@@ -190,10 +188,10 @@ photos_main_toolbar_col_active_changed (PhotosBaseManager *manager, GObject *obj
priv->coll_back_button = photos_main_toolbar_add_back_button (self);
gtk_widget_show (priv->coll_back_button);
- g_signal_connect (priv->coll_back_button,
- "clicked",
- G_CALLBACK (photos_main_toolbar_coll_back_button_clicked),
- self);
+ g_signal_connect_swapped (priv->coll_back_button,
+ "clicked",
+ G_CALLBACK (photos_main_toolbar_coll_back_button_clicked),
+ self);
}
}
else
@@ -212,9 +210,8 @@ photos_main_toolbar_col_active_changed (PhotosBaseManager *manager, GObject *obj
static void
-photos_main_toolbar_item_active_changed (PhotosBaseManager *manager, GObject *object, gpointer user_data)
+photos_main_toolbar_item_active_changed (PhotosMainToolbar *self, GObject *object)
{
- PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
PhotosMainToolbarPrivate *priv = self->priv;
PhotosWindowMode window_mode;
gboolean favorite;
@@ -234,18 +231,15 @@ photos_main_toolbar_item_active_changed (PhotosBaseManager *manager, GObject *ob
static void
-photos_main_toolbar_select_button_clicked (GtkButton *button, gpointer user_data)
+photos_main_toolbar_select_button_clicked (PhotosMainToolbar *self)
{
- PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, TRUE);
}
static void
-photos_main_toolbar_remote_display_button_clicked (GtkButton *button,
- gpointer user_data)
+photos_main_toolbar_remote_display_button_clicked (PhotosMainToolbar *self)
{
- PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
PhotosMainToolbarPrivate *priv = self->priv;
photos_remote_display_manager_stop (priv->remote_mngr);
@@ -276,8 +270,10 @@ photos_main_toolbar_add_remote_display_button (PhotosMainToolbar *self)
gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->toolbar), priv->remote_display_button);
gtk_widget_show_all (priv->remote_display_button);
- g_signal_connect (priv->remote_display_button, "clicked",
- G_CALLBACK (photos_main_toolbar_remote_display_button_clicked), self);
+ g_signal_connect_swapped (priv->remote_display_button,
+ "clicked",
+ G_CALLBACK (photos_main_toolbar_remote_display_button_clicked),
+ self);
g_free (text);
}
@@ -308,22 +304,24 @@ photos_main_toolbar_add_selection_button (PhotosMainToolbar *self)
selection_button = gtk_button_new_from_icon_name (PHOTOS_ICON_OBJECT_SELECT_SYMBOLIC,
GTK_ICON_SIZE_BUTTON);
gtk_widget_set_tooltip_text (selection_button, _("Select Items"));
gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->toolbar), selection_button);
- g_signal_connect (selection_button, "clicked", G_CALLBACK (photos_main_toolbar_select_button_clicked),
self);
+ g_signal_connect_swapped (selection_button,
+ "clicked",
+ G_CALLBACK (photos_main_toolbar_select_button_clicked),
+ self);
g_signal_connect_object (priv->col_mngr,
"active-changed",
G_CALLBACK (photos_main_toolbar_col_active_changed),
self,
- 0);
+ G_CONNECT_SWAPPED);
return selection_button;
}
static void
-photos_main_toolbar_back_button_clicked (GtkButton *button, gpointer user_data)
+photos_main_toolbar_back_button_clicked (PhotosMainToolbar *self)
{
- PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
PhotosMainToolbarPrivate *priv = self->priv;
photos_base_manager_set_active_object (priv->item_mngr, NULL);
@@ -439,9 +437,8 @@ photos_main_toolbar_create_preview_menu (PhotosMainToolbar *self)
static void
-photos_main_toolbar_done_button_clicked (GtkButton *button, gpointer user_data)
+photos_main_toolbar_done_button_clicked (PhotosMainToolbar *self)
{
- PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (user_data);
photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, FALSE);
}
@@ -504,7 +501,7 @@ photos_main_toolbar_populate_for_collections (PhotosMainToolbar *self)
gtk_container_add (GTK_CONTAINER (self), priv->searchbar);
object = photos_base_manager_get_active_object (priv->col_mngr);
- photos_main_toolbar_col_active_changed (priv->col_mngr, object, self);
+ photos_main_toolbar_col_active_changed (self, object);
}
@@ -541,7 +538,7 @@ photos_main_toolbar_populate_for_favorites (PhotosMainToolbar *self)
gtk_container_add (GTK_CONTAINER (self), priv->searchbar);
object = photos_base_manager_get_active_object (priv->col_mngr);
- photos_main_toolbar_col_active_changed (priv->col_mngr, object, self);
+ photos_main_toolbar_col_active_changed (self, object);
}
@@ -560,7 +557,7 @@ photos_main_toolbar_populate_for_overview (PhotosMainToolbar *self)
gtk_container_add (GTK_CONTAINER (self), priv->searchbar);
object = photos_base_manager_get_active_object (priv->col_mngr);
- photos_main_toolbar_col_active_changed (priv->col_mngr, object, self);
+ photos_main_toolbar_col_active_changed (self, object);
}
@@ -582,7 +579,7 @@ photos_main_toolbar_populate_for_preview (PhotosMainToolbar *self)
photos_header_bar_set_mode (PHOTOS_HEADER_BAR (priv->toolbar), PHOTOS_HEADER_BAR_MODE_STANDALONE);
back_button = photos_main_toolbar_add_back_button (self);
- g_signal_connect (back_button, "clicked", G_CALLBACK (photos_main_toolbar_back_button_clicked), self);
+ g_signal_connect_swapped (back_button, "clicked", G_CALLBACK (photos_main_toolbar_back_button_clicked),
self);
preview_menu = photos_main_toolbar_create_preview_menu (self);
image = gtk_image_new_from_icon_name (PHOTOS_ICON_SYSTEM_SYMBOLIC, GTK_ICON_SIZE_BUTTON);
@@ -614,7 +611,10 @@ photos_main_toolbar_populate_for_preview (PhotosMainToolbar *self)
remote_display_available = photos_dlna_renderers_manager_is_available ();
g_simple_action_set_enabled (G_SIMPLE_ACTION (remote_display_action), remote_display_available);
- g_signal_connect (priv->item_mngr, "active-changed", G_CALLBACK (photos_main_toolbar_item_active_changed),
self);
+ g_signal_connect_swapped (priv->item_mngr,
+ "active-changed",
+ G_CALLBACK (photos_main_toolbar_item_active_changed),
+ self);
}
@@ -633,7 +633,7 @@ photos_main_toolbar_populate_for_search (PhotosMainToolbar *self)
gtk_container_add (GTK_CONTAINER (self), priv->searchbar);
object = photos_base_manager_get_active_object (priv->col_mngr);
- photos_main_toolbar_col_active_changed (priv->col_mngr, object, self);
+ photos_main_toolbar_col_active_changed (self, object);
}
@@ -647,7 +647,10 @@ photos_main_toolbar_populate_for_selection_mode (PhotosMainToolbar *self)
selection_button = gtk_button_new_with_label (_("Cancel"));
gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->toolbar), selection_button);
- g_signal_connect (selection_button, "clicked", G_CALLBACK (photos_main_toolbar_done_button_clicked), self);
+ g_signal_connect_swapped (selection_button,
+ "clicked",
+ G_CALLBACK (photos_main_toolbar_done_button_clicked),
+ self);
g_signal_connect_object (priv->sel_cntrlr,
"selection-changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]