From 0f55b074af9ace7b13cd6b2559d5c6340dc2ee0b Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 16 May 2023 11:35:54 -0600 Subject: [PATCH] GUI: Add branch selection --- resources/wx_gui/gui_settings.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index 32652dd5a..d3b14c56d 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -15,7 +15,8 @@ from resources import ( constants, global_settings, defaults, - generate_smbios + generate_smbios, + network_handler ) from data import ( model_array, @@ -1180,15 +1181,35 @@ Hardware Information: def on_nightly(self, event: wx.Event) -> None: + # Ask prompt for which branch + branches = ["main"] + result = network_handler.NetworkUtilities().get("https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/branches") + if result is not None: + result = result.json() + for branch in result: + if branch["name"] == "gh-pages": + continue + if branch["name"] not in branches: + branches.append(branch["name"]) + + with wx.SingleChoiceDialog(self.parent, "Which branch would you like to download?", "Branch Selection", branches) as dialog: + if dialog.ShowModal() == wx.ID_CANCEL: + return + + branch = dialog.GetStringSelection() + else: + branch = "main" + gui_update.UpdateFrame( parent=self.parent, title=self.title, global_constants=self.constants, screen_location=self.parent.GetPosition(), - url="https://nightly.link/dortania/OpenCore-Legacy-Patcher/workflows/build-app-wxpython/main/OpenCore-Patcher.app%20%28GUI%29.zip", + url=f"https://nightly.link/dortania/OpenCore-Legacy-Patcher/workflows/build-app-wxpython/{branch}/OpenCore-Patcher.app%20%28GUI%29.zip", version_label="(Nightly)" ) + def on_export_constants(self, event: wx.Event) -> None: # Throw pop up to get save location with wx.FileDialog(self.parent, "Save Constants File", wildcard="JSON files (*.txt)|*.txt", style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog: