diff --git a/gio/Gir.toml b/gio/Gir.toml index e4d2012c8543..03f8d8b995e0 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -806,6 +806,14 @@ status = "generate" name = "set_modification_time" # use SystemTime manual = true + [[object.function]] + name = "get_attribute_stringv" + # use strv + manual = true + [[object.function]] + name = "set_attribute_stringv" + # use strv + manual = true [[object]] name = "Gio.FilterOutputStream" @@ -1114,6 +1122,14 @@ status = "generate" [object.function.return] bool_return_is_error = "Can't set readonly key" [[object.function]] + name = "get_strv" + # Use strv + manual = true + [[object.function]] + name = "set_strv" + # Use strv + manual = true + [[object.function]] name = "bind" manual = true [[object.function]] diff --git a/gio/src/auto/file_info.rs b/gio/src/auto/file_info.rs index c42329c88535..5a61b2c27801 100644 --- a/gio/src/auto/file_info.rs +++ b/gio/src/auto/file_info.rs @@ -138,17 +138,6 @@ impl FileInfo { } } - #[doc(alias = "g_file_info_get_attribute_stringv")] - #[doc(alias = "get_attribute_stringv")] - pub fn attribute_stringv(&self, attribute: &str) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_none(ffi::g_file_info_get_attribute_stringv( - self.to_glib_none().0, - attribute.to_glib_none().0, - )) - } - } - #[doc(alias = "g_file_info_get_attribute_type")] #[doc(alias = "get_attribute_type")] pub fn attribute_type(&self, attribute: &str) -> FileAttributeType { @@ -425,17 +414,6 @@ impl FileInfo { } } - #[doc(alias = "g_file_info_set_attribute_stringv")] - pub fn set_attribute_stringv(&self, attribute: &str, attr_value: &[&str]) { - unsafe { - ffi::g_file_info_set_attribute_stringv( - self.to_glib_none().0, - attribute.to_glib_none().0, - attr_value.to_glib_none().0, - ); - } - } - #[doc(alias = "g_file_info_set_attribute_uint32")] pub fn set_attribute_uint32(&self, attribute: &str, attr_value: u32) { unsafe { diff --git a/gio/src/auto/settings.rs b/gio/src/auto/settings.rs index 17e997c1510e..c93916736d08 100644 --- a/gio/src/auto/settings.rs +++ b/gio/src/auto/settings.rs @@ -162,10 +162,6 @@ pub trait SettingsExt: 'static { #[doc(alias = "get_string")] fn string(&self, key: &str) -> glib::GString; - #[doc(alias = "g_settings_get_strv")] - #[doc(alias = "get_strv")] - fn strv(&self, key: &str) -> Vec; - #[doc(alias = "g_settings_get_uint")] #[doc(alias = "get_uint")] fn uint(&self, key: &str) -> u32; @@ -218,9 +214,6 @@ pub trait SettingsExt: 'static { #[doc(alias = "g_settings_set_string")] fn set_string(&self, key: &str, value: &str) -> Result<(), glib::error::BoolError>; - #[doc(alias = "g_settings_set_strv")] - fn set_strv(&self, key: &str, value: &[&str]) -> Result<(), glib::error::BoolError>; - #[doc(alias = "g_settings_set_uint")] fn set_uint(&self, key: &str, value: u32) -> Result<(), glib::error::BoolError>; @@ -385,15 +378,6 @@ impl> SettingsExt for O { } } - fn strv(&self, key: &str) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_full(ffi::g_settings_get_strv( - self.as_ref().to_glib_none().0, - key.to_glib_none().0, - )) - } - } - fn uint(&self, key: &str) -> u32 { unsafe { ffi::g_settings_get_uint(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } @@ -544,19 +528,6 @@ impl> SettingsExt for O { } } - fn set_strv(&self, key: &str, value: &[&str]) -> Result<(), glib::error::BoolError> { - unsafe { - glib::result_from_gboolean!( - ffi::g_settings_set_strv( - self.as_ref().to_glib_none().0, - key.to_glib_none().0, - value.to_glib_none().0 - ), - "Can't set readonly key" - ) - } - } - fn set_uint(&self, key: &str, value: u32) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( diff --git a/gio/src/file_info.rs b/gio/src/file_info.rs index 0b69c846ec8e..0019833d4552 100644 --- a/gio/src/file_info.rs +++ b/gio/src/file_info.rs @@ -5,7 +5,7 @@ use std::{ time::{Duration, SystemTime}, }; -use glib::translate::*; +use glib::{translate::*, IntoStrV, StrV}; use crate::FileInfo; @@ -47,4 +47,28 @@ impl FileInfo { ); } } + + #[doc(alias = "g_file_info_get_attribute_stringv")] + #[doc(alias = "get_attribute_stringv")] + pub fn attribute_stringv(&self, attribute: &str) -> StrV { + unsafe { + FromGlibPtrContainer::from_glib_none(ffi::g_file_info_get_attribute_stringv( + self.to_glib_none().0, + attribute.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_file_info_set_attribute_stringv")] + pub fn set_attribute_stringv(&self, attribute: &str, attr_value: impl IntoStrV) { + unsafe { + attr_value.run_with_strv(|attr_value| { + ffi::g_file_info_set_attribute_stringv( + self.to_glib_none().0, + attribute.to_glib_none().0, + attr_value.as_ptr() as *mut _, + ); + }); + } + } } diff --git a/gio/src/settings.rs b/gio/src/settings.rs index 1cf759a5522b..cf75adf2a50c 100644 --- a/gio/src/settings.rs +++ b/gio/src/settings.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{prelude::*, translate::*, variant::FromVariant, BoolError, Variant}; +use glib::{prelude::*, translate::*, variant::FromVariant, BoolError, IntoStrV, StrV, Variant}; use crate::{prelude::*, Settings, SettingsBindFlags}; @@ -170,6 +170,13 @@ pub trait SettingsExtManual { fn set(&self, key: &str, value: impl Into) -> Result<(), BoolError>; + #[doc(alias = "g_settings_get_strv")] + #[doc(alias = "get_strv")] + fn strv(&self, key: &str) -> StrV; + + #[doc(alias = "g_settings_set_strv")] + fn set_strv(&self, key: &str, value: impl IntoStrV) -> Result<(), glib::error::BoolError>; + #[doc(alias = "g_settings_bind")] #[doc(alias = "g_settings_bind_with_mapping")] fn bind<'a, P: IsA>( @@ -196,6 +203,30 @@ impl> SettingsExtManual for O { self.set_value(key, &value.into()) } + fn strv(&self, key: &str) -> StrV { + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::g_settings_get_strv( + self.as_ref().to_glib_none().0, + key.to_glib_none().0, + )) + } + } + + fn set_strv(&self, key: &str, value: impl IntoStrV) -> Result<(), glib::error::BoolError> { + unsafe { + value.run_with_strv(|value| { + glib::result_from_gboolean!( + ffi::g_settings_set_strv( + self.as_ref().to_glib_none().0, + key.to_glib_none().0, + value.as_ptr() as *mut _, + ), + "Can't set readonly key" + ) + }) + } + } + fn bind<'a, P: IsA>( &'a self, key: &'a str,