1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from gir-files (https://github.com/gtk-rs/gir-files) 3 // DO NOT EDIT 4 5 use gio_sys; 6 use glib; 7 use glib::object::Cast; 8 use glib::object::IsA; 9 use glib::signal::connect_raw; 10 use glib::signal::SignalHandlerId; 11 use glib::translate::*; 12 use glib::GString; 13 use glib_sys; 14 use std; 15 use std::boxed::Box as Box_; 16 use std::fmt; 17 use std::mem; 18 use std::mem::transmute; 19 use File; 20 use InputStream; 21 22 glib_wrapper! { 23 pub struct ApplicationCommandLine(Object<gio_sys::GApplicationCommandLine, gio_sys::GApplicationCommandLineClass, ApplicationCommandLineClass>); 24 25 match fn { 26 get_type => || gio_sys::g_application_command_line_get_type(), 27 } 28 } 29 30 pub const NONE_APPLICATION_COMMAND_LINE: Option<&ApplicationCommandLine> = None; 31 32 pub trait ApplicationCommandLineExt: 'static { create_file_for_arg<P: AsRef<std::ffi::OsStr>>(&self, arg: P) -> Option<File>33 fn create_file_for_arg<P: AsRef<std::ffi::OsStr>>(&self, arg: P) -> Option<File>; 34 get_arguments(&self) -> Vec<std::ffi::OsString>35 fn get_arguments(&self) -> Vec<std::ffi::OsString>; 36 get_cwd(&self) -> Option<std::path::PathBuf>37 fn get_cwd(&self) -> Option<std::path::PathBuf>; 38 get_environ(&self) -> Vec<std::ffi::OsString>39 fn get_environ(&self) -> Vec<std::ffi::OsString>; 40 get_exit_status(&self) -> i3241 fn get_exit_status(&self) -> i32; 42 get_is_remote(&self) -> bool43 fn get_is_remote(&self) -> bool; 44 45 //fn get_options_dict(&self) -> /*Ignored*/Option<glib::VariantDict>; 46 get_platform_data(&self) -> Option<glib::Variant>47 fn get_platform_data(&self) -> Option<glib::Variant>; 48 get_stdin(&self) -> Option<InputStream>49 fn get_stdin(&self) -> Option<InputStream>; 50 getenv<P: AsRef<std::ffi::OsStr>>(&self, name: P) -> Option<GString>51 fn getenv<P: AsRef<std::ffi::OsStr>>(&self, name: P) -> Option<GString>; 52 53 //fn print(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); 54 55 //fn printerr(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); 56 set_exit_status(&self, exit_status: i32)57 fn set_exit_status(&self, exit_status: i32); 58 connect_property_is_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId59 fn connect_property_is_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 60 } 61 62 impl<O: IsA<ApplicationCommandLine>> ApplicationCommandLineExt for O { create_file_for_arg<P: AsRef<std::ffi::OsStr>>(&self, arg: P) -> Option<File>63 fn create_file_for_arg<P: AsRef<std::ffi::OsStr>>(&self, arg: P) -> Option<File> { 64 unsafe { 65 from_glib_full(gio_sys::g_application_command_line_create_file_for_arg( 66 self.as_ref().to_glib_none().0, 67 arg.as_ref().to_glib_none().0, 68 )) 69 } 70 } 71 get_arguments(&self) -> Vec<std::ffi::OsString>72 fn get_arguments(&self) -> Vec<std::ffi::OsString> { 73 unsafe { 74 let mut argc = mem::MaybeUninit::uninit(); 75 let ret = FromGlibContainer::from_glib_full_num( 76 gio_sys::g_application_command_line_get_arguments( 77 self.as_ref().to_glib_none().0, 78 argc.as_mut_ptr(), 79 ), 80 argc.assume_init() as usize, 81 ); 82 ret 83 } 84 } 85 get_cwd(&self) -> Option<std::path::PathBuf>86 fn get_cwd(&self) -> Option<std::path::PathBuf> { 87 unsafe { 88 from_glib_none(gio_sys::g_application_command_line_get_cwd( 89 self.as_ref().to_glib_none().0, 90 )) 91 } 92 } 93 get_environ(&self) -> Vec<std::ffi::OsString>94 fn get_environ(&self) -> Vec<std::ffi::OsString> { 95 unsafe { 96 FromGlibPtrContainer::from_glib_none(gio_sys::g_application_command_line_get_environ( 97 self.as_ref().to_glib_none().0, 98 )) 99 } 100 } 101 get_exit_status(&self) -> i32102 fn get_exit_status(&self) -> i32 { 103 unsafe { 104 gio_sys::g_application_command_line_get_exit_status(self.as_ref().to_glib_none().0) 105 } 106 } 107 get_is_remote(&self) -> bool108 fn get_is_remote(&self) -> bool { 109 unsafe { 110 from_glib(gio_sys::g_application_command_line_get_is_remote( 111 self.as_ref().to_glib_none().0, 112 )) 113 } 114 } 115 116 //fn get_options_dict(&self) -> /*Ignored*/Option<glib::VariantDict> { 117 // unsafe { TODO: call gio_sys:g_application_command_line_get_options_dict() } 118 //} 119 get_platform_data(&self) -> Option<glib::Variant>120 fn get_platform_data(&self) -> Option<glib::Variant> { 121 unsafe { 122 from_glib_full(gio_sys::g_application_command_line_get_platform_data( 123 self.as_ref().to_glib_none().0, 124 )) 125 } 126 } 127 get_stdin(&self) -> Option<InputStream>128 fn get_stdin(&self) -> Option<InputStream> { 129 unsafe { 130 from_glib_full(gio_sys::g_application_command_line_get_stdin( 131 self.as_ref().to_glib_none().0, 132 )) 133 } 134 } 135 getenv<P: AsRef<std::ffi::OsStr>>(&self, name: P) -> Option<GString>136 fn getenv<P: AsRef<std::ffi::OsStr>>(&self, name: P) -> Option<GString> { 137 unsafe { 138 from_glib_none(gio_sys::g_application_command_line_getenv( 139 self.as_ref().to_glib_none().0, 140 name.as_ref().to_glib_none().0, 141 )) 142 } 143 } 144 145 //fn print(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { 146 // unsafe { TODO: call gio_sys:g_application_command_line_print() } 147 //} 148 149 //fn printerr(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { 150 // unsafe { TODO: call gio_sys:g_application_command_line_printerr() } 151 //} 152 set_exit_status(&self, exit_status: i32)153 fn set_exit_status(&self, exit_status: i32) { 154 unsafe { 155 gio_sys::g_application_command_line_set_exit_status( 156 self.as_ref().to_glib_none().0, 157 exit_status, 158 ); 159 } 160 } 161 connect_property_is_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId162 fn connect_property_is_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 163 unsafe extern "C" fn notify_is_remote_trampoline<P, F: Fn(&P) + 'static>( 164 this: *mut gio_sys::GApplicationCommandLine, 165 _param_spec: glib_sys::gpointer, 166 f: glib_sys::gpointer, 167 ) where 168 P: IsA<ApplicationCommandLine>, 169 { 170 let f: &F = &*(f as *const F); 171 f(&ApplicationCommandLine::from_glib_borrow(this).unsafe_cast()) 172 } 173 unsafe { 174 let f: Box_<F> = Box_::new(f); 175 connect_raw( 176 self.as_ptr() as *mut _, 177 b"notify::is-remote\0".as_ptr() as *const _, 178 Some(transmute(notify_is_remote_trampoline::<Self, F> as usize)), 179 Box_::into_raw(f), 180 ) 181 } 182 } 183 } 184 185 impl fmt::Display for ApplicationCommandLine { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result186 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 187 write!(f, "ApplicationCommandLine") 188 } 189 } 190