[gnome-games/wip/exalm/tnum: 23/24] collection-view: Show number of selected games in headerbar
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/tnum: 23/24] collection-view: Show number of selected games in headerbar
- Date: Wed, 19 Aug 2020 18:22:24 +0000 (UTC)
commit a2879adaf3ae94b183c7eb8366f3258a5d3e14c2
Author: Neville <nevilleantony98 gmail com>
Date: Sat Aug 15 18:13:40 2020 +0530
collection-view: Show number of selected games in headerbar
shows "Selected n items" in selection mode headerbar which is handy to
keep track of selected games.
Fixes #302.
Fixes #303
data/ui/collection-view.ui | 11 +++++++----
src/ui/collection-view.vala | 24 +++++++++++++++---------
2 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/data/ui/collection-view.ui b/data/ui/collection-view.ui
index 0b82ea4e8..b54c94dad 100644
--- a/data/ui/collection-view.ui
+++ b/data/ui/collection-view.ui
@@ -368,10 +368,13 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
- <object class="GtkLabel">
+ <object class="GtkLabel" id="selection_mode_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Click on items to select them</property>
<property name="ellipsize">end</property>
+ <attributes>
+ <attribute name="font-features" value="tnum=1"/>
+ </attributes>
</object>
</child>
<child>
@@ -437,7 +440,7 @@
<property name="visible">True</property>
<property name="is-selection-mode" bind-source="GamesCollectionView"
bind-property="is-selection-mode"/>
<signal name="game-activated" handler="on_game_activated"/>
- <signal name="selected-items-changed" handler="update_selection_action_bar"/>
+ <signal name="selected-items-changed" handler="on_selected_items_changed"/>
</object>
<packing>
<property name="name">games</property>
@@ -452,7 +455,7 @@
<property name="is-selection-mode" bind-source="GamesCollectionView"
bind-property="is-selection-mode"/>
<signal name="game-activated" handler="on_game_activated"/>
<signal name="notify::is-subview-open" handler="update_selection_availability"/>
- <signal name="selected-items-changed" handler="update_selection_action_bar"/>
+ <signal name="selected-items-changed" handler="on_selected_items_changed"/>
</object>
<packing>
<property name="name">platform</property>
@@ -467,7 +470,7 @@
<property name="is-selection-mode" bind-source="GamesCollectionView"
bind-property="is-selection-mode"/>
<property name="is-search-mode" bind-source="GamesCollectionView"
bind-property="search-mode" bind-flags="bidirectional"/>
<signal name="game-activated" handler="on_game_activated"/>
- <signal name="selected-items-changed" handler="update_selection_action_bar"/>
+ <signal name="selected-items-changed" handler="on_selected_items_changed"/>
<signal name="notify::is-subpage-open" handler="update_bottom_bar"/>
</object>
<packing>
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 8be154108..f91b615c0 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -56,6 +56,8 @@ private class Games.CollectionView : Gtk.Box, UiView {
private Gtk.Popover rename_popover;
[GtkChild]
private Gtk.Label collection_rename_error_label;
+ [GtkChild]
+ private Gtk.Label selection_mode_label;
private bool _is_view_active;
public bool is_view_active {
@@ -345,7 +347,7 @@ private class Games.CollectionView : Gtk.Box, UiView {
games_page.select_none ();
collections_page.select_none ();
- update_selection_action_bar ();
+ on_selected_items_changed ();
}
private void select_all () {
@@ -355,6 +357,8 @@ private class Games.CollectionView : Gtk.Box, UiView {
games_page.select_all ();
else
collections_page.select_all ();
+
+ on_selected_items_changed ();
}
private void toggle_select () {
@@ -407,7 +411,7 @@ private class Games.CollectionView : Gtk.Box, UiView {
return;
}
- update_selection_action_bar ();
+ on_selected_items_changed ();
}
public void remove_collection () {
@@ -478,15 +482,17 @@ private class Games.CollectionView : Gtk.Box, UiView {
}
[GtkCallback]
- private void update_selection_action_bar () {
- Game[] games = {};
- if (viewstack.visible_child == games_page)
- games = games_page.get_selected_games ();
- else if (viewstack.visible_child == platforms_page)
- games = platforms_page.get_selected_games ();
+ private void on_selected_items_changed () {
+ var games = get_currently_selected_games ();
+
+ var length = games.length;
+ string label;
+ if (length != 0)
+ label = ngettext ("Selected %d item", "Selected %d items", length).printf (length);
else
- games = collections_page.get_selected_games ();
+ label = _("Click on items to select them");
+ selection_mode_label.label = label;
selection_action_bar.update (games);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]