[gnome-boxes] properties: list and show correct pages



commit 693a3b4d75ccce094f8361aa37cd7b3037d5c351
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Mon Oct 29 13:46:39 2012 +0100

    properties: list and show correct pages
    
    The bug is currently visible with remote machine, where the shown page
    doesn't match the selected page.
    
    Since all pages are not inserted, we can't use the row index directly
    to switch notebook page. I chose to use a model filter to solve this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=687111

 src/properties.vala |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/properties.vala b/src/properties.vala
index 6889c57..dba8744 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -19,6 +19,7 @@ private class Boxes.Properties: Boxes.UI {
     private Gtk.Button back;
     private Gtk.Label toolbar_label;
     private Gtk.ListStore listmodel;
+    private Gtk.TreeModelFilter model_filter;
     private Gtk.TreeView tree_view;
     private Gtk.Button shutdown_button;
     private GLib.Binding toolbar_label_bind;
@@ -130,11 +131,12 @@ private class Boxes.Properties: Boxes.UI {
         setup_ui ();
     }
 
-    private void list_append (Gtk.ListStore listmodel, string label) {
+    private void list_append (Gtk.ListStore listmodel, string label, bool visible) {
         Gtk.TreeIter iter;
 
         listmodel.append (out iter);
         listmodel.set (iter, 0, label);
+        listmodel.set (iter, 1, visible);
     }
 
     private void populate () {
@@ -155,8 +157,7 @@ private class Boxes.Properties: Boxes.UI {
             notebook.append_page (page.widget, null);
             notebook.set_data<PageWidget> (@"boxes-property-$i", page);
 
-            if (!page.empty)
-                list_append (listmodel, page.name);
+            list_append (listmodel, page.name, !page.empty);
         }
 
         PropertiesPage current_page;
@@ -213,11 +214,17 @@ private class Boxes.Properties: Boxes.UI {
         selection.set_mode (Gtk.SelectionMode.BROWSE);
         tree_view_activate_on_single_click (tree_view, true);
         tree_view.row_activated.connect ( (treeview, path, column) => {
-            notebook.page = path.get_indices ()[0];
+            Gtk.TreeIter filter_iter, iter;
+            model_filter.get_iter (out filter_iter, path);
+            model_filter.convert_iter_to_child_iter (out iter, filter_iter);
+            notebook.page = listmodel.get_path (iter).get_indices ()[0];
         });
 
-        listmodel = new Gtk.ListStore (1, typeof (string));
-        tree_view.set_model (listmodel);
+        listmodel = new Gtk.ListStore (2, typeof (string), typeof (bool));
+        model_filter = new Gtk.TreeModelFilter (listmodel, null);
+        model_filter.set_visible_column (1);
+
+        tree_view.set_model (model_filter);
         tree_view.headers_visible = false;
         var renderer = new CellRendererText ();
         renderer.xpad = 20;



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