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::IsA; 8 use glib::translate::*; 9 use glib::GString; 10 use std; 11 use std::fmt; 12 use FileAttributeMatcher; 13 use FileAttributeStatus; 14 use FileAttributeType; 15 use FileType; 16 use Icon; 17 18 glib_wrapper! { 19 pub struct FileInfo(Object<gio_sys::GFileInfo, gio_sys::GFileInfoClass, FileInfoClass>); 20 21 match fn { 22 get_type => || gio_sys::g_file_info_get_type(), 23 } 24 } 25 26 impl FileInfo { new() -> FileInfo27 pub fn new() -> FileInfo { 28 unsafe { from_glib_full(gio_sys::g_file_info_new()) } 29 } 30 clear_status(&self)31 pub fn clear_status(&self) { 32 unsafe { 33 gio_sys::g_file_info_clear_status(self.to_glib_none().0); 34 } 35 } 36 copy_into(&self, dest_info: &FileInfo)37 pub fn copy_into(&self, dest_info: &FileInfo) { 38 unsafe { 39 gio_sys::g_file_info_copy_into(self.to_glib_none().0, dest_info.to_glib_none().0); 40 } 41 } 42 dup(&self) -> Option<FileInfo>43 pub fn dup(&self) -> Option<FileInfo> { 44 unsafe { from_glib_full(gio_sys::g_file_info_dup(self.to_glib_none().0)) } 45 } 46 get_attribute_as_string(&self, attribute: &str) -> Option<GString>47 pub fn get_attribute_as_string(&self, attribute: &str) -> Option<GString> { 48 unsafe { 49 from_glib_full(gio_sys::g_file_info_get_attribute_as_string( 50 self.to_glib_none().0, 51 attribute.to_glib_none().0, 52 )) 53 } 54 } 55 get_attribute_boolean(&self, attribute: &str) -> bool56 pub fn get_attribute_boolean(&self, attribute: &str) -> bool { 57 unsafe { 58 from_glib(gio_sys::g_file_info_get_attribute_boolean( 59 self.to_glib_none().0, 60 attribute.to_glib_none().0, 61 )) 62 } 63 } 64 get_attribute_byte_string(&self, attribute: &str) -> Option<GString>65 pub fn get_attribute_byte_string(&self, attribute: &str) -> Option<GString> { 66 unsafe { 67 from_glib_none(gio_sys::g_file_info_get_attribute_byte_string( 68 self.to_glib_none().0, 69 attribute.to_glib_none().0, 70 )) 71 } 72 } 73 74 //pub fn get_attribute_data(&self, attribute: &str, value_pp: /*Unimplemented*/&mut Fundamental: Pointer) -> Option<(FileAttributeType, FileAttributeStatus)> { 75 // unsafe { TODO: call gio_sys:g_file_info_get_attribute_data() } 76 //} 77 get_attribute_int32(&self, attribute: &str) -> i3278 pub fn get_attribute_int32(&self, attribute: &str) -> i32 { 79 unsafe { 80 gio_sys::g_file_info_get_attribute_int32( 81 self.to_glib_none().0, 82 attribute.to_glib_none().0, 83 ) 84 } 85 } 86 get_attribute_int64(&self, attribute: &str) -> i6487 pub fn get_attribute_int64(&self, attribute: &str) -> i64 { 88 unsafe { 89 gio_sys::g_file_info_get_attribute_int64( 90 self.to_glib_none().0, 91 attribute.to_glib_none().0, 92 ) 93 } 94 } 95 get_attribute_object(&self, attribute: &str) -> Option<glib::Object>96 pub fn get_attribute_object(&self, attribute: &str) -> Option<glib::Object> { 97 unsafe { 98 from_glib_none(gio_sys::g_file_info_get_attribute_object( 99 self.to_glib_none().0, 100 attribute.to_glib_none().0, 101 )) 102 } 103 } 104 get_attribute_status(&self, attribute: &str) -> FileAttributeStatus105 pub fn get_attribute_status(&self, attribute: &str) -> FileAttributeStatus { 106 unsafe { 107 from_glib(gio_sys::g_file_info_get_attribute_status( 108 self.to_glib_none().0, 109 attribute.to_glib_none().0, 110 )) 111 } 112 } 113 get_attribute_string(&self, attribute: &str) -> Option<GString>114 pub fn get_attribute_string(&self, attribute: &str) -> Option<GString> { 115 unsafe { 116 from_glib_none(gio_sys::g_file_info_get_attribute_string( 117 self.to_glib_none().0, 118 attribute.to_glib_none().0, 119 )) 120 } 121 } 122 get_attribute_stringv(&self, attribute: &str) -> Vec<GString>123 pub fn get_attribute_stringv(&self, attribute: &str) -> Vec<GString> { 124 unsafe { 125 FromGlibPtrContainer::from_glib_none(gio_sys::g_file_info_get_attribute_stringv( 126 self.to_glib_none().0, 127 attribute.to_glib_none().0, 128 )) 129 } 130 } 131 get_attribute_type(&self, attribute: &str) -> FileAttributeType132 pub fn get_attribute_type(&self, attribute: &str) -> FileAttributeType { 133 unsafe { 134 from_glib(gio_sys::g_file_info_get_attribute_type( 135 self.to_glib_none().0, 136 attribute.to_glib_none().0, 137 )) 138 } 139 } 140 get_attribute_uint32(&self, attribute: &str) -> u32141 pub fn get_attribute_uint32(&self, attribute: &str) -> u32 { 142 unsafe { 143 gio_sys::g_file_info_get_attribute_uint32( 144 self.to_glib_none().0, 145 attribute.to_glib_none().0, 146 ) 147 } 148 } 149 get_attribute_uint64(&self, attribute: &str) -> u64150 pub fn get_attribute_uint64(&self, attribute: &str) -> u64 { 151 unsafe { 152 gio_sys::g_file_info_get_attribute_uint64( 153 self.to_glib_none().0, 154 attribute.to_glib_none().0, 155 ) 156 } 157 } 158 get_content_type(&self) -> Option<GString>159 pub fn get_content_type(&self) -> Option<GString> { 160 unsafe { from_glib_none(gio_sys::g_file_info_get_content_type(self.to_glib_none().0)) } 161 } 162 get_deletion_date(&self) -> Option<glib::DateTime>163 pub fn get_deletion_date(&self) -> Option<glib::DateTime> { 164 unsafe { 165 from_glib_full(gio_sys::g_file_info_get_deletion_date( 166 self.to_glib_none().0, 167 )) 168 } 169 } 170 get_display_name(&self) -> Option<GString>171 pub fn get_display_name(&self) -> Option<GString> { 172 unsafe { from_glib_none(gio_sys::g_file_info_get_display_name(self.to_glib_none().0)) } 173 } 174 get_edit_name(&self) -> Option<GString>175 pub fn get_edit_name(&self) -> Option<GString> { 176 unsafe { from_glib_none(gio_sys::g_file_info_get_edit_name(self.to_glib_none().0)) } 177 } 178 get_etag(&self) -> Option<GString>179 pub fn get_etag(&self) -> Option<GString> { 180 unsafe { from_glib_none(gio_sys::g_file_info_get_etag(self.to_glib_none().0)) } 181 } 182 get_file_type(&self) -> FileType183 pub fn get_file_type(&self) -> FileType { 184 unsafe { from_glib(gio_sys::g_file_info_get_file_type(self.to_glib_none().0)) } 185 } 186 get_icon(&self) -> Option<Icon>187 pub fn get_icon(&self) -> Option<Icon> { 188 unsafe { from_glib_none(gio_sys::g_file_info_get_icon(self.to_glib_none().0)) } 189 } 190 get_is_backup(&self) -> bool191 pub fn get_is_backup(&self) -> bool { 192 unsafe { from_glib(gio_sys::g_file_info_get_is_backup(self.to_glib_none().0)) } 193 } 194 get_is_hidden(&self) -> bool195 pub fn get_is_hidden(&self) -> bool { 196 unsafe { from_glib(gio_sys::g_file_info_get_is_hidden(self.to_glib_none().0)) } 197 } 198 get_is_symlink(&self) -> bool199 pub fn get_is_symlink(&self) -> bool { 200 unsafe { from_glib(gio_sys::g_file_info_get_is_symlink(self.to_glib_none().0)) } 201 } 202 203 #[cfg(any(feature = "v2_62", feature = "dox"))] get_modification_date_time(&self) -> Option<glib::DateTime>204 pub fn get_modification_date_time(&self) -> Option<glib::DateTime> { 205 unsafe { 206 from_glib_full(gio_sys::g_file_info_get_modification_date_time( 207 self.to_glib_none().0, 208 )) 209 } 210 } 211 212 #[cfg_attr(feature = "v2_62", deprecated)] get_modification_time(&self) -> glib::TimeVal213 pub fn get_modification_time(&self) -> glib::TimeVal { 214 unsafe { 215 let mut result = glib::TimeVal::uninitialized(); 216 gio_sys::g_file_info_get_modification_time( 217 self.to_glib_none().0, 218 result.to_glib_none_mut().0, 219 ); 220 result 221 } 222 } 223 get_name(&self) -> Option<std::path::PathBuf>224 pub fn get_name(&self) -> Option<std::path::PathBuf> { 225 unsafe { from_glib_none(gio_sys::g_file_info_get_name(self.to_glib_none().0)) } 226 } 227 get_size(&self) -> i64228 pub fn get_size(&self) -> i64 { 229 unsafe { gio_sys::g_file_info_get_size(self.to_glib_none().0) } 230 } 231 get_sort_order(&self) -> i32232 pub fn get_sort_order(&self) -> i32 { 233 unsafe { gio_sys::g_file_info_get_sort_order(self.to_glib_none().0) } 234 } 235 get_symbolic_icon(&self) -> Option<Icon>236 pub fn get_symbolic_icon(&self) -> Option<Icon> { 237 unsafe { 238 from_glib_none(gio_sys::g_file_info_get_symbolic_icon( 239 self.to_glib_none().0, 240 )) 241 } 242 } 243 get_symlink_target(&self) -> Option<GString>244 pub fn get_symlink_target(&self) -> Option<GString> { 245 unsafe { 246 from_glib_none(gio_sys::g_file_info_get_symlink_target( 247 self.to_glib_none().0, 248 )) 249 } 250 } 251 has_attribute(&self, attribute: &str) -> bool252 pub fn has_attribute(&self, attribute: &str) -> bool { 253 unsafe { 254 from_glib(gio_sys::g_file_info_has_attribute( 255 self.to_glib_none().0, 256 attribute.to_glib_none().0, 257 )) 258 } 259 } 260 has_namespace(&self, name_space: &str) -> bool261 pub fn has_namespace(&self, name_space: &str) -> bool { 262 unsafe { 263 from_glib(gio_sys::g_file_info_has_namespace( 264 self.to_glib_none().0, 265 name_space.to_glib_none().0, 266 )) 267 } 268 } 269 list_attributes(&self, name_space: Option<&str>) -> Vec<GString>270 pub fn list_attributes(&self, name_space: Option<&str>) -> Vec<GString> { 271 unsafe { 272 FromGlibPtrContainer::from_glib_full(gio_sys::g_file_info_list_attributes( 273 self.to_glib_none().0, 274 name_space.to_glib_none().0, 275 )) 276 } 277 } 278 remove_attribute(&self, attribute: &str)279 pub fn remove_attribute(&self, attribute: &str) { 280 unsafe { 281 gio_sys::g_file_info_remove_attribute( 282 self.to_glib_none().0, 283 attribute.to_glib_none().0, 284 ); 285 } 286 } 287 288 //pub fn set_attribute(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Fundamental: Pointer) { 289 // unsafe { TODO: call gio_sys:g_file_info_set_attribute() } 290 //} 291 set_attribute_boolean(&self, attribute: &str, attr_value: bool)292 pub fn set_attribute_boolean(&self, attribute: &str, attr_value: bool) { 293 unsafe { 294 gio_sys::g_file_info_set_attribute_boolean( 295 self.to_glib_none().0, 296 attribute.to_glib_none().0, 297 attr_value.to_glib(), 298 ); 299 } 300 } 301 set_attribute_byte_string(&self, attribute: &str, attr_value: &str)302 pub fn set_attribute_byte_string(&self, attribute: &str, attr_value: &str) { 303 unsafe { 304 gio_sys::g_file_info_set_attribute_byte_string( 305 self.to_glib_none().0, 306 attribute.to_glib_none().0, 307 attr_value.to_glib_none().0, 308 ); 309 } 310 } 311 set_attribute_int32(&self, attribute: &str, attr_value: i32)312 pub fn set_attribute_int32(&self, attribute: &str, attr_value: i32) { 313 unsafe { 314 gio_sys::g_file_info_set_attribute_int32( 315 self.to_glib_none().0, 316 attribute.to_glib_none().0, 317 attr_value, 318 ); 319 } 320 } 321 set_attribute_int64(&self, attribute: &str, attr_value: i64)322 pub fn set_attribute_int64(&self, attribute: &str, attr_value: i64) { 323 unsafe { 324 gio_sys::g_file_info_set_attribute_int64( 325 self.to_glib_none().0, 326 attribute.to_glib_none().0, 327 attr_value, 328 ); 329 } 330 } 331 set_attribute_mask(&self, mask: &FileAttributeMatcher)332 pub fn set_attribute_mask(&self, mask: &FileAttributeMatcher) { 333 unsafe { 334 gio_sys::g_file_info_set_attribute_mask(self.to_glib_none().0, mask.to_glib_none().0); 335 } 336 } 337 set_attribute_object<P: IsA<glib::Object>>(&self, attribute: &str, attr_value: &P)338 pub fn set_attribute_object<P: IsA<glib::Object>>(&self, attribute: &str, attr_value: &P) { 339 unsafe { 340 gio_sys::g_file_info_set_attribute_object( 341 self.to_glib_none().0, 342 attribute.to_glib_none().0, 343 attr_value.as_ref().to_glib_none().0, 344 ); 345 } 346 } 347 set_attribute_status(&self, attribute: &str, status: FileAttributeStatus) -> bool348 pub fn set_attribute_status(&self, attribute: &str, status: FileAttributeStatus) -> bool { 349 unsafe { 350 from_glib(gio_sys::g_file_info_set_attribute_status( 351 self.to_glib_none().0, 352 attribute.to_glib_none().0, 353 status.to_glib(), 354 )) 355 } 356 } 357 set_attribute_string(&self, attribute: &str, attr_value: &str)358 pub fn set_attribute_string(&self, attribute: &str, attr_value: &str) { 359 unsafe { 360 gio_sys::g_file_info_set_attribute_string( 361 self.to_glib_none().0, 362 attribute.to_glib_none().0, 363 attr_value.to_glib_none().0, 364 ); 365 } 366 } 367 set_attribute_stringv(&self, attribute: &str, attr_value: &[&str])368 pub fn set_attribute_stringv(&self, attribute: &str, attr_value: &[&str]) { 369 unsafe { 370 gio_sys::g_file_info_set_attribute_stringv( 371 self.to_glib_none().0, 372 attribute.to_glib_none().0, 373 attr_value.to_glib_none().0, 374 ); 375 } 376 } 377 set_attribute_uint32(&self, attribute: &str, attr_value: u32)378 pub fn set_attribute_uint32(&self, attribute: &str, attr_value: u32) { 379 unsafe { 380 gio_sys::g_file_info_set_attribute_uint32( 381 self.to_glib_none().0, 382 attribute.to_glib_none().0, 383 attr_value, 384 ); 385 } 386 } 387 set_attribute_uint64(&self, attribute: &str, attr_value: u64)388 pub fn set_attribute_uint64(&self, attribute: &str, attr_value: u64) { 389 unsafe { 390 gio_sys::g_file_info_set_attribute_uint64( 391 self.to_glib_none().0, 392 attribute.to_glib_none().0, 393 attr_value, 394 ); 395 } 396 } 397 set_content_type(&self, content_type: &str)398 pub fn set_content_type(&self, content_type: &str) { 399 unsafe { 400 gio_sys::g_file_info_set_content_type( 401 self.to_glib_none().0, 402 content_type.to_glib_none().0, 403 ); 404 } 405 } 406 set_display_name(&self, display_name: &str)407 pub fn set_display_name(&self, display_name: &str) { 408 unsafe { 409 gio_sys::g_file_info_set_display_name( 410 self.to_glib_none().0, 411 display_name.to_glib_none().0, 412 ); 413 } 414 } 415 set_edit_name(&self, edit_name: &str)416 pub fn set_edit_name(&self, edit_name: &str) { 417 unsafe { 418 gio_sys::g_file_info_set_edit_name(self.to_glib_none().0, edit_name.to_glib_none().0); 419 } 420 } 421 set_file_type(&self, type_: FileType)422 pub fn set_file_type(&self, type_: FileType) { 423 unsafe { 424 gio_sys::g_file_info_set_file_type(self.to_glib_none().0, type_.to_glib()); 425 } 426 } 427 set_icon<P: IsA<Icon>>(&self, icon: &P)428 pub fn set_icon<P: IsA<Icon>>(&self, icon: &P) { 429 unsafe { 430 gio_sys::g_file_info_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0); 431 } 432 } 433 set_is_hidden(&self, is_hidden: bool)434 pub fn set_is_hidden(&self, is_hidden: bool) { 435 unsafe { 436 gio_sys::g_file_info_set_is_hidden(self.to_glib_none().0, is_hidden.to_glib()); 437 } 438 } 439 set_is_symlink(&self, is_symlink: bool)440 pub fn set_is_symlink(&self, is_symlink: bool) { 441 unsafe { 442 gio_sys::g_file_info_set_is_symlink(self.to_glib_none().0, is_symlink.to_glib()); 443 } 444 } 445 446 #[cfg(any(feature = "v2_62", feature = "dox"))] set_modification_date_time(&self, mtime: &glib::DateTime)447 pub fn set_modification_date_time(&self, mtime: &glib::DateTime) { 448 unsafe { 449 gio_sys::g_file_info_set_modification_date_time( 450 self.to_glib_none().0, 451 mtime.to_glib_none().0, 452 ); 453 } 454 } 455 456 #[cfg_attr(feature = "v2_62", deprecated)] set_modification_time(&self, mtime: &mut glib::TimeVal)457 pub fn set_modification_time(&self, mtime: &mut glib::TimeVal) { 458 unsafe { 459 gio_sys::g_file_info_set_modification_time( 460 self.to_glib_none().0, 461 mtime.to_glib_none_mut().0, 462 ); 463 } 464 } 465 set_name<P: AsRef<std::path::Path>>(&self, name: P)466 pub fn set_name<P: AsRef<std::path::Path>>(&self, name: P) { 467 unsafe { 468 gio_sys::g_file_info_set_name(self.to_glib_none().0, name.as_ref().to_glib_none().0); 469 } 470 } 471 set_size(&self, size: i64)472 pub fn set_size(&self, size: i64) { 473 unsafe { 474 gio_sys::g_file_info_set_size(self.to_glib_none().0, size); 475 } 476 } 477 set_sort_order(&self, sort_order: i32)478 pub fn set_sort_order(&self, sort_order: i32) { 479 unsafe { 480 gio_sys::g_file_info_set_sort_order(self.to_glib_none().0, sort_order); 481 } 482 } 483 set_symbolic_icon<P: IsA<Icon>>(&self, icon: &P)484 pub fn set_symbolic_icon<P: IsA<Icon>>(&self, icon: &P) { 485 unsafe { 486 gio_sys::g_file_info_set_symbolic_icon( 487 self.to_glib_none().0, 488 icon.as_ref().to_glib_none().0, 489 ); 490 } 491 } 492 set_symlink_target(&self, symlink_target: &str)493 pub fn set_symlink_target(&self, symlink_target: &str) { 494 unsafe { 495 gio_sys::g_file_info_set_symlink_target( 496 self.to_glib_none().0, 497 symlink_target.to_glib_none().0, 498 ); 499 } 500 } 501 unset_attribute_mask(&self)502 pub fn unset_attribute_mask(&self) { 503 unsafe { 504 gio_sys::g_file_info_unset_attribute_mask(self.to_glib_none().0); 505 } 506 } 507 } 508 509 impl Default for FileInfo { default() -> Self510 fn default() -> Self { 511 Self::new() 512 } 513 } 514 515 impl fmt::Display for FileInfo { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result516 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 517 write!(f, "FileInfo") 518 } 519 } 520