Disconnect signals from old model
authorEnrico Zini <enrico@enricozini.org>
Wed, 9 Dec 2009 22:25:30 +0000 (22:25 +0000)
committerEnrico Zini <enrico@enricozini.org>
Wed, 9 Dec 2009 22:25:30 +0000 (22:25 +0000)
src/fisheye.vala

index 9b281f6b9865ef722d9e9cc64d06c8acc6e671bc..177a012328977e27ec68f0726ee1eef19f560721 100644 (file)
@@ -102,16 +102,30 @@ public class FisheyeList : Gtk.DrawingArea
        public unowned Gtk.TreeModel get_model() { return model; }
        public void set_model (Gtk.TreeModel? model)
        {
+               if (this.model != null)
+               {
+                       this.model.row_changed -= on_row_changed;
+                       this.model.row_deleted -= on_row_deleted;
+                       this.model.row_has_child_toggled -= on_row_has_child_toggled;
+                       this.model.row_inserted -= on_row_inserted;
+                       this.model.rows_reordered -= on_rows_reordered;
+               }
                this.model = model;
-               this.model.row_changed += (a, b) => { build_label_cache_needed = true; };
-               this.model.row_deleted += (a) => { build_label_cache_needed = true; };
-               this.model.row_has_child_toggled += (a, b) => { build_label_cache_needed = true; };
-               this.model.row_inserted += (a, b) => { build_label_cache_needed = true; };
-               this.model.rows_reordered += (a, b, c) => { build_label_cache_needed = true; };
+               this.model.row_changed += on_row_changed;
+               this.model.row_deleted += on_row_deleted;
+               this.model.row_has_child_toggled += on_row_has_child_toggled;
+               this.model.row_inserted += on_row_inserted;
+               this.model.rows_reordered += on_rows_reordered;
                build_label_cache_needed = true;
                queue_draw();
        }
 
+       private void on_row_changed(Gtk.TreePath path, Gtk.TreeIter iter) { build_label_cache_needed = true; }
+       private void on_row_deleted(Gtk.TreePath path) { build_label_cache_needed = true; }
+       private void on_row_has_child_toggled(Gtk.TreePath path, Gtk.TreeIter iter) { build_label_cache_needed = true; }
+       private void on_row_inserted(Gtk.TreePath path, Gtk.TreeIter iter) { build_label_cache_needed = true; }
+       private void on_rows_reordered(Gtk.TreePath path, Gtk.TreeIter iter, void* new_order) { build_label_cache_needed = true; }
+
        /* Mouse button got pressed over widget */
        public override bool button_press_event(Gdk.EventButton event)
        {