11use std:: cell:: OnceCell ;
22
3+ use adw:: prelude:: AdwDialogExt ;
34use adw:: subclass:: prelude:: * ;
45use gettextrs:: gettext;
56use glib:: clone;
@@ -97,44 +98,64 @@ impl Application {
9798 fn setup_gactions ( & self ) {
9899 // Quit
99100 let action_quit = gio:: SimpleAction :: new ( "quit" , None ) ;
100- action_quit. connect_activate ( clone ! ( @weak self as app => move |_, _| {
101- // This is needed to trigger the delete event and saving the window state
102- app. main_window( ) . close( ) ;
103- app. quit( ) ;
104- } ) ) ;
101+ action_quit. connect_activate ( clone ! (
102+ #[ weak( rename_to = app) ]
103+ self ,
104+ move |_, _| {
105+ // This is needed to trigger the delete event and saving the window state
106+ app. main_window( ) . close( ) ;
107+ app. quit( ) ;
108+ }
109+ ) ) ;
105110 self . add_action ( & action_quit) ;
106111
107112 // About
108113 let action_about = gio:: SimpleAction :: new ( "about" , None ) ;
109- action_about. connect_activate ( clone ! ( @weak self as app => move |_, _| {
110- app. show_about_dialog( ) ;
111- } ) ) ;
114+ action_about. connect_activate ( clone ! (
115+ #[ weak( rename_to = app) ]
116+ self ,
117+ move |_, _| {
118+ app. show_about_dialog( ) ;
119+ }
120+ ) ) ;
112121 self . add_action ( & action_about) ;
113122
114123 // Select chat
115124 let action_select_chat =
116125 gio:: SimpleAction :: new ( "select-chat" , Some ( glib:: VariantTy :: new ( "(ix)" ) . unwrap ( ) ) ) ;
117- action_select_chat. connect_activate ( clone ! ( @weak self as app => move |_, data| {
118- let ( client_id, chat_id) = data. unwrap( ) . get( ) . unwrap( ) ;
119- app. main_window( ) . select_chat( client_id, chat_id) ;
120- } ) ) ;
126+ action_select_chat. connect_activate ( clone ! (
127+ #[ weak( rename_to = app) ]
128+ self ,
129+ move |_, data| {
130+ let ( client_id, chat_id) = data. unwrap( ) . get( ) . unwrap( ) ;
131+ app. main_window( ) . select_chat( client_id, chat_id) ;
132+ }
133+ ) ) ;
121134 self . add_action ( & action_select_chat) ;
122135
123136 // New login on production server
124137 let action_new_login_production_server =
125138 gio:: SimpleAction :: new ( "new-login-production-server" , None ) ;
126- action_new_login_production_server. connect_activate (
127- clone ! ( @weak self as app => move |_, _| {
128- app. main_window( ) . client_manager_view( ) . add_new_client( false ) ;
129- } ) ,
130- ) ;
139+ action_new_login_production_server. connect_activate ( clone ! (
140+ #[ weak( rename_to = app) ]
141+ self ,
142+ move |_, _| {
143+ app. main_window( )
144+ . client_manager_view( )
145+ . add_new_client( false ) ;
146+ }
147+ ) ) ;
131148 self . add_action ( & action_new_login_production_server) ;
132149
133150 // New login on test server
134151 let action_new_login_test_server = gio:: SimpleAction :: new ( "new-login-test-server" , None ) ;
135- action_new_login_test_server. connect_activate ( clone ! ( @weak self as app => move |_, _| {
136- app. main_window( ) . client_manager_view( ) . add_new_client( true ) ;
137- } ) ) ;
152+ action_new_login_test_server. connect_activate ( clone ! (
153+ #[ weak( rename_to = app) ]
154+ self ,
155+ move |_, _| {
156+ app. main_window( ) . client_manager_view( ) . add_new_client( true ) ;
157+ }
158+ ) ) ;
138159 self . add_action ( & action_new_login_test_server) ;
139160 }
140161
@@ -154,8 +175,7 @@ impl Application {
154175 }
155176
156177 fn show_about_dialog ( & self ) {
157- let about = adw:: AboutWindow :: builder ( )
158- . transient_for ( & self . main_window ( ) )
178+ let about = adw:: AboutDialog :: builder ( )
159179 . application_name ( "Paper Plane" )
160180 . application_icon ( config:: APP_ID )
161181 . version ( config:: VERSION )
@@ -201,6 +221,6 @@ impl Application {
201221 ) ) ,
202222 ) ;
203223
204- about. present ( ) ;
224+ about. present ( Some ( & self . main_window ( ) ) ) ;
205225 }
206226}
0 commit comments