[gnome-games/wip/exalm/savestates: 5/5] savestate-list: Update load action in a separate function



commit 75ad42b68226c12336bd5bdc5aa6f2b02cc8e749
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Jan 27 00:16:51 2020 +0500

    savestate-list: Update load action in a separate function
    
    This will be clearer when we have more actions.

 data/ui/savestates-list.ui  | 1 +
 src/ui/savestates-list.vala | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/savestates-list.ui b/data/ui/savestates-list.ui
index 6d488241..a0e5f843 100644
--- a/data/ui/savestates-list.ui
+++ b/data/ui/savestates-list.ui
@@ -3,6 +3,7 @@
   <requires lib="gtk+" version="3.24"/>
   <template class="GamesSavestatesList" parent="GtkBox">
     <signal name="notify::is-revealed" handler="on_revealed_changed"/>
+    <signal name="notify::selected-savestate" handler="selected_savestate_changed"/>
     <style>
       <class name="background"/>
     </style>
diff --git a/src/ui/savestates-list.vala b/src/ui/savestates-list.vala
index 15e2371e..e507d825 100644
--- a/src/ui/savestates-list.vala
+++ b/src/ui/savestates-list.vala
@@ -252,7 +252,7 @@ private class Games.SavestatesList : Gtk.Box {
                if (row == null) {
                        runner.preview_current_state ();
                        selected_savestate = null;
-                       lookup_action ("load-snapshot").set_enabled (false);
+                       selected_savestate_changed ();
                }
                else {
                        row.grab_focus ();
@@ -270,7 +270,7 @@ private class Games.SavestatesList : Gtk.Box {
 
                        runner.preview_savestate (savestate);
                        selected_savestate = savestate;
-                       lookup_action ("load-snapshot").set_enabled (true);
+                       selected_savestate_changed ();
                }
 
                delete_btn.sensitive = (selected_savestate != null);
@@ -288,4 +288,8 @@ private class Games.SavestatesList : Gtk.Box {
 
                return false;
        }
+
+       private void selected_savestate_changed () {
+               lookup_action ("load-snapshot").set_enabled (selected_savestate != null);
+       }
 }


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