[gnome-photos/wip/rishi/collection: 3/23] application: Simplify code



commit c56571c55a3585bc94e46291fc4aeb96b32d33cc
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 16 16:42:51 2018 +0100

    application: Simplify code
    
    Since GLib 2.40.0, boolean-typed stateful GSimpleActions will
    automatically toggle their states when activated, if there are no
    handlers connected to GSimpleAction::activate.

 src/photos-application.c | 19 -------------------
 1 file changed, 19 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 05fb7195..37339d39 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -294,22 +294,6 @@ photos_application_about (PhotosApplication *self)
 }
 
 
-static void
-photos_application_action_toggle (GSimpleAction *simple, GVariant *parameter, gpointer user_data)
-{
-  g_autoptr (GVariant) state = NULL;
-  GVariant *new_state;
-  gboolean state_value;
-
-  state = g_action_get_state (G_ACTION (simple));
-  g_return_if_fail (state != NULL);
-
-  state_value = g_variant_get_boolean (state);
-  new_state = g_variant_new ("b", !state_value);
-  g_action_change_state (G_ACTION (simple), new_state);
-}
-
-
 static PhotosBaseItem *
 photos_application_get_selection_or_active_item (PhotosApplication *self)
 {
@@ -1965,7 +1949,6 @@ photos_application_startup (GApplication *application)
 
   state = g_variant_new ("b", FALSE);
   self->gear_action = g_simple_action_new_stateful ("gear-menu", NULL, state);
-  g_signal_connect (self->gear_action, "activate", G_CALLBACK (photos_application_action_toggle), self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->gear_action));
 
   self->insta_action = g_simple_action_new ("insta-current", G_VARIANT_TYPE_INT16);
@@ -2014,7 +1997,6 @@ photos_application_startup (GApplication *application)
 
   state = g_variant_new ("b", FALSE);
   self->search_action = g_simple_action_new_stateful ("search", NULL, state);
-  g_signal_connect (self->search_action, "activate", G_CALLBACK (photos_application_action_toggle), self);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->search_action));
 
   state = g_variant_new ("s", PHOTOS_SEARCH_MATCH_STOCK_ALL);
@@ -2037,7 +2019,6 @@ photos_application_startup (GApplication *application)
 
   state = g_variant_new ("b", FALSE);
   self->selection_mode_action = g_simple_action_new_stateful ("selection-mode", NULL, state);
-  g_signal_connect (self->selection_mode_action, "activate", G_CALLBACK (photos_application_action_toggle), 
self);
   g_signal_connect_swapped (self->selection_mode_action,
                             "notify::state",
                             G_CALLBACK (photos_application_selection_mode_notify_state),


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