From e383c41b6e04d941788221e39bb3a68656d28138 Mon Sep 17 00:00:00 2001 From: Xpl0itR Date: Tue, 1 Dec 2020 22:51:49 +0000 Subject: [PATCH] Add a "Remove All" button to the DLC and Update windows (#1579) --- Ryujinx/Ui/DlcWindow.cs | 20 +++++++++++++++ Ryujinx/Ui/DlcWindow.glade | 24 +++++++++++++++--- Ryujinx/Ui/TitleUpdateWindow.cs | 40 +++++++++++++++++++----------- Ryujinx/Ui/TitleUpdateWindow.glade | 26 +++++++++++++++---- 4 files changed, 86 insertions(+), 24 deletions(-) diff --git a/Ryujinx/Ui/DlcWindow.cs b/Ryujinx/Ui/DlcWindow.cs index b9b770c0cf..29e96b07fb 100644 --- a/Ryujinx/Ui/DlcWindow.cs +++ b/Ryujinx/Ui/DlcWindow.cs @@ -195,6 +195,26 @@ namespace Ryujinx.Ui } } } + + private void RemoveAllButton_Clicked(object sender, EventArgs args) + { + List toRemove = new List(); + + if (_dlcTreeView.Model.GetIterFirst(out TreeIter iter)) + { + do + { + toRemove.Add(iter); + } + while (_dlcTreeView.Model.IterNext(ref iter)); + } + + foreach (TreeIter i in toRemove) + { + TreeIter j = i; + ((TreeStore)_dlcTreeView.Model).Remove(ref j); + } + } private void SaveButton_Clicked(object sender, EventArgs args) { diff --git a/Ryujinx/Ui/DlcWindow.glade b/Ryujinx/Ui/DlcWindow.glade index 08d7ca0acb..cd0d86744d 100644 --- a/Ryujinx/Ui/DlcWindow.glade +++ b/Ryujinx/Ui/DlcWindow.glade @@ -1,5 +1,5 @@ - + @@ -9,9 +9,6 @@ center 550 350 - - - True @@ -118,6 +115,22 @@ 1 + + + Remove All + True + True + True + Removes the selected update + 10 + + + + True + True + 2 + + True @@ -182,5 +195,8 @@ + + + diff --git a/Ryujinx/Ui/TitleUpdateWindow.cs b/Ryujinx/Ui/TitleUpdateWindow.cs index c3345271a7..54b5b2620a 100644 --- a/Ryujinx/Ui/TitleUpdateWindow.cs +++ b/Ryujinx/Ui/TitleUpdateWindow.cs @@ -13,6 +13,7 @@ using Ryujinx.HLE.HOS; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using GUI = Gtk.Builder.ObjectAttribute; @@ -60,19 +61,16 @@ namespace Ryujinx.Ui } _baseTitleInfoLabel.Text = $"Updates Available for {titleName} [{titleId.ToUpper()}]"; + _noUpdateRadioButton.Active = true; foreach (string path in _titleUpdateWindowData.Paths) { AddUpdate(path, false); } - _noUpdateRadioButton.Active = true; - foreach (KeyValuePair keyValuePair in _radioButtonToPathDictionary) + foreach ((RadioButton update, var _) in _radioButtonToPathDictionary.Where(keyValuePair => keyValuePair.Value == _titleUpdateWindowData.Selected)) { - if (keyValuePair.Value == _titleUpdateWindowData.Selected) - { - keyValuePair.Key.Active = true; - } + update.Active = true; } } @@ -131,6 +129,19 @@ namespace Ryujinx.Ui } } + private void RemoveUpdates(bool removeSelectedOnly = false) + { + foreach (RadioButton radioButton in _noUpdateRadioButton.Group) + { + if (radioButton.Label != "No Update" && (!removeSelectedOnly || radioButton.Active)) + { + _availableUpdatesBox.Remove(radioButton); + _radioButtonToPathDictionary.Remove(radioButton); + radioButton.Dispose(); + } + } + } + private void AddButton_Clicked(object sender, EventArgs args) { FileChooserDialog fileChooser = new FileChooserDialog("Select update files", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept) @@ -154,20 +165,19 @@ namespace Ryujinx.Ui private void RemoveButton_Clicked(object sender, EventArgs args) { - foreach (RadioButton radioButton in _noUpdateRadioButton.Group) - { - if (radioButton.Label != "No Update" && radioButton.Active) - { - _availableUpdatesBox.Remove(radioButton); - _radioButtonToPathDictionary.Remove(radioButton); - radioButton.Dispose(); - } - } + RemoveUpdates(true); + } + + private void RemoveAllButton_Clicked(object sender, EventArgs args) + { + RemoveUpdates(); } private void SaveButton_Clicked(object sender, EventArgs args) { _titleUpdateWindowData.Paths.Clear(); + _titleUpdateWindowData.Selected = ""; + foreach (string paths in _radioButtonToPathDictionary.Values) { _titleUpdateWindowData.Paths.Add(paths); diff --git a/Ryujinx/Ui/TitleUpdateWindow.glade b/Ryujinx/Ui/TitleUpdateWindow.glade index 081dc3eaa4..de557471a0 100644 --- a/Ryujinx/Ui/TitleUpdateWindow.glade +++ b/Ryujinx/Ui/TitleUpdateWindow.glade @@ -1,5 +1,5 @@ - + @@ -7,11 +7,8 @@ Ryujinx - Title Update Manager True center - 440 + 550 250 - - - True @@ -130,6 +127,22 @@ 1 + + + Remove All + True + True + True + Removes the selected update + 10 + + + + True + True + 2 + + True @@ -194,5 +207,8 @@ + + +