@@ -18,17 +18,15 @@ struct Versions {
18
18
handheld_iso_version : String ,
19
19
}
20
20
21
- fn outdated_version_check ( message : String ) -> bool {
21
+ fn outdated_version_check ( window : & gtk :: Window , message : String ) -> bool {
22
22
let edition_tag: String =
23
23
fs:: read_to_string ( "/etc/edition-tag" ) . unwrap_or ( "desktop" . into ( ) ) . trim ( ) . into ( ) ;
24
24
let version_tag: String =
25
25
fs:: read_to_string ( "/etc/version-tag" ) . unwrap_or ( "testing" . into ( ) ) . trim ( ) . into ( ) ;
26
26
27
- let window_ref = unsafe { & G_HELLO_WINDOW . as_ref ( ) . unwrap ( ) . window } ;
28
-
29
27
if version_tag. contains ( "testing" ) {
30
28
utils:: show_simple_dialog (
31
- window_ref ,
29
+ window ,
32
30
gtk:: MessageType :: Warning ,
33
31
& fl ! ( "testing-iso-warning" ) ,
34
32
message. clone ( ) ,
@@ -40,7 +38,7 @@ fn outdated_version_check(message: String) -> bool {
40
38
41
39
if response. is_err ( ) {
42
40
utils:: show_simple_dialog (
43
- window_ref ,
41
+ window ,
44
42
gtk:: MessageType :: Warning ,
45
43
& fl ! ( "offline-error" ) ,
46
44
message. clone ( ) ,
@@ -60,7 +58,7 @@ fn outdated_version_check(message: String) -> bool {
60
58
61
59
if version_tag != latest_version {
62
60
utils:: show_simple_dialog (
63
- window_ref ,
61
+ window ,
64
62
gtk:: MessageType :: Warning ,
65
63
& fl ! ( "outdated-version-warning" ) ,
66
64
message. clone ( ) ,
@@ -69,7 +67,7 @@ fn outdated_version_check(message: String) -> bool {
69
67
true
70
68
}
71
69
72
- fn edition_compat_check ( message : String ) -> bool {
70
+ fn edition_compat_check ( window : & gtk :: Window , message : String ) -> bool {
73
71
let edition_tag = fs:: read_to_string ( "/etc/edition-tag" ) . unwrap_or ( "desktop" . to_string ( ) ) ;
74
72
75
73
if edition_tag == "handheld" {
@@ -85,9 +83,8 @@ fn edition_compat_check(message: String) -> bool {
85
83
86
84
if available_profiles. iter ( ) . any ( |profile| handheld_profile_names. contains ( & & profile. name ) )
87
85
{
88
- let window_ref = unsafe { & G_HELLO_WINDOW . as_ref ( ) . unwrap ( ) . window } ;
89
86
utils:: show_simple_dialog (
90
- window_ref ,
87
+ window ,
91
88
gtk:: MessageType :: Warning ,
92
89
& fl ! ( "unsupported-hw-warning" ) ,
93
90
message. clone ( ) ,
@@ -98,20 +95,14 @@ fn edition_compat_check(message: String) -> bool {
98
95
true
99
96
}
100
97
101
- fn connectivity_check ( message : String ) -> bool {
98
+ fn connectivity_check ( window : & gtk :: Window , message : String ) -> bool {
102
99
let status = match reqwest:: blocking:: get ( "https://cachyos.org" ) {
103
100
Ok ( resp) => resp. status ( ) . is_success ( ) || resp. status ( ) . is_server_error ( ) ,
104
101
_ => false ,
105
102
} ;
106
103
107
104
if !status {
108
- let window_ref = unsafe { & G_HELLO_WINDOW . as_ref ( ) . unwrap ( ) . window } ;
109
- utils:: show_simple_dialog (
110
- window_ref,
111
- gtk:: MessageType :: Error ,
112
- & fl ! ( "offline-error" ) ,
113
- message,
114
- ) ;
105
+ utils:: show_simple_dialog ( window, gtk:: MessageType :: Error , & fl ! ( "offline-error" ) , message) ;
115
106
return false ;
116
107
}
117
108
true
@@ -120,13 +111,14 @@ fn connectivity_check(message: String) -> bool {
120
111
pub fn launch_installer ( message : String ) {
121
112
// Spawn child process in separate thread.
122
113
std:: thread:: spawn ( move || {
114
+ let window_ref = unsafe { & G_HELLO_WINDOW . as_ref ( ) . unwrap ( ) . window } ;
123
115
let builder = unsafe { & G_HELLO_WINDOW . as_ref ( ) . unwrap ( ) . builder } ;
124
116
125
117
let install_btn: gtk:: Button = builder. object ( "install" ) . unwrap ( ) ;
126
118
install_btn. set_sensitive ( false ) ;
127
119
128
120
let checks = [ connectivity_check, edition_compat_check, outdated_version_check] ;
129
- if !checks. iter ( ) . all ( |x| x ( message. clone ( ) ) ) {
121
+ if !checks. iter ( ) . all ( |x| x ( window_ref , message. clone ( ) ) ) {
130
122
// if any check failed, return
131
123
info ! ( "Some ISO check failed!" ) ;
132
124
install_btn. set_sensitive ( true ) ;
0 commit comments