@@ -16,40 +16,45 @@ mod sealed {
16
16
pub trait FileChooserExtManual : sealed:: Sealed + IsA < FileChooser > + ' static {
17
17
#[ doc( alias = "gtk_file_chooser_add_choice" ) ]
18
18
fn add_choice ( & self , id : impl IntoGStr , label : impl IntoGStr , options : & [ ( & str , & str ) ] ) {
19
- unsafe {
20
- let ( options_ids, options_labels) = if options. is_empty ( ) {
21
- ( std:: ptr:: null ( ) , std:: ptr:: null ( ) )
22
- } else {
23
- let stashes_ids = options
24
- . iter ( )
25
- . map ( |o| o. 0 . to_glib_none ( ) )
26
- . collect :: < Vec < _ > > ( ) ;
27
- let stashes_labels = options
28
- . iter ( )
29
- . map ( |o| o. 1 . to_glib_none ( ) )
30
- . collect :: < Vec < _ > > ( ) ;
31
- (
32
- stashes_ids
33
- . iter ( )
34
- . map ( |o| o. 0 )
35
- . collect :: < Vec < * const libc:: c_char > > ( )
36
- . as_ptr ( ) ,
37
- stashes_labels
38
- . iter ( )
39
- . map ( |o| o. 0 )
40
- . collect :: < Vec < * const libc:: c_char > > ( )
41
- . as_ptr ( ) ,
42
- )
43
- } ;
44
-
19
+ if options. is_empty ( ) {
20
+ id. run_with_gstr ( |id| {
21
+ label. run_with_gstr ( |label| unsafe {
22
+ ffi:: gtk_file_chooser_add_choice (
23
+ self . as_ref ( ) . to_glib_none ( ) . 0 ,
24
+ id. as_ptr ( ) ,
25
+ label. as_ptr ( ) ,
26
+ mut_override ( std:: ptr:: null ( ) ) ,
27
+ mut_override ( std:: ptr:: null ( ) ) ,
28
+ ) ;
29
+ } ) ;
30
+ } ) ;
31
+ } else {
32
+ let stashes_ids = options
33
+ . iter ( )
34
+ . map ( |o| o. 0 . to_glib_none ( ) )
35
+ . collect :: < Vec < _ > > ( ) ;
36
+ let stashes_labels = options
37
+ . iter ( )
38
+ . map ( |o| o. 1 . to_glib_none ( ) )
39
+ . collect :: < Vec < _ > > ( ) ;
40
+ let options_ids = stashes_ids
41
+ . iter ( )
42
+ . map ( |o| o. 0 )
43
+ . chain ( std:: iter:: once ( std:: ptr:: null ( ) ) )
44
+ . collect :: < Vec < * const libc:: c_char > > ( ) ;
45
+ let options_labels = stashes_labels
46
+ . iter ( )
47
+ . map ( |o| o. 0 )
48
+ . chain ( std:: iter:: once ( std:: ptr:: null ( ) ) )
49
+ . collect :: < Vec < * const libc:: c_char > > ( ) ;
45
50
id. run_with_gstr ( |id| {
46
- label. run_with_gstr ( |label| {
51
+ label. run_with_gstr ( |label| unsafe {
47
52
ffi:: gtk_file_chooser_add_choice (
48
53
self . as_ref ( ) . to_glib_none ( ) . 0 ,
49
54
id. as_ptr ( ) ,
50
55
label. as_ptr ( ) ,
51
- mut_override ( options_ids) ,
52
- mut_override ( options_labels) ,
56
+ mut_override ( options_ids. as_ptr ( ) ) ,
57
+ mut_override ( options_labels. as_ptr ( ) ) ,
53
58
) ;
54
59
} ) ;
55
60
} ) ;
0 commit comments