[gnome-photos/wip/foo: 12/13] 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/wip/foo: 12/13] Use g_signal_connect_swapped to simplify the callbacks
- Date: Sat, 30 Mar 2013 15:54:07 +0000 (UTC)
commit 6cebad77f6e689f1bd2b3aaa9d2a14ccac5660e0
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Mar 28 23:56:13 2013 +0100
Use g_signal_connect_swapped to simplify the callbacks
src/photos-application.c | 27 ++++++++-----------
src/photos-organize-collection-view.c | 46 +++++++++++++++------------------
2 files changed, 32 insertions(+), 41 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index b2a751c..ec0a752 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -77,21 +77,19 @@ photos_application_action_toggle (GSimpleAction *simple, GVariant *parameter, gp
static void
-photos_application_can_fullscreen_changed (PhotosModeController *mode_cntrlr, gpointer user_data)
+photos_application_can_fullscreen_changed (PhotosApplication *self)
{
- PhotosApplication *self = PHOTOS_APPLICATION (user_data);
PhotosApplicationPrivate *priv = self->priv;
gboolean can_fullscreen;
- can_fullscreen = photos_mode_controller_get_can_fullscreen (mode_cntrlr);
+ can_fullscreen = photos_mode_controller_get_can_fullscreen (priv->mode_cntrlr);
g_simple_action_set_enabled (priv->fs_action, can_fullscreen);
}
static void
-photos_application_fullscreen (GSimpleAction *simple, GVariant *parameter, gpointer user_data)
+photos_application_fullscreen (PhotosApplication *self, GVariant *parameter)
{
- PhotosApplication *self = PHOTOS_APPLICATION (user_data);
PhotosApplicationPrivate *priv = self->priv;
photos_mode_controller_toggle_fullscreen (priv->mode_cntrlr);
@@ -149,12 +147,9 @@ photos_application_properties (PhotosApplication *self)
static void
-photos_application_quit (GSimpleAction *simple, GVariant *parameter, gpointer user_data)
+photos_application_quit (PhotosApplication *self, GVariant *parameter)
{
- PhotosApplication *self = PHOTOS_APPLICATION (user_data);
- PhotosApplicationPrivate *priv = self->priv;
-
- gtk_widget_destroy (priv->main_window);
+ gtk_widget_destroy (self->priv->main_window);
}
@@ -217,13 +212,13 @@ photos_application_startup (GApplication *application)
g_object_unref (action);
priv->fs_action = g_simple_action_new ("fullscreen", NULL);
- g_signal_connect (priv->fs_action, "activate", G_CALLBACK (photos_application_fullscreen), self);
+ g_signal_connect_swapped (priv->fs_action, "activate", G_CALLBACK (photos_application_fullscreen), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->fs_action));
- g_signal_connect (priv->mode_cntrlr,
- "can-fullscreen-changed",
- G_CALLBACK (photos_application_can_fullscreen_changed),
- self);
+ g_signal_connect_swapped (priv->mode_cntrlr,
+ "can-fullscreen-changed",
+ G_CALLBACK (photos_application_can_fullscreen_changed),
+ self);
state = g_variant_new ("b", FALSE);
priv->gear_action = g_simple_action_new_stateful ("gear-menu", NULL, state);
@@ -243,7 +238,7 @@ photos_application_startup (GApplication *application)
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->properties_action));
action = g_simple_action_new ("quit", NULL);
- g_signal_connect (action, "activate", G_CALLBACK (photos_application_quit), self);
+ g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_application_quit), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
g_object_unref (action);
diff --git a/src/photos-organize-collection-view.c b/src/photos-organize-collection-view.c
index 1e363d3..2af31f0 100644
--- a/src/photos-organize-collection-view.c
+++ b/src/photos-organize-collection-view.c
@@ -69,11 +69,8 @@ photos_organize_collection_view_check_cell (GtkTreeViewColumn *tree_column,
static void
-photos_organize_collection_view_check_toggled (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- gpointer user_data)
+photos_organize_collection_view_check_toggled (PhotosOrganizeCollectionView *self, gchar *path)
{
- PhotosOrganizeCollectionView *self = PHOTOS_ORGANIZE_COLLECTION_VIEW (user_data);
PhotosOrganizeCollectionViewPrivate *priv = self->priv;
GtkTreeIter iter;
GtkTreePath *tree_path;
@@ -181,24 +178,23 @@ photos_organize_collection_view_text_edited_real (PhotosOrganizeCollectionView *
static void
-photos_organize_collection_view_text_edited (GtkCellRendererText *cell_renderer,
- gchar *path,
- gchar *new_text,
- gpointer user_data)
+photos_organize_collection_view_text_edited (PhotosOrganizeCollectionView *self, gchar *path, gchar
*new_text)
{
- PhotosOrganizeCollectionView *self = PHOTOS_ORGANIZE_COLLECTION_VIEW (user_data);
+ PhotosOrganizeCollectionViewPrivate *priv = self->priv;
GtkTreePath *tree_path;
tree_path = gtk_tree_path_new_from_string (path);
- photos_organize_collection_view_text_edited_real (self, cell_renderer, tree_path, new_text);
+ photos_organize_collection_view_text_edited_real (self,
+ GTK_CELL_RENDERER_TEXT (priv->renderer_text),
+ tree_path,
+ new_text);
gtk_tree_path_free (tree_path);
}
static void
-photos_organize_collection_view_text_editing_canceled (GtkCellRenderer *cell_renderer, gpointer user_data)
+photos_organize_collection_view_text_editing_canceled (PhotosOrganizeCollectionView *self)
{
- PhotosOrganizeCollectionView *self = PHOTOS_ORGANIZE_COLLECTION_VIEW (user_data);
PhotosOrganizeCollectionViewPrivate *priv = self->priv;
if (priv->choice_confirmed)
@@ -222,7 +218,7 @@ photos_organize_collection_view_text_editing_canceled (GtkCellRenderer *cell_ren
text = gtk_entry_get_text (GTK_ENTRY (entry));
photos_organize_collection_view_text_edited_real (self,
- GTK_CELL_RENDERER_TEXT (cell_renderer),
+ GTK_CELL_RENDERER_TEXT (priv->renderer_text),
path,
text);
}
@@ -268,22 +264,22 @@ photos_organize_collection_view_init (PhotosOrganizeCollectionView *self)
photos_organize_collection_view_check_cell,
self,
NULL);
- g_signal_connect (priv->renderer_check,
- "toggled",
- G_CALLBACK (photos_organize_collection_view_check_toggled),
- self);
+ g_signal_connect_swapped (priv->renderer_check,
+ "toggled",
+ G_CALLBACK (photos_organize_collection_view_check_toggled),
+ self);
priv->renderer_text = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (priv->view_col, priv->renderer_text, TRUE);
gtk_tree_view_column_add_attribute (priv->view_col, priv->renderer_text, "text",
PHOTOS_ORGANIZE_MODEL_NAME);
- g_signal_connect (priv->renderer_text,
- "edited",
- G_CALLBACK (photos_organize_collection_view_text_edited),
- self);
- g_signal_connect (priv->renderer_text,
- "editing-canceled",
- G_CALLBACK (photos_organize_collection_view_text_editing_canceled),
- self);
+ g_signal_connect_swapped (priv->renderer_text,
+ "edited",
+ G_CALLBACK (photos_organize_collection_view_text_edited),
+ self);
+ g_signal_connect_swapped (priv->renderer_text,
+ "editing-canceled",
+ G_CALLBACK (photos_organize_collection_view_text_editing_canceled),
+ self);
priv->renderer_detail = gd_styled_text_renderer_new ();
gtk_cell_renderer_set_padding (priv->renderer_detail, 16, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]