[gnome-games/wip/exalm/platform-preferences: 23/28] preferences-sidebar: Add header function



commit 3e6da63fb0d563c4c7da60e914459b12424d0b9c
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Sep 25 19:49:02 2018 +0500

    preferences-sidebar: Add header function
    
    Add separators between rows with different categories.

 src/ui/preferences-sidebar.vala | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/src/ui/preferences-sidebar.vala b/src/ui/preferences-sidebar.vala
index 6298a829..73982e33 100644
--- a/src/ui/preferences-sidebar.vala
+++ b/src/ui/preferences-sidebar.vala
@@ -56,6 +56,28 @@ private class Games.PreferencesSidebar: Gtk.Bin {
        construct {
                rows = new HashTable<PreferencesPage, PreferencesSidebarItem> (null, null);
                show_selection = true;
+
+               list.set_header_func (update_header);
+       }
+
+       void update_header (Gtk.ListBoxRow row, Gtk.ListBoxRow? before) {
+               if (before == null)
+                       return;
+
+               var item1 = row as PreferencesSidebarItem;
+               var item2 = before as PreferencesSidebarItem;
+
+               var page1 = item1.preferences_page;
+               var page2 = item2.preferences_page;
+
+               if (page1.category != page2.category) {
+                       var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
+                       separator.set_margin_top (4);
+                       separator.set_margin_bottom (4);
+                       separator.get_style_context ().add_class ("sidebar");
+
+                       row.set_header (separator);
+               }
        }
 
        [GtkCallback]


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