[gnome-games] savestates-list: Move Delete button to an actionbar



commit c1b1a146c7fbb5b9ef29df37bc2d272013d5a74c
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Aug 11 00:03:42 2019 +0500

    savestates-list: Move Delete button to an actionbar
    
    It makes more sense for it to be there, since there will be a Rename
    button there too. Additionally, it's more compact in mobile mode.

 data/ui/display-header-bar.ui  | 20 ----------
 data/ui/savestates-list.ui     | 87 +++++++++++++++++++++++++++---------------
 src/ui/display-header-bar.vala |  8 ----
 src/ui/savestates-list.vala    |  5 +++
 4 files changed, 61 insertions(+), 59 deletions(-)
---
diff --git a/data/ui/display-header-bar.ui b/data/ui/display-header-bar.ui
index 668b6519..0eb6de8b 100644
--- a/data/ui/display-header-bar.ui
+++ b/data/ui/display-header-bar.ui
@@ -149,19 +149,6 @@
             <property name="pack-type">end</property>
           </packing>
         </child>
-        <child>
-          <object class="GtkButton" id="savestates_delete_btn">
-            <property name="sensitive">False</property>
-            <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="use-underline">True</property>
-            <property name="label" translatable="yes">_Delete</property>
-            <signal name="clicked" handler="on_savestates_delete_clicked"/>
-          </object>
-          <packing>
-            <property name="pack-type">end</property>
-          </packing>
-        </child>
         <child>
           <object class="GtkButton" id="savestates_back">
             <property name="visible">True</property>
@@ -207,11 +194,4 @@
       </object>
     </child>
   </object>
-  <object class="GtkSizeGroup">
-    <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
-    <widgets>
-      <widget name="savestates_load_btn"/>
-      <widget name="savestates_delete_btn"/>
-    </widgets>
-  </object>
 </interface>
diff --git a/data/ui/savestates-list.ui b/data/ui/savestates-list.ui
index 99b2d183..850e77af 100644
--- a/data/ui/savestates-list.ui
+++ b/data/ui/savestates-list.ui
@@ -19,54 +19,79 @@
               </object>
             </child>
             <child>
-              <object class="GtkScrolledWindow" id="scrolled_window">
+              <object class="GtkBox">
                 <property name="visible">True</property>
-                <property name="vexpand">True</property>
-                <property name="width-request">350</property>
+                <property name="orientation">vertical</property>
                 <child>
-                  <object class="GtkListBox" id="list_box">
+                  <object class="GtkScrolledWindow" id="scrolled_window">
                     <property name="visible">True</property>
-                    <signal name="row-activated" after="yes" handler="on_row_activated"/>
-                    <style>
-                      <class name="sidebar"/>
-                    </style>
+                    <property name="vexpand">True</property>
+                    <property name="width-request">350</property>
                     <child>
-                      <object class="GtkListBoxRow" id="new_savestate_row">
+                      <object class="GtkListBox" id="list_box">
                         <property name="visible">True</property>
+                        <signal name="row-activated" after="yes" handler="on_row_activated"/>
                         <style>
-                          <class name="savestate-row"/>
+                          <class name="sidebar"/>
                         </style>
                         <child>
-                          <object class="GtkBox">
+                          <object class="GtkListBoxRow" id="new_savestate_row">
                             <property name="visible">True</property>
+                            <style>
+                              <class name="savestate-row"/>
+                            </style>
                             <child>
-                              <object class="GtkImage">
+                              <object class="GtkBox">
                                 <property name="visible">True</property>
-                                <property name="icon-name">list-add-symbolic</property>
-                                <property name="pixel-size">32</property>
-                                <style>
-                                  <class name="savestate-thumbnail"/>
-                                </style>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkLabel">
-                                <property name="visible">True</property>
-                                <property name="margin">12</property>
-                                <property name="label">Create new savestate</property>
-                                <attributes>
-                                  <!-- "1.2" is the value of "large" -->
-                                  <attribute name="scale" value="1.2"/>
-                                </attributes>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="visible">True</property>
+                                    <property name="icon-name">list-add-symbolic</property>
+                                    <property name="pixel-size">32</property>
+                                    <style>
+                                      <class name="savestate-thumbnail"/>
+                                    </style>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="margin">12</property>
+                                    <property name="label">Create new savestate</property>
+                                    <attributes>
+                                      <!-- "1.2" is the value of "large" -->
+                                      <attribute name="scale" value="1.2"/>
+                                    </attributes>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>
                         </child>
+                        <style>
+                          <class name="savestates-list"/>
+                        </style>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkActionBar">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkButton" id="delete_btn">
+                        <property name="visible">True</property>
+                        <property name="use-underline">True</property>
+                        <property name="label" translatable="yes">_Delete</property>
+                        <signal name="clicked" handler="on_delete_clicked"/>
+                        <style>
+                          <class name="destructive-action"/>
+                        </style>
                       </object>
+                      <packing>
+                        <property name="pack-type">end</property>
+                      </packing>
                     </child>
-                    <style>
-                      <class name="savestates-list"/>
-                    </style>
                   </object>
                 </child>
               </object>
diff --git a/src/ui/display-header-bar.vala b/src/ui/display-header-bar.vala
index 46db0263..7b82972e 100644
--- a/src/ui/display-header-bar.vala
+++ b/src/ui/display-header-bar.vala
@@ -86,8 +86,6 @@ private class Games.DisplayHeaderBar : Gtk.Stack {
        private Gtk.HeaderBar savestates_header_bar;
        [GtkChild]
        private Gtk.Button savestates_load_btn;
-       [GtkChild]
-       private Gtk.Button savestates_delete_btn;
 
        private Settings settings;
 
@@ -136,11 +134,6 @@ private class Games.DisplayHeaderBar : Gtk.Stack {
                savestates_list_state.load_clicked ();
        }
 
-       [GtkCallback]
-       private void on_savestates_delete_clicked () {
-               savestates_list_state.delete_clicked ();
-       }
-
        [GtkCallback]
        private void on_savestates_back_clicked () {
                runner.preview_current_state ();
@@ -156,6 +149,5 @@ private class Games.DisplayHeaderBar : Gtk.Stack {
 
        private void on_selected_savestate_changed () {
                savestates_load_btn.sensitive = (savestates_list_state.selected_savestate != null);
-               savestates_delete_btn.sensitive = (savestates_list_state.selected_savestate != null);
        }
 }
diff --git a/src/ui/savestates-list.vala b/src/ui/savestates-list.vala
index f88787ef..9229fa95 100644
--- a/src/ui/savestates-list.vala
+++ b/src/ui/savestates-list.vala
@@ -10,6 +10,8 @@ private class Games.SavestatesList : Gtk.Box {
        private Gtk.ListBoxRow new_savestate_row;
        [GtkChild]
        private Gtk.ScrolledWindow scrolled_window;
+       [GtkChild]
+       private Gtk.Button delete_btn;
 
        private SavestatesListState _state;
        public SavestatesListState state {
@@ -124,6 +126,7 @@ private class Games.SavestatesList : Gtk.Box {
                state.on_revealer_transition_end ();
        }
 
+       [GtkCallback]
        private void on_delete_clicked () {
                var selected_row = list_box.get_selected_row ();
                var selected_row_index = selected_row.get_index ();
@@ -177,5 +180,7 @@ private class Games.SavestatesList : Gtk.Box {
                        runner.preview_savestate (savestate);
                        state.selected_savestate = savestate;
                }
+
+               delete_btn.sensitive = (state.selected_savestate != null);
        }
 }


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