Skip to content

Commit 658073d

Browse files
committed
gio: use StrV for the file_info API
1 parent 89905bd commit 658073d

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

gio/Gir.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,14 @@ status = "generate"
806806
name = "set_modification_time"
807807
# use SystemTime
808808
manual = true
809+
[[object.function]]
810+
name = "get_attribute_stringv"
811+
# use strv
812+
manual = true
813+
[[object.function]]
814+
name = "set_attribute_stringv"
815+
# use strv
816+
manual = true
809817

810818
[[object]]
811819
name = "Gio.FilterOutputStream"

gio/src/auto/file_info.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,6 @@ impl FileInfo {
138138
}
139139
}
140140

141-
#[doc(alias = "g_file_info_get_attribute_stringv")]
142-
#[doc(alias = "get_attribute_stringv")]
143-
pub fn attribute_stringv(&self, attribute: &str) -> Vec<glib::GString> {
144-
unsafe {
145-
FromGlibPtrContainer::from_glib_none(ffi::g_file_info_get_attribute_stringv(
146-
self.to_glib_none().0,
147-
attribute.to_glib_none().0,
148-
))
149-
}
150-
}
151-
152141
#[doc(alias = "g_file_info_get_attribute_type")]
153142
#[doc(alias = "get_attribute_type")]
154143
pub fn attribute_type(&self, attribute: &str) -> FileAttributeType {
@@ -425,17 +414,6 @@ impl FileInfo {
425414
}
426415
}
427416

428-
#[doc(alias = "g_file_info_set_attribute_stringv")]
429-
pub fn set_attribute_stringv(&self, attribute: &str, attr_value: &[&str]) {
430-
unsafe {
431-
ffi::g_file_info_set_attribute_stringv(
432-
self.to_glib_none().0,
433-
attribute.to_glib_none().0,
434-
attr_value.to_glib_none().0,
435-
);
436-
}
437-
}
438-
439417
#[doc(alias = "g_file_info_set_attribute_uint32")]
440418
pub fn set_attribute_uint32(&self, attribute: &str, attr_value: u32) {
441419
unsafe {

gio/src/file_info.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
time::{Duration, SystemTime},
66
};
77

8-
use glib::translate::*;
8+
use glib::{translate::*, IntoStrV, StrV};
99

1010
use crate::FileInfo;
1111

@@ -47,4 +47,28 @@ impl FileInfo {
4747
);
4848
}
4949
}
50+
51+
#[doc(alias = "g_file_info_get_attribute_stringv")]
52+
#[doc(alias = "get_attribute_stringv")]
53+
pub fn attribute_stringv(&self, attribute: &str) -> StrV {
54+
unsafe {
55+
FromGlibPtrContainer::from_glib_none(ffi::g_file_info_get_attribute_stringv(
56+
self.to_glib_none().0,
57+
attribute.to_glib_none().0,
58+
))
59+
}
60+
}
61+
62+
#[doc(alias = "g_file_info_set_attribute_stringv")]
63+
pub fn set_attribute_stringv(&self, attribute: &str, attr_value: impl IntoStrV) {
64+
unsafe {
65+
attr_value.run_with_strv(|attr_value| {
66+
ffi::g_file_info_set_attribute_stringv(
67+
self.to_glib_none().0,
68+
attribute.to_glib_none().0,
69+
attr_value.as_ptr() as *mut _,
70+
);
71+
});
72+
}
73+
}
5074
}

0 commit comments

Comments
 (0)