[gnome-games/wip/exalm/tnum: 17/24] collection-view: Add support for removing games from collections
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/tnum: 17/24] collection-view: Add support for removing games from collections
- Date: Wed, 19 Aug 2020 18:22:24 +0000 (UTC)
commit aa95f9cfa44deae7c81e5e566fc1f5932d89bfab
Author: Neville <nevilleantony98 gmail com>
Date: Tue Aug 11 23:03:03 2020 +0530
collection-view: Add support for removing games from collections
Adds a "Remove" button to selection-action-bar and an action to "view".
data/ui/collection-view.ui | 5 ++++-
data/ui/selection-action-bar.ui | 15 +++++++++++++++
src/ui/collection-view.vala | 27 ++++++++++++++++++++-------
src/ui/selection-action-bar.vala | 2 ++
4 files changed, 41 insertions(+), 8 deletions(-)
---
diff --git a/data/ui/collection-view.ui b/data/ui/collection-view.ui
index 97d3658ce..0b82ea4e8 100644
--- a/data/ui/collection-view.ui
+++ b/data/ui/collection-view.ui
@@ -546,7 +546,10 @@
<property name="reveal-child" bind-source="GamesCollectionView" bind-property="is-selection-mode"/>
<property name="transition-type">slide-up</property>
<child>
- <object class="GamesSelectionActionBar" id="selection_action_bar"/>
+ <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"/>
+ </object>
</child>
</object>
</child>
diff --git a/data/ui/selection-action-bar.ui b/data/ui/selection-action-bar.ui
index 236468736..8baf2d554 100644
--- a/data/ui/selection-action-bar.ui
+++ b/data/ui/selection-action-bar.ui
@@ -53,5 +53,20 @@
<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>
</template>
</interface>
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 683af72c9..cd6f67a0d 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -139,13 +139,14 @@ private class Games.CollectionView : Gtk.Box, UiView {
private KonamiCode konami_code;
private SimpleActionGroup action_group;
private const ActionEntry[] action_entries = {
- { "select-all", select_all },
- { "select-none", select_none },
- { "toggle-select", toggle_select },
- { "favorite-action", favorite_action },
- { "add-to-collection", add_to_collection },
- { "remove-collection", remove_collection },
- { "rename-collection", rename_collection }
+ { "select-all", select_all },
+ { "select-none", select_none },
+ { "toggle-select", toggle_select },
+ { "favorite-action", favorite_action },
+ { "add-to-collection", add_to_collection },
+ { "remove-collection", remove_collection },
+ { "rename-collection", rename_collection },
+ { "remove-from-collection", remove_from_collection }
};
construct {
@@ -343,6 +344,8 @@ private class Games.CollectionView : Gtk.Box, UiView {
platforms_page.select_none ();
games_page.select_none ();
collections_page.select_none ();
+
+ update_selection_action_bar ();
}
private void select_all () {
@@ -424,6 +427,16 @@ private class Games.CollectionView : Gtk.Box, UiView {
collection_rename_entry.grab_focus ();
}
+ private void remove_from_collection () {
+ if (!collections_page.is_subpage_open || collections_page.current_collection == null)
+ return;
+
+ var games = get_currently_selected_games ();
+ collections_page.current_collection.remove_games (games);
+ collections_page.update_is_collection_empty ();
+ select_none ();
+ }
+
[GtkCallback]
private void update_collection_name_validity () {
var name = collection_rename_entry.text.strip ();
diff --git a/src/ui/selection-action-bar.vala b/src/ui/selection-action-bar.vala
index 0d0127fca..1e6b889bd 100644
--- a/src/ui/selection-action-bar.vala
+++ b/src/ui/selection-action-bar.vala
@@ -18,6 +18,8 @@ private class Games.SelectionActionBar : Gtk.ActionBar {
}
}
+ public bool show_remove_button { get; set; }
+
public enum FavoriteState {
NONE_FAVORITE,
ALL_FAVORITE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]