[gnome-games/wip/exalm/tnum: 21/24] collection: Make title public property of Collection
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/tnum: 21/24] collection: Make title public property of Collection
- Date: Wed, 19 Aug 2020 18:22:24 +0000 (UTC)
commit 981ed6b06746684ac10119e602003c28fbc200f3
Author: Neville <nevilleantony98 gmail com>
Date: Wed Aug 12 19:47:36 2020 +0530
collection: Make title public property of Collection
src/collection/collection-manager.vala | 2 +-
src/collection/collection.vala | 10 +++++-----
src/collection/dummy-add-collection.vala | 8 ++++----
src/collection/favorites-collection.vala | 8 ++++----
src/collection/recently-played-collection.vala | 8 ++++----
src/collection/user-collection.vala | 18 ++++++++++--------
src/database/database.vala | 14 +++++++-------
src/ui/collection-icon-view.vala | 2 +-
src/ui/collection-list-item.vala | 2 +-
src/ui/collections-page.vala | 4 ++--
10 files changed, 39 insertions(+), 37 deletions(-)
---
diff --git a/src/collection/collection-manager.vala b/src/collection/collection-manager.vala
index 15c776306..410f8b8f7 100644
--- a/src/collection/collection-manager.vala
+++ b/src/collection/collection-manager.vala
@@ -85,7 +85,7 @@ private class Games.CollectionManager : Object {
public bool does_collection_title_exist (string title) {
foreach (var collection in collections.get_values ())
- if (collection.get_title () == title)
+ if (collection.title == title)
return true;
return false;
diff --git a/src/collection/collection.vala b/src/collection/collection.vala
index 42df3cf76..ba9ffa64d 100644
--- a/src/collection/collection.vala
+++ b/src/collection/collection.vala
@@ -12,12 +12,12 @@ private interface Games.Collection : Object {
public abstract bool is_empty { get; }
+ public abstract string title { get; }
+
public abstract void load ();
public abstract string get_id ();
- public abstract string get_title ();
-
public abstract bool get_hide_stars ();
public abstract GameModel get_game_model ();
@@ -35,7 +35,7 @@ private interface Games.Collection : Object {
public abstract void on_game_replaced (Game game, Game prev_game);
public bool matches_search_terms (string[] search_terms) {
- var name = get_title ();
+ var name = title;
if (search_terms.length != 0)
foreach (var term in search_terms)
if (!(term.casefold () in name.casefold ()))
@@ -56,8 +56,8 @@ private interface Games.Collection : Object {
}
public static int compare (Collection a, Collection b) {
- var title_a = a.get_title ();
- var title_b = b.get_title ();
+ var title_a = a.title;
+ var title_b = b.title;
var type_a = a.get_collection_type ();
var type_b = b.get_collection_type ();
diff --git a/src/collection/dummy-add-collection.vala b/src/collection/dummy-add-collection.vala
index 926c49d80..30d275656 100644
--- a/src/collection/dummy-add-collection.vala
+++ b/src/collection/dummy-add-collection.vala
@@ -5,12 +5,12 @@ private class Games.DummyAddCollection : Object, Collection {
get { return true; }
}
- public string get_id () {
- return "Add Collection";
+ public string title {
+ get { return _("Add Collection"); }
}
- public string get_title () {
- return _("Add Collection");
+ public string get_id () {
+ return "Add Collection";
}
public GameModel get_game_model () {
diff --git a/src/collection/favorites-collection.vala b/src/collection/favorites-collection.vala
index 2a5739189..1da7371e1 100644
--- a/src/collection/favorites-collection.vala
+++ b/src/collection/favorites-collection.vala
@@ -11,6 +11,10 @@ private class Games.FavoritesCollection : Object, Collection {
get { return _is_empty; }
}
+ public string title {
+ get { return _("Favorites"); }
+ }
+
private ulong idle_id = 0;
public FavoritesCollection (Database database) {
@@ -43,10 +47,6 @@ private class Games.FavoritesCollection : Object, Collection {
return "Favorites";
}
- public string get_title () {
- return _("Favorites");
- }
-
public GameModel get_game_model () {
return game_model;
}
diff --git a/src/collection/recently-played-collection.vala b/src/collection/recently-played-collection.vala
index 0c710b7a9..e2bce64b4 100644
--- a/src/collection/recently-played-collection.vala
+++ b/src/collection/recently-played-collection.vala
@@ -11,6 +11,10 @@ private class Games.RecentlyPlayedCollection : Object, Collection {
get { return _is_empty; }
}
+ public string title {
+ get { return _("Recently Played"); }
+ }
+
public RecentlyPlayedCollection (Database database) {
this.database = database;
@@ -42,10 +46,6 @@ private class Games.RecentlyPlayedCollection : Object, Collection {
return "Recently Played";
}
- public string get_title () {
- return _("Recently Played");
- }
-
public GameModel get_game_model () {
return game_model;
}
diff --git a/src/collection/user-collection.vala b/src/collection/user-collection.vala
index 7ca55bef7..794da96ae 100644
--- a/src/collection/user-collection.vala
+++ b/src/collection/user-collection.vala
@@ -7,7 +7,6 @@ private class Games.UserCollection : Object, Collection {
private GenericSet<Uid> game_uids;
private GameCollection game_collection;
private string id;
- private string title;
private ulong idle_id = 0;
private ulong on_game_added_id = 0;
@@ -15,9 +14,14 @@ private class Games.UserCollection : Object, Collection {
get { return false; }
}
+ private string _title;
+ public string title {
+ get { return _title; }
+ }
+
public UserCollection (string id, string title, Database database) {
this.id = id;
- this.title = title;
+ _title = title;
this.database = database;
game_uids = new GenericSet<Uid> (Uid.hash, Uid.equal);
@@ -35,17 +39,15 @@ private class Games.UserCollection : Object, Collection {
return id;
}
- public string get_title () {
- return title;
- }
-
public void set_title (string value) {
if (title == value)
return;
try {
- if (database.rename_user_collection (this, value))
- title = value;
+ if (database.rename_user_collection (this, value)) {
+ _title = value;
+ notify_property ("title");
+ }
}
catch (Error e) {
critical ("%s", e.message);
diff --git a/src/database/database.vala b/src/database/database.vala
index 366fae63a..1bac2ee2a 100644
--- a/src/database/database.vala
+++ b/src/database/database.vala
@@ -573,18 +573,18 @@ private class Games.Database : Object {
public bool add_user_collection (UserCollection collection) throws Error {
if (does_user_collection_exist (collection.get_id ())) {
- critical ("A collection named %s already exists", collection.get_title ());
+ critical ("A collection named %s already exists", collection.title);
return false;
}
add_user_collection_query.reset ();
bind_text (add_user_collection_query, "$COLLECTION_ID", collection.get_id ());
- bind_text (add_user_collection_query, "$TITLE", collection.get_title ());
+ bind_text (add_user_collection_query, "$TITLE", collection.title);
var result = add_user_collection_query.step ();
if (result != Sqlite.DONE)
throw new DatabaseError.EXECUTION_FAILED ("Failed to add user collection %s: %s",
- collection.get_title (), result.to_string
());
+ collection.title, result.to_string ());
return true;
}
@@ -600,7 +600,7 @@ private class Games.Database : Object {
var result = add_game_to_user_collection_query.step ();
if (result != Sqlite.DONE)
throw new DatabaseError.EXECUTION_FAILED ("Failed to add %s to user collection %s",
- game.name, collection.get_title ());
+ game.name, collection.title);
return true;
}
@@ -639,7 +639,7 @@ private class Games.Database : Object {
var result = remove_user_collection_query.step ();
if (result != Sqlite.DONE)
- throw new DatabaseError.EXECUTION_FAILED ("Failed to remove user collection %s",
collection.get_title ());
+ throw new DatabaseError.EXECUTION_FAILED ("Failed to remove user collection %s",
collection.title);
return true;
}
@@ -655,7 +655,7 @@ private class Games.Database : Object {
var result = remove_game_from_user_collection_query.step ();
if (result != Sqlite.DONE)
throw new DatabaseError.EXECUTION_FAILED ("Failed to remove %s from user collection
%s",
- game.name, collection.get_title ());
+ game.name, collection.title);
return true;
}
@@ -671,7 +671,7 @@ private class Games.Database : Object {
var result = rename_user_collection_query.step ();
if (result != Sqlite.DONE)
throw new DatabaseError.EXECUTION_FAILED ("Failed to rename user collection %s",
- collection.get_title ());
+ collection.title);
return true;
}
diff --git a/src/ui/collection-icon-view.vala b/src/ui/collection-icon-view.vala
index a76af2056..4a6652d88 100644
--- a/src/ui/collection-icon-view.vala
+++ b/src/ui/collection-icon-view.vala
@@ -13,7 +13,7 @@ private class Games.CollectionIconView : Gtk.FlowBoxChild {
construct set {
_collection = value;
- title.label = collection.get_title ();
+ title.label = collection.title;
thumbnail.collection = collection;
}
}
diff --git a/src/ui/collection-list-item.vala b/src/ui/collection-list-item.vala
index da56c7d70..800cf668f 100644
--- a/src/ui/collection-list-item.vala
+++ b/src/ui/collection-list-item.vala
@@ -5,7 +5,7 @@ private class Games.CollectionListItem : Hdy.ActionRow {
public Collection collection { get; construct; }
construct {
- title = collection.get_title ();
+ title = collection.title;
}
public CollectionListItem (Collection collection) {
diff --git a/src/ui/collections-page.vala b/src/ui/collections-page.vala
index 5b76fd88c..0f088ca53 100644
--- a/src/ui/collections-page.vala
+++ b/src/ui/collections-page.vala
@@ -138,7 +138,7 @@ private class Games.CollectionsPage : Gtk.Bin {
return;
/* translators: This is displayed in an undo notification when a game collection is removed */
- removed_notification_title = _("%s removed").printf (current_collection.get_title ());
+ removed_notification_title = _("%s removed").printf (current_collection.title);
if (last_removed_collection != null)
collection_manager.remove_user_collection (last_removed_collection);
@@ -193,7 +193,7 @@ private class Games.CollectionsPage : Gtk.Bin {
}
current_collection = collection;
- collection_title = collection.get_title ();
+ collection_title = collection.title;
collections_deck.visible_child = collections_subpage_stack;
is_collection_empty = collection.get_game_model ().get_n_items () == 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]