[gnome-games/wip/exalm/list-rows: 2/3] platform-list-item: Add compare() function



commit 7dd8094e062cc226b533639bd6d48e760c4e2cf2
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Sep 30 18:31:55 2018 +0500

    platform-list-item: Add compare() function
    
    This allows to avoid accessing 'label' property from outside.

 src/ui/platform-list-item.vala | 4 ++++
 src/ui/platforms-view.vala     | 5 +----
 2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/ui/platform-list-item.vala b/src/ui/platform-list-item.vala
index 9e0e5510..3acb9a43 100644
--- a/src/ui/platform-list-item.vala
+++ b/src/ui/platform-list-item.vala
@@ -12,4 +12,8 @@ private class Games.PlatformListItem: Gtk.Label {
        public PlatformListItem (Platform platform) {
                Object (platform : platform);
        }
+
+       public static int compare (PlatformListItem a, PlatformListItem b) {
+               return a.platform.get_name ().collate (b.platform.get_name ());
+       }
 }
diff --git a/src/ui/platforms-view.vala b/src/ui/platforms-view.vala
index 684defc5..3c0c243b 100644
--- a/src/ui/platforms-view.vala
+++ b/src/ui/platforms-view.vala
@@ -23,9 +23,6 @@ private class Games.PlatformsView : SidebarView {
                var item1 = row1.get_child () as PlatformListItem;
                var item2 = row2.get_child () as PlatformListItem;
 
-               assert (item1 != null);
-               assert (item2 != null);
-
-               return item1.label.collate (item2.label);
+               return PlatformListItem.compare (item1, item2);
        }
 }


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