@@ -45,6 +45,10 @@ const (
45
45
applyPreferencesActionName = "applypreferences"
46
46
openDownloadsActionName = "opendownloads"
47
47
copyMagnetLinkActionName = "copymagnetlink"
48
+
49
+ responseDownloadFlathub = "download-flathub"
50
+ responseDownloadWebsite = "download-website"
51
+ responseManualConfiguration = "manual-configuration"
48
52
)
49
53
50
54
func OpenAssistantWindow (
@@ -89,10 +93,7 @@ func OpenAssistantWindow(
89
93
descriptionHeaderbarSubtitle := descriptionBuilder .GetObject ("headerbar-subtitle" ).Cast ().(* gtk.Label )
90
94
91
95
warningBuilder := gtk .NewBuilderFromResource (resources .GResourceWarningPath )
92
- warningDialog := warningBuilder .GetObject ("warning-dialog" ).Cast ().(* gtk.MessageDialog )
93
- mpvFlathubDownloadButton := warningBuilder .GetObject ("mpv-download-flathub-button" ).Cast ().(* gtk.Button )
94
- mpvWebsiteDownloadButton := warningBuilder .GetObject ("mpv-download-website-button" ).Cast ().(* gtk.Button )
95
- mpvManualConfigurationButton := warningBuilder .GetObject ("mpv-manual-configuration-button" ).Cast ().(* gtk.Button )
96
+ warningDialog := warningBuilder .GetObject ("warning-dialog" ).Cast ().(* adw.AlertDialog )
96
97
97
98
magnetLink := ""
98
99
torrentTitle := ""
@@ -721,41 +722,32 @@ func OpenAssistantWindow(
721
722
})
722
723
723
724
if runtime .GOOS == "linux" {
724
- mpvFlathubDownloadButton .SetVisible (true )
725
- warningDialog .SetDefaultWidget (mpvFlathubDownloadButton )
726
- } else {
727
- warningDialog .SetDefaultWidget (mpvWebsiteDownloadButton )
725
+ warningDialog .SetResponseEnabled (responseDownloadFlathub , true )
726
+ warningDialog .SetDefaultResponse (responseDownloadFlathub )
728
727
}
729
728
730
- mpvFlathubDownloadButton .ConnectClicked (func () {
731
- _ = openuri .OpenURI ("" , mpvFlathubURL , nil )
732
-
733
- warningDialog .Close ()
734
-
735
- os .Exit (0 )
736
- })
729
+ warningDialog .ConnectResponse (func (response string ) {
730
+ switch response {
731
+ case responseDownloadFlathub :
732
+ _ = openuri .OpenURI ("" , mpvFlathubURL , nil )
737
733
738
- mpvWebsiteDownloadButton .ConnectClicked (func () {
739
- _ = openuri .OpenURI ("" , mpvWebsiteURL , nil )
734
+ warningDialog .Close ()
740
735
741
- warningDialog . Close ( )
736
+ os . Exit ( 0 )
742
737
743
- os . Exit ( 0 )
744
- } )
738
+ case responseDownloadWebsite :
739
+ _ = openuri . OpenURI ( "" , mpvWebsiteURL , nil )
745
740
746
- mpvManualConfigurationButton .ConnectClicked (func () {
747
- warningDialog .Close ()
741
+ warningDialog .Close ()
748
742
749
- preferencesDialog .Present (& window .Window )
750
- mpvCommandInput .GrabFocus ()
751
- })
743
+ os .Exit (0 )
752
744
753
- warningDialog .SetTransientFor (& window .Window )
754
- warningDialog .ConnectCloseRequest (func () (ok bool ) {
755
- warningDialog .Close ()
756
- warningDialog .SetVisible (false )
745
+ default :
746
+ warningDialog .Close ()
757
747
758
- return ok
748
+ preferencesDialog .Present (& window .Window )
749
+ mpvCommandInput .GrabFocus ()
750
+ }
759
751
})
760
752
761
753
app .AddWindow (& window .Window )
@@ -764,7 +756,7 @@ func OpenAssistantWindow(
764
756
if oldMPVCommand := settings .String (resources .GSchemaMPVKey ); strings .TrimSpace (oldMPVCommand ) == "" {
765
757
newMPVCommand , err := mpvClient .DiscoverMPVExecutable ()
766
758
if err != nil {
767
- warningDialog .SetVisible ( true )
759
+ warningDialog .Present ( & window . Window )
768
760
769
761
return
770
762
}
0 commit comments