[gnome-games/wip/exalm/list-rows: 3/3] platform-list-item: Extend ListBoxRow instead of Label



commit 01e3ec8dc8e10cb7629138491e8651086fe43514
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Sep 30 18:33:21 2018 +0500

    platform-list-item: Extend ListBoxRow instead of Label
    
    Pack label into it instead. This is cleaner and allows to be more
    flexible with layout.

 data/ui/platform-list-item.ui  | 16 ++++++++++------
 src/ui/platform-list-item.vala |  7 +++++--
 src/ui/platforms-view.vala     |  6 +++---
 3 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/platform-list-item.ui b/data/ui/platform-list-item.ui
index 3d0d4702..eab73693 100644
--- a/data/ui/platform-list-item.ui
+++ b/data/ui/platform-list-item.ui
@@ -1,10 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GamesPlatformListItem" parent="GtkLabel">
+  <template class="GamesPlatformListItem" parent="GtkListBoxRow">
     <property name="visible">true</property>
-    <property name="vexpand">true</property>
-    <property name="margin">6</property>
-    <property name="wrap">true</property>
-    <property name="xalign">0</property>
+    <child>
+      <object class="GtkLabel" id="label">
+        <property name="visible">true</property>
+        <property name="margin">6</property>
+        <property name="wrap">true</property>
+        <property name="xalign">0</property>
+      </object>
+    </child>
   </template>
-</interface>
\ No newline at end of file
+</interface>
diff --git a/src/ui/platform-list-item.vala b/src/ui/platform-list-item.vala
index 3acb9a43..98ce6f48 100644
--- a/src/ui/platform-list-item.vala
+++ b/src/ui/platform-list-item.vala
@@ -1,11 +1,14 @@
 [GtkTemplate (ui = "/org/gnome/Games/ui/platform-list-item.ui")]
-private class Games.PlatformListItem: Gtk.Label {
+private class Games.PlatformListItem: Gtk.ListBoxRow {
+       [GtkChild]
+       private Gtk.Label label;
+
        private Platform _platform;
        public Platform platform {
                get { return _platform; }
                set {
                        _platform = value;
-                       label = value.get_name ();
+                       label.label = value.get_name ();
                }
        }
 
diff --git a/src/ui/platforms-view.vala b/src/ui/platforms-view.vala
index 3c0c243b..ba071fc8 100644
--- a/src/ui/platforms-view.vala
+++ b/src/ui/platforms-view.vala
@@ -14,14 +14,14 @@ private class Games.PlatformsView : SidebarView {
        }
 
        protected override void invalidate (Gtk.ListBoxRow row_item) {
-               var row = row_item.get_child () as PlatformListItem;
+               var row = row_item as PlatformListItem;
                var platform = row.platform;
                collection_view.filtering_platform = platform;
        }
 
        protected override int sort_rows (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
-               var item1 = row1.get_child () as PlatformListItem;
-               var item2 = row2.get_child () as PlatformListItem;
+               var item1 = row1 as PlatformListItem;
+               var item2 = row2 as PlatformListItem;
 
                return PlatformListItem.compare (item1, item2);
        }


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