[gnome-games/wip/exalm/libhandy2: 8/12] preferences-sidebar: Add 'show-selection' property



commit 3bbc674b90617e03e6f96af47985b3df6db436ff
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Oct 21 19:28:24 2018 +0500

    preferences-sidebar: Add 'show-selection' property
    
    This property allows not to mark selected item in any way.
    
    This will be used in the next commits for folded mode.

 src/ui/preferences-sidebar.vala | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/src/ui/preferences-sidebar.vala b/src/ui/preferences-sidebar.vala
index 778ed95b..577c6a92 100644
--- a/src/ui/preferences-sidebar.vala
+++ b/src/ui/preferences-sidebar.vala
@@ -27,6 +27,22 @@ private class Games.PreferencesSidebar: Gtk.Bin {
                }
        }
 
+       private bool _show_selection;
+       public bool show_selection {
+               get { return _show_selection; }
+               set {
+                       _show_selection = value;
+
+                       if (_show_selection)
+                               list.selection_mode = Gtk.SelectionMode.SINGLE;
+                       else
+                               list.selection_mode = Gtk.SelectionMode.NONE;
+
+                       if (stack != null)
+                               select_current_row ();
+               }
+       }
+
        public signal void row_selected ();
 
        [GtkChild]
@@ -40,6 +56,7 @@ private class Games.PreferencesSidebar: Gtk.Bin {
        construct {
                rows = new HashTable<PreferencesPage, PreferencesSidebarItem> (null, null);
                list.set_header_func (update_header);
+               show_selection = true;
        }
 
        [GtkCallback]
@@ -79,6 +96,9 @@ private class Games.PreferencesSidebar: Gtk.Bin {
        }
 
        private void select_current_row () {
+               if (!show_selection)
+                       return;
+
                var page = stack.visible_child as PreferencesPage;
 
                var row = rows[page];


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