[gnome-boxes] selectionbar: Fix selection bug on favorites



commit 18e91d9b39f17a16b8e1d3c4a7e4c3eff650be3a
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Wed Aug 28 23:04:37 2013 +0800

    selectionbar: Fix selection bug on favorites
    
    Selecting a machine not in favorites, while there is a machine that is
    in favorites and selected, adds all selected items to favorites. This
    happens because the active property is changed during the check for
    selection, emitting a "clicked" signal.
    
    This patch will block the "clicked" handler for favorite button while
    changing this property.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707076

 src/selectionbar.vala |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/selectionbar.vala b/src/selectionbar.vala
index 61e51ba..6c6af72 100644
--- a/src/selectionbar.vala
+++ b/src/selectionbar.vala
@@ -8,6 +8,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
     private Gtk.Button pause_btn;
     private Gtk.Button remove_btn;
     private Gtk.Button properties_btn;
+    private ulong favorite_btn_clicked_handler;
 
     public Selectionbar () {
         transition_type = Gtk.RevealerTransitionType.SLIDE_UP;
@@ -19,7 +20,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
         headerbar.pack_start (favorite_btn);
         favorite_btn.image = new Gtk.Image.from_icon_name ("emblem-favorite-symbolic", Gtk.IconSize.MENU);
         favorite_btn.get_style_context ().add_class ("image-button");
-        favorite_btn.clicked.connect (() => {
+        favorite_btn_clicked_handler = favorite_btn.clicked.connect (() => {
            foreach (var item in App.app.selected_items) {
                var machine = item as Machine;
                if (machine == null)
@@ -97,8 +98,12 @@ private class Boxes.Selectionbar: Gtk.Revealer {
             }
         }
 
+        // Block the handler so that the selected items won't get added to the
+        // "favorite" category while changing the status of the button.
+        SignalHandler.block (favorite_btn, favorite_btn_clicked_handler);
         favorite_btn.active = active;
         favorite_btn.sensitive = sensitive;
+        SignalHandler.unblock (favorite_btn, favorite_btn_clicked_handler);
     }
 
     private void update_properties_btn () {


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