[gnome-games] ui: Add DevelopersView widget
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Add DevelopersView widget
- Date: Fri, 3 Aug 2018 16:35:56 +0000 (UTC)
commit f843b9661ca2768ea039a68ac11f86ff0be0ecf8
Author: 1PunMan <saurabhsingh412 gmail com>
Date: Wed Aug 1 23:16:12 2018 +0530
ui: Add DevelopersView widget
This widget will allow the display of games grouped by the developers
available.
src/meson.build | 1 +
src/ui/developers-view.vala | 50 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
---
diff --git a/src/meson.build b/src/meson.build
index e46f2f4c..62772da6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -128,6 +128,7 @@ vala_sources = [
'ui/collection-icon-view.vala',
'ui/collection-header-bar.vala',
'ui/developer-list-item.vala',
+ 'ui/developers-view.vala',
'ui/display-box.vala',
'ui/display-header-bar.vala',
'ui/dummy-display.vala',
diff --git a/src/ui/developers-view.vala b/src/ui/developers-view.vala
new file mode 100644
index 00000000..454d0109
--- /dev/null
+++ b/src/ui/developers-view.vala
@@ -0,0 +1,50 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private class Games.DevelopersView : SidebarView {
+ private GenericSet<Developer> developers = new GenericSet<Developer> (Developer.hash,
Developer.equal);
+ private ulong developer_changed_id;
+
+ private void invalidate_developer (Developer developer){
+ if (!developers.contains (developer)) {
+ developers.add (developer);
+ var developer_list_item = new DeveloperListItem (developer);
+ list_box.add (developer_list_item);
+ }
+ }
+
+ protected override void game_added (Game game) {
+ var developer = game.get_developer ();
+
+ developer_changed_id = developer.changed.connect ((source) => {
+ invalidate_developer (source);
+ });
+
+ // FIXME: Currently developers are fetched in sync and there is
+ // a need to check non GriloDeveloper objects, update this function
+ // if necessary.
+ if (!(developer is GriloDeveloper)) {
+ if (developers.contains (developer))
+ return;
+
+ developers.add (developer);
+ var listbox_item = new DeveloperListItem (developer);
+ list_box.add (listbox_item);
+ }
+ }
+
+ protected override void invalidate (Gtk.ListBoxRow row_item) {
+ var row = row_item.get_child () as DeveloperListItem;
+ var developer = row.developer;
+ collection_view.filtering_developer = developer;
+ }
+
+ protected override int sort_rows (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
+ var item1 = row1.get_child () as DeveloperListItem;
+ var item2 = row2.get_child () as DeveloperListItem;
+
+ assert (item1 != null);
+ assert (item2 != null);
+
+ return item1.label.collate (item2.label);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]