[gnome-games] collection-view: Support selection mode in CollectionsPage
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] collection-view: Support selection mode in CollectionsPage
- Date: Tue, 25 Aug 2020 11:11:56 +0000 (UTC)
commit 678a66897307d0bc7689084839b8a6264b59222d
Author: Neville <nevilleantony98 gmail com>
Date: Fri Aug 21 16:25:31 2020 +0530
collection-view: Support selection mode in CollectionsPage
data/ui/collection-view.ui | 4 +-
data/ui/selection-action-bar.ui | 104 ++++++++++++++++++++++++---------------
src/ui/collection-view.vala | 46 ++++++++++++++---
src/ui/selection-action-bar.vala | 2 +
4 files changed, 108 insertions(+), 48 deletions(-)
---
diff --git a/data/ui/collection-view.ui b/data/ui/collection-view.ui
index b54c94dad..25f81fae0 100644
--- a/data/ui/collection-view.ui
+++ b/data/ui/collection-view.ui
@@ -471,7 +471,7 @@
<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="on_selected_items_changed"/>
- <signal name="notify::is-subpage-open" handler="update_bottom_bar"/>
+ <signal name="notify::is-subpage-open" handler="on_collection_subpage_opened"/>
</object>
<packing>
<property name="name">collections</property>
@@ -552,6 +552,8 @@
<object class="GamesSelectionActionBar" id="selection_action_bar">
<property name="visible">True</property>
<property name="show-remove-button" bind-source="collections_page"
bind-property="is-showing-user-collection"/>
+ <property name="show-game-actions" bind-source="GamesCollectionView"
bind-property="show-game-actions"/>
+ <property name="show-remove-collection-button" bind-source="GamesCollectionView"
bind-property="show-remove-action-button"/>
</object>
</child>
</object>
diff --git a/data/ui/selection-action-bar.ui b/data/ui/selection-action-bar.ui
index 1ee8e19e0..a71593c76 100644
--- a/data/ui/selection-action-bar.ui
+++ b/data/ui/selection-action-bar.ui
@@ -5,61 +5,83 @@
<property name="visible">True</property>
<property name="sensitive">False</property>
<child>
- <object class="GtkButton" id="favorite_button">
- <property name="visible">True</property>
- <property name="action-name">view.favorite-action</property>
- <property name="tooltip-text" translatable="yes">Add/Remove selected games to favorite</property>
+ <object class="GtkBox">
+ <property name="visible" bind-source="GamesSelectionActionBar" bind-property="show-game-actions"/>
+ <property name="hexpand">True</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkStack" id="icon_stack">
+ <object class="GtkButton" id="favorite_button">
<property name="visible">True</property>
- <property name="transition-type">crossfade</property>
+ <property name="action-name">view.favorite-action</property>
+ <property name="tooltip-text" translatable="yes">Add/Remove selected games to favorite</property>
<child>
- <object class="GtkImage">
+ <object class="GtkStack" id="icon_stack">
<property name="visible">True</property>
- <property name="icon-name">starred-symbolic</property>
+ <property name="transition-type">crossfade</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">starred-symbolic</property>
+ </object>
+ <packing>
+ <property name="name">starred-icon</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">non-starred-symbolic</property>
+ </object>
+ <packing>
+ <property name="name">non-starred-icon</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">semi-starred-symbolic</property>
+ </object>
+ <packing>
+ <property name="name">semi-starred-icon</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="name">starred-icon</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">non-starred-symbolic</property>
- </object>
- <packing>
- <property name="name">non-starred-icon</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">semi-starred-symbolic</property>
- </object>
- <packing>
- <property name="name">semi-starred-icon</property>
- </packing>
</child>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="add_to_collection_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Add to Collection</property>
- <property name="use-underline">True</property>
- <property name="action-name">view.add-to-collection</property>
- <property name="tooltip-text" translatable="yes">Add selected games to a collection</property>
+ <child>
+ <object class="GtkButton" id="add_to_collection_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Add to Collection</property>
+ <property name="use-underline">True</property>
+ <property name="action-name">view.add-to-collection</property>
+ <property name="tooltip-text" translatable="yes">Add selected games to a collection</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible" bind-source="GamesSelectionActionBar"
bind-property="show-remove-button"/>
+ <property name="label" translatable="yes">_Remove</property>
+ <property name="use-underline">True</property>
+ <property name="action-name">view.remove-from-collection</property>
+ <property name="tooltip-text" translatable="yes">Remove selected games from this
collection</property>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
</object>
</child>
<child>
<object class="GtkButton">
- <property name="visible" bind-source="GamesSelectionActionBar" bind-property="show-remove-button"/>
+ <property name="visible" bind-source="GamesSelectionActionBar"
bind-property="show-remove-collection-button"/>
<property name="label" translatable="yes">_Remove</property>
<property name="use-underline">True</property>
- <property name="action-name">view.remove-from-collection</property>
- <property name="tooltip-text" translatable="yes">Remove selected games from this
collection</property>
+ <property name="action-name">view.remove-collection</property>
+ <property name="tooltip-text" translatable="yes">Remove selected collections</property>
<style>
<class name="destructive-action"/>
</style>
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index f91b615c0..2cf063472 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -136,6 +136,8 @@ private class Games.CollectionView : Gtk.Box, UiView {
public bool is_selection_mode { get; set; }
public bool is_selection_available { get; set; }
public bool is_collection_rename_valid { get; set; }
+ public bool show_game_actions { get; set; }
+ public bool show_remove_action_button { get; set; }
private CollectionManager collection_manager;
private KonamiCode konami_code;
@@ -175,6 +177,7 @@ private class Games.CollectionView : Gtk.Box, UiView {
window.insert_action_group ("view", action_group);
update_search_availablity ();
+ update_available_selection_actions ();
}
public void show_error (string error_message) {
@@ -415,8 +418,16 @@ private class Games.CollectionView : Gtk.Box, UiView {
}
public void remove_collection () {
- collections_page.remove_current_user_collection ();
+ if (viewstack.visible_child != collections_page)
+ return;
+
+ if (collections_page.is_subpage_open && collections_page.is_showing_user_collection)
+ collections_page.remove_current_user_collection ();
+ else
+ collections_page.remove_currently_selected_user_collections ();
+
undo_notification.show_notification ();
+ is_selection_mode = false;
}
public void rename_collection () {
@@ -436,6 +447,20 @@ private class Games.CollectionView : Gtk.Box, UiView {
select_none ();
}
+ private void update_available_selection_actions () {
+ show_game_actions = viewstack.visible_child != collections_page ||
+ collections_page.is_subpage_open;
+
+ show_remove_action_button = viewstack.visible_child == collections_page &&
+ !collections_page.is_subpage_open;
+ }
+
+ [GtkCallback]
+ private void on_collection_subpage_opened () {
+ update_bottom_bar ();
+ update_available_selection_actions ();
+ }
+
[GtkCallback]
private void update_collection_name_validity () {
var name = collection_rename_entry.text.strip ();
@@ -483,9 +508,19 @@ private class Games.CollectionView : Gtk.Box, UiView {
[GtkCallback]
private void on_selected_items_changed () {
- var games = get_currently_selected_games ();
+ int length = 0;
+
+ if (viewstack.visible_child == collections_page && !collections_page.is_subpage_open) {
+ var collections = collections_page.get_selected_collections ();
+ length = collections.length;
+ selection_action_bar.sensitive = length != 0;
+ }
+ else {
+ var games = get_currently_selected_games ();
+ length = games.length;
+ selection_action_bar.update (games);
+ }
- var length = games.length;
string label;
if (length != 0)
label = ngettext ("Selected %d item", "Selected %d items", length).printf (length);
@@ -493,7 +528,6 @@ private class Games.CollectionView : Gtk.Box, UiView {
label = _("Click on items to select them");
selection_mode_label.label = label;
- selection_action_bar.update (games);
}
[GtkCallback]
@@ -528,8 +562,7 @@ private class Games.CollectionView : Gtk.Box, UiView {
[GtkCallback]
private void update_selection_availability () {
- is_selection_available = (viewstack.visible_child != platforms_page || !is_folded)
- && viewstack.visible_child != collections_page;
+ is_selection_available = viewstack.visible_child != platforms_page || !is_folded;
}
[GtkCallback]
@@ -553,6 +586,7 @@ private class Games.CollectionView : Gtk.Box, UiView {
update_selection_availability ();
update_search_availablity ();
+ update_available_selection_actions ();
}
[GtkCallback]
diff --git a/src/ui/selection-action-bar.vala b/src/ui/selection-action-bar.vala
index 1e6b889bd..e54ec3335 100644
--- a/src/ui/selection-action-bar.vala
+++ b/src/ui/selection-action-bar.vala
@@ -19,6 +19,8 @@ private class Games.SelectionActionBar : Gtk.ActionBar {
}
public bool show_remove_button { get; set; }
+ public bool show_game_actions { get; set; }
+ public bool show_remove_collection_button { get; set; }
public enum FavoriteState {
NONE_FAVORITE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]