[gnome-boxes] snapshot-list-row: Remove redundant revealer



commit 62d8c14c7603e35d207dd3c1d310355024c79466
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Oct 28 20:29:13 2014 +0000

    snapshot-list-row: Remove redundant revealer
    
    There is no need to use a revealer to allow for undoing deletion of
    snapshots. Instead we can just remove the snapshot row from the view and
    if user clicks undo button, we can simply add it back in.

 data/ui/snapshot-list-row.ui |  117 +++++++++++++++++++----------------------
 src/snapshot-list-row.vala   |   27 ++--------
 src/snapshots-property.vala  |    2 -
 3 files changed, 59 insertions(+), 87 deletions(-)
---
diff --git a/data/ui/snapshot-list-row.ui b/data/ui/snapshot-list-row.ui
index f20ee62..a94fb97 100644
--- a/data/ui/snapshot-list-row.ui
+++ b/data/ui/snapshot-list-row.ui
@@ -22,83 +22,45 @@
   <template class="BoxesSnapshotListRow" parent="GtkListBoxRow">
     <property name="visible">True</property>
     <property name="can_focus">True</property>
+
     <child>
-      <object class="GtkRevealer" id="delete_revealer">
+      <object class="GtkStack" id="mode_stack">
         <property name="visible">true</property>
         <property name="can_focus">false</property>
-        <property name="reveal_child">true</property>
-
+        <property name="transition_type">slide-up-down</property>
         <child>
-          <object class="GtkStack" id="mode_stack">
-            <property name="visible">true</property>
-            <property name="can_focus">false</property>
-            <property name="transition_type">slide-up-down</property>
+          <object class="GtkBox" id="show_name_box">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <child>
-              <object class="GtkBox" id="show_name_box">
+              <object class="GtkLabel" id="name_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkLabel" id="name_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                    <property name="halign">start</property>
-                    <property name="valign">center</property>
-                    <property name="margin_start">45</property>
-                    <property name="ellipsize">end</property>
-                    <property name="xalign">0</property>
-                  </object>
-                </child>
-
-                <child>
-                  <object class="GtkMenuButton" id="more_button">
-                    <property name="visible">true</property>
-                    <property name="menu_model">actions_menu</property>
-                    <property name="valign">center</property>
-                    <property name="margin_top">4</property>
-                    <property name="margin_bottom">4</property>
-                    <property name="margin_end">4</property>
-                    <style>
-                      <class name="image-button" />
-                    </style>
-                    <child>
-                      <object class="GtkImage">
-                        <property name="visible">true</property>
-                        <property name="icon-name">emblem-system-symbolic</property>
-                      </object>
-                    </child>
-                  </object>
-                </child>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="halign">start</property>
+                <property name="valign">center</property>
+                <property name="margin_start">45</property>
+                <property name="ellipsize">end</property>
+                <property name="xalign">0</property>
               </object>
             </child>
 
             <child>
-              <object class="GtkBox" id="edit_name_box">
+              <object class="GtkMenuButton" id="more_button">
                 <property name="visible">true</property>
-                <property name="orientation">horizontal</property>
-                <property name="can_focus">false</property>
-                <child>
-                  <object class="GtkEntry" id="name_entry">
-                    <property name="visible">true</property>
-                    <property name="can_focus">true</property>
-                    <property name="margin_start">45</property>
-                    <property name="hexpand">true</property>
-                    <signal name="activate" handler="on_save_name_button_clicked" />
-                  </object>
-                </child>
-
+                <property name="menu_model">actions_menu</property>
+                <property name="valign">center</property>
+                <property name="margin_top">4</property>
+                <property name="margin_bottom">4</property>
+                <property name="margin_end">4</property>
+                <style>
+                  <class name="image-button" />
+                </style>
                 <child>
-                  <object class="GtkButton" id="save_name_button">
-                    <property name="can_focus">true</property>
+                  <object class="GtkImage">
                     <property name="visible">true</property>
-                    <property name="margin_start">10</property>
-                    <property name="valign">center</property>
-                    <property name="label" translatable="yes">Done</property>
-                    <signal name="clicked" handler="on_save_name_button_clicked" />
-                    <style>
-                      <class name="text-button" />
-                    </style>
+                    <property name="icon-name">emblem-system-symbolic</property>
                   </object>
                 </child>
               </object>
@@ -106,7 +68,36 @@
           </object>
         </child>
 
+        <child>
+          <object class="GtkBox" id="edit_name_box">
+            <property name="visible">true</property>
+            <property name="orientation">horizontal</property>
+            <property name="can_focus">false</property>
+            <child>
+              <object class="GtkEntry" id="name_entry">
+                <property name="visible">true</property>
+                <property name="can_focus">true</property>
+                <property name="margin_start">45</property>
+                <property name="hexpand">true</property>
+                <signal name="activate" handler="on_save_name_button_clicked" />
+              </object>
+            </child>
 
+            <child>
+              <object class="GtkButton" id="save_name_button">
+                <property name="can_focus">true</property>
+                <property name="visible">true</property>
+                <property name="margin_start">10</property>
+                <property name="valign">center</property>
+                <property name="label" translatable="yes">Done</property>
+                <signal name="clicked" handler="on_save_name_button_clicked" />
+                <style>
+                  <class name="text-button" />
+                </style>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
     </child>
   </template>
diff --git a/src/snapshot-list-row.vala b/src/snapshot-list-row.vala
index 3f9342b..be76f58 100644
--- a/src/snapshot-list-row.vala
+++ b/src/snapshot-list-row.vala
@@ -6,8 +6,6 @@ private class Boxes.SnapshotListRow : Gtk.ListBoxRow {
     public string activity_message { get; set; default = ""; }
 
     [GtkChild]
-    private Gtk.Revealer delete_revealer;
-    [GtkChild]
     private Gtk.Label name_label;
     [GtkChild]
     private Gtk.Stack mode_stack;
@@ -63,14 +61,6 @@ private class Boxes.SnapshotListRow : Gtk.ListBoxRow {
         var action_group = new GLib.SimpleActionGroup ();
         action_group.add_action_entries (action_entries, this);
         this.insert_action_group ("snap", action_group);
-
-        delete_revealer.notify["child-revealed"].connect (() => {
-            if (!delete_revealer.child_revealed) {
-                parent_container = (Gtk.Container) this.get_parent ();
-                if (parent_container != null)
-                    parent_container.remove (this);
-            }
-        });
     }
 
     // Need to override this in order to connect the indicators without any gaps.
@@ -178,12 +168,13 @@ private class Boxes.SnapshotListRow : Gtk.ListBoxRow {
                       e.message);
         }
         var message = _("Snapshot \"%s\" deleted.").printf (snapshot_identifier);
-        delete_revealer.reveal_child = false;
+        parent_container = (Gtk.Container) this.get_parent ();
+        var row = this;
+        parent_container.remove (this);
 
         Notification.OKFunc undo = () => {
             parent_container.add (this);
-            this.visible = true;
-            delete_revealer.reveal_child = true;
+            row = null;
         };
 
         Notification.CancelFunc really_remove = () => {
@@ -195,6 +186,7 @@ private class Boxes.SnapshotListRow : Gtk.ListBoxRow {
                     warning ("Error while deleting snapshot %s: %s", snapshot.get_name (), e.message);
                 }
             });
+            row = null;
         };
         machine.window.notificationbar.display_for_action (message,
                                                            _("_Undo"),
@@ -208,15 +200,6 @@ private class Boxes.SnapshotListRow : Gtk.ListBoxRow {
         name_entry.grab_focus ();
     }
 
-    public void unreveal () {
-        delete_revealer.reveal_child = false;
-    }
-
-    public void reveal () {
-        delete_revealer.reveal_child = true;
-    }
-
-
     private void update_index () {
         var parent = this.get_parent ();
 
diff --git a/src/snapshots-property.vala b/src/snapshots-property.vala
index 714f749..584d503 100644
--- a/src/snapshots-property.vala
+++ b/src/snapshots-property.vala
@@ -106,9 +106,7 @@ private class Boxes.SnapshotsProperty : Boxes.Property {
             var new_snapshot = yield machine.properties.create_snapshot ();
             var new_row = new SnapshotListRow (new_snapshot, machine);
             new_row.notify["activity-message"].connect (row_activity_changed);
-            new_row.unreveal ();
             snapshot_list.add (new_row);
-            new_row.reveal ();
         } catch (GLib.Error e) {
             var msg = _("Failed to create snapshot of %s").printf (machine.name);
             machine.window.notificationbar.display_error (msg);


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