2
2
3
3
use std:: { ffi:: OsString , fmt, ops:: Deref , ptr} ;
4
4
5
- use glib:: { subclass:: prelude:: * , translate:: * , Cast , VariantDict } ;
5
+ use glib:: { subclass:: prelude:: * , translate:: * , Cast , ExitCode , VariantDict } ;
6
6
use libc:: { c_char, c_int, c_void} ;
7
7
8
8
use crate :: Application ;
@@ -77,11 +77,11 @@ pub trait ApplicationImpl: ObjectImpl + ApplicationImplExt {
77
77
self . parent_before_emit ( platform_data)
78
78
}
79
79
80
- fn command_line ( & self , command_line : & crate :: ApplicationCommandLine ) -> i32 {
80
+ fn command_line ( & self , command_line : & crate :: ApplicationCommandLine ) -> ExitCode {
81
81
self . parent_command_line ( command_line)
82
82
}
83
83
84
- fn local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < i32 > {
84
+ fn local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < ExitCode > {
85
85
self . parent_local_command_line ( arguments)
86
86
}
87
87
@@ -105,7 +105,7 @@ pub trait ApplicationImpl: ObjectImpl + ApplicationImplExt {
105
105
self . parent_startup ( )
106
106
}
107
107
108
- fn handle_local_options ( & self , options : & VariantDict ) -> i32 {
108
+ fn handle_local_options ( & self , options : & VariantDict ) -> ExitCode {
109
109
self . parent_handle_local_options ( options)
110
110
}
111
111
}
@@ -114,14 +114,14 @@ pub trait ApplicationImplExt: ObjectSubclass {
114
114
fn parent_activate ( & self ) ;
115
115
fn parent_after_emit ( & self , platform_data : & glib:: Variant ) ;
116
116
fn parent_before_emit ( & self , platform_data : & glib:: Variant ) ;
117
- fn parent_command_line ( & self , command_line : & crate :: ApplicationCommandLine ) -> i32 ;
118
- fn parent_local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < i32 > ;
117
+ fn parent_command_line ( & self , command_line : & crate :: ApplicationCommandLine ) -> ExitCode ;
118
+ fn parent_local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < ExitCode > ;
119
119
fn parent_open ( & self , files : & [ crate :: File ] , hint : & str ) ;
120
120
fn parent_quit_mainloop ( & self ) ;
121
121
fn parent_run_mainloop ( & self ) ;
122
122
fn parent_shutdown ( & self ) ;
123
123
fn parent_startup ( & self ) ;
124
- fn parent_handle_local_options ( & self , options : & VariantDict ) -> i32 ;
124
+ fn parent_handle_local_options ( & self , options : & VariantDict ) -> ExitCode ;
125
125
}
126
126
127
127
impl < T : ApplicationImpl > ApplicationImplExt for T {
@@ -164,7 +164,7 @@ impl<T: ApplicationImpl> ApplicationImplExt for T {
164
164
}
165
165
}
166
166
167
- fn parent_command_line ( & self , command_line : & crate :: ApplicationCommandLine ) -> i32 {
167
+ fn parent_command_line ( & self , command_line : & crate :: ApplicationCommandLine ) -> ExitCode {
168
168
unsafe {
169
169
let data = T :: type_data ( ) ;
170
170
let parent_class = data. as_ref ( ) . parent_class ( ) as * mut ffi:: GApplicationClass ;
@@ -175,10 +175,11 @@ impl<T: ApplicationImpl> ApplicationImplExt for T {
175
175
self . obj ( ) . unsafe_cast_ref :: < Application > ( ) . to_glib_none ( ) . 0 ,
176
176
command_line. to_glib_none ( ) . 0 ,
177
177
)
178
+ . into ( )
178
179
}
179
180
}
180
181
181
- fn parent_local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < i32 > {
182
+ fn parent_local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < ExitCode > {
182
183
unsafe {
183
184
let data = T :: type_data ( ) ;
184
185
let parent_class = data. as_ref ( ) . parent_class ( ) as * mut ffi:: GApplicationClass ;
@@ -196,7 +197,7 @@ impl<T: ApplicationImpl> ApplicationImplExt for T {
196
197
197
198
match res {
198
199
glib:: ffi:: GFALSE => None ,
199
- _ => Some ( exit_status) ,
200
+ _ => Some ( exit_status. into ( ) ) ,
200
201
}
201
202
}
202
203
}
@@ -261,7 +262,7 @@ impl<T: ApplicationImpl> ApplicationImplExt for T {
261
262
}
262
263
}
263
264
264
- fn parent_handle_local_options ( & self , options : & VariantDict ) -> i32 {
265
+ fn parent_handle_local_options ( & self , options : & VariantDict ) -> ExitCode {
265
266
unsafe {
266
267
let data = T :: type_data ( ) ;
267
268
let parent_class = data. as_ref ( ) . parent_class ( ) as * mut ffi:: GApplicationClass ;
@@ -270,9 +271,10 @@ impl<T: ApplicationImpl> ApplicationImplExt for T {
270
271
self . obj ( ) . unsafe_cast_ref :: < Application > ( ) . to_glib_none ( ) . 0 ,
271
272
options. to_glib_none ( ) . 0 ,
272
273
)
274
+ . into ( )
273
275
} else {
274
276
// Continue default handling
275
- - 1
277
+ ExitCode :: from ( - 1 )
276
278
}
277
279
}
278
280
}
@@ -329,7 +331,7 @@ unsafe extern "C" fn application_command_line<T: ApplicationImpl>(
329
331
let instance = & * ( ptr as * mut T :: Instance ) ;
330
332
let imp = instance. imp ( ) ;
331
333
332
- imp. command_line ( & from_glib_borrow ( command_line) )
334
+ imp. command_line ( & from_glib_borrow ( command_line) ) . into ( )
333
335
}
334
336
unsafe extern "C" fn application_local_command_line < T : ApplicationImpl > (
335
337
ptr : * mut ffi:: GApplication ,
@@ -340,7 +342,7 @@ unsafe extern "C" fn application_local_command_line<T: ApplicationImpl>(
340
342
let imp = instance. imp ( ) ;
341
343
342
344
let mut args = ArgumentList :: new ( arguments) ;
343
- let res = imp. local_command_line ( & mut args) ;
345
+ let res = imp. local_command_line ( & mut args) . map ( i32 :: from ) ;
344
346
args. refresh ( ) ;
345
347
346
348
match res {
@@ -395,7 +397,7 @@ unsafe extern "C" fn application_handle_local_options<T: ApplicationImpl>(
395
397
let instance = & * ( ptr as * mut T :: Instance ) ;
396
398
let imp = instance. imp ( ) ;
397
399
398
- imp. handle_local_options ( & from_glib_borrow ( options) )
400
+ imp. handle_local_options ( & from_glib_borrow ( options) ) . into ( )
399
401
}
400
402
401
403
#[ cfg( test) ]
@@ -421,7 +423,7 @@ mod tests {
421
423
impl ObjectImpl for SimpleApplication { }
422
424
423
425
impl ApplicationImpl for SimpleApplication {
424
- fn command_line ( & self , cmd_line : & crate :: ApplicationCommandLine ) -> i32 {
426
+ fn command_line ( & self , cmd_line : & crate :: ApplicationCommandLine ) -> ExitCode {
425
427
let arguments = cmd_line. arguments ( ) ;
426
428
427
429
for arg in arguments {
@@ -430,10 +432,10 @@ mod tests {
430
432
assert ! ( !a. starts_with( "--local-" ) )
431
433
}
432
434
433
- EXIT_STATUS
435
+ EXIT_STATUS . into ( )
434
436
}
435
437
436
- fn local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < i32 > {
438
+ fn local_command_line ( & self , arguments : & mut ArgumentList ) -> Option < ExitCode > {
437
439
let mut rm = Vec :: new ( ) ;
438
440
439
441
for ( i, line) in arguments. iter ( ) . enumerate ( ) {
@@ -469,6 +471,6 @@ mod tests {
469
471
470
472
app. set_inactivity_timeout ( 10000 ) ;
471
473
472
- assert_eq ! ( app. run_with_args( & [ "--local" ] ) , EXIT_STATUS ) ;
474
+ assert_eq ! ( app. run_with_args( & [ "--local" ] ) , EXIT_STATUS . into ( ) ) ;
473
475
}
474
476
}
0 commit comments