[shotwell] Use change_state to set initial action state



commit 368c897bb6ddced1e120ec74765390ae803361f1
Author: Jens Georg <mail jensge org>
Date:   Wed Nov 23 23:14:36 2016 +0100

    Use change_state to set initial action state
    
    Signed-off-by: Jens Georg <mail jensge org>

 src/MediaPage.vala                  |   21 ++++++++++-----------
 src/PhotoPage.vala                  |    4 ++--
 src/SearchFilter.vala               |    6 +++---
 src/camera/ImportPage.vala          |    2 +-
 src/events/EventsDirectoryPage.vala |    4 ++--
 5 files changed, 18 insertions(+), 19 deletions(-)
---
diff --git a/src/MediaPage.vala b/src/MediaPage.vala
index c9b23b8..4809933 100644
--- a/src/MediaPage.vala
+++ b/src/MediaPage.vala
@@ -329,15 +329,15 @@ public abstract class MediaPage : CheckerboardPage {
         get_config_photos_sort(out sort_order, out sort_by);
 
         AppWindow.get_instance ().add_action_entries (entries, this);
-        (get_action ("ViewTitle") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_titles ());
-        (get_action ("ViewComment") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_comments ());
-        (get_action ("ViewRatings") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_ratings ());
-        (get_action ("ViewTags") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_tags ());
-        (get_action ("SortBy") as GLib.SimpleAction).set_state ("%d".printf (sort_by));
-        (get_action ("Sort") as GLib.SimpleAction).set_state (sort_order ? "'ascending'" : "'descending'");
+        get_action ("ViewTitle").change_state (Config.Facade.get_instance ().get_display_photo_titles ());
+        get_action ("ViewComment").change_state (Config.Facade.get_instance ().get_display_photo_comments 
());
+        get_action ("ViewRatings").change_state (Config.Facade.get_instance ().get_display_photo_ratings ());
+        get_action ("ViewTags").change_state (Config.Facade.get_instance ().get_display_photo_tags ());
+        get_action ("SortBy").change_state ("%d".printf (sort_by));
+        get_action ("Sort").change_state (sort_order ? "'ascending'" : "'descending'");
+
         var d = Config.Facade.get_instance().get_default_raw_developer();
-        var action = get_action ("RawDeveloper") as GLib.SimpleAction;
-        action.set_state (d == RawDeveloper.SHOTWELL ? "'Shotwell'" : "'Camera'");
+        get_action ("RawDeveloper").change_state (d == RawDeveloper.SHOTWELL ? "'Shotwell'" : "'Camera'");
     }
     
     protected override void update_actions(int selected_count, int count) {
@@ -979,7 +979,7 @@ public abstract class MediaPage : CheckerboardPage {
     
     protected void set_menu_sort_by(int val) {
         var sort = "%d".printf (val);
-        (sort_by_title_action() as GLib.SimpleAction).set_state (sort);
+        sort_by_title_action().change_state (sort);
     }
     
     protected bool get_menu_sort_order() {
@@ -988,8 +988,7 @@ public abstract class MediaPage : CheckerboardPage {
     }
     
     protected void set_menu_sort_order(bool ascending) {
-        (sort_ascending_action() as GLib.SimpleAction).set_state (
-            ascending ? "'ascending'" : "'descending'");
+        sort_ascending_action().change_state (ascending ? "'ascending'" : "'descending'");
     }
     
     void set_view_comparator(int sort_by, bool ascending) {
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 3ad2076..a654987 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -2438,10 +2438,10 @@ public class LibraryPhotoPage : EditingHostPage {
         base.add_actions ();
 
         AppWindow.get_instance ().add_action_entries (entries, this);
-        (get_action ("ViewRatings") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_ratings ());
+        (get_action ("ViewRatings") as GLib.SimpleAction).change_state (Config.Facade.get_instance 
().get_display_photo_ratings ());
         var d = Config.Facade.get_instance().get_default_raw_developer();
         var action = get_action ("RawDeveloper") as GLib.SimpleAction;
-        action.set_state (d == RawDeveloper.SHOTWELL ? "'Shotwell'" : "'Camera'");
+        action.change_state (d == RawDeveloper.SHOTWELL ? "'Shotwell'" : "'Camera'");
     }
 
     protected override InjectionGroup[] init_collect_injection_groups() {
diff --git a/src/SearchFilter.vala b/src/SearchFilter.vala
index a080884..9059748 100644
--- a/src/SearchFilter.vala
+++ b/src/SearchFilter.vala
@@ -441,7 +441,7 @@ public class SearchFilterActions {
         raw.set_enabled (false);
         videos.set_enabled (false);
         Variant v = "'%d'".printf (RatingFilter.UNRATED_OR_HIGHER);
-        rating.set_state (v);
+        rating.change_state (v);
 
         text.set_text(null);
     }
@@ -1212,7 +1212,7 @@ public class SearchFilterToolbar : Gtk.Revealer {
         // Could we find the appropriate action?
         if(action != null) {
             // Yes, hide the search bar.
-            action.set_state(false);
+            action.change_state(false);
         }
     }
     
@@ -1247,7 +1247,7 @@ public class SearchFilterToolbar : Gtk.Revealer {
 
         // Could we find the appropriate action?
         if(action != null) {
-            action.set_state(true);
+            action.change_state(true);
         }
 
         update();
diff --git a/src/camera/ImportPage.vala b/src/camera/ImportPage.vala
index 352bba6..0552d86 100644
--- a/src/camera/ImportPage.vala
+++ b/src/camera/ImportPage.vala
@@ -877,7 +877,7 @@ public class ImportPage : CheckerboardPage {
 
         AppWindow.get_instance ().add_action_entries (entries, this);
 
-        (get_action ("ViewTitle") as GLib.SimpleAction).set_state (Config.Facade.get_instance 
().get_display_photo_titles ());
+        get_action ("ViewTitle").change_state (Config.Facade.get_instance ().get_display_photo_titles ());
     }
     
     public GPhoto.Camera get_camera() {
diff --git a/src/events/EventsDirectoryPage.vala b/src/events/EventsDirectoryPage.vala
index 46fabe3..850f0ce 100644
--- a/src/events/EventsDirectoryPage.vala
+++ b/src/events/EventsDirectoryPage.vala
@@ -118,8 +118,8 @@ public abstract class EventsDirectoryPage : CheckerboardPage {
         base.add_actions ();
         AppWindow.get_instance ().add_action_entries (entries, this);
 
-        (get_action ("ViewComment") as GLib.SimpleAction).set_state
-            (Config.Facade.get_instance().get_display_event_comments());
+        var display_comments = Config.Facade.get_instance().get_display_event_comments()
+        get_action ("ViewComment").change_state (display_comments);
     }
 
     protected override void init_actions(int selected_count, int count) {


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