Skip to content

Commit

Permalink
New generated code from gir
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcaricio committed May 23, 2021
1 parent e016853 commit 80f23aa
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 47 deletions.
10 changes: 7 additions & 3 deletions gdk-pixbuf/src/auto/pixbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ impl Pixbuf {

#[doc(alias = "gdk_pixbuf_new_from_xpm_data")]
#[doc(alias = "new_from_xpm_data")]
pub fn from_xpm_data(data: &[&str]) -> Pixbuf {
unsafe { from_glib_full(ffi::gdk_pixbuf_new_from_xpm_data(data.to_glib_none().0)) }
pub fn from_xpm_data<P: AsRef<str>>(data: &[P]) -> Pixbuf {
unsafe {
from_glib_full(ffi::gdk_pixbuf_new_from_xpm_data(
data.as_ref().to_glib_none().0,
))
}
}

#[doc(alias = "gdk_pixbuf_add_alpha")]
Expand Down Expand Up @@ -479,7 +483,7 @@ impl Pixbuf {
//}

//#[doc(alias = "gdk_pixbuf_save_to_callbackv")]
//pub fn save_to_callbackv<P: FnMut(&Vec<u8>, usize, &glib::Error) -> bool>(&self, save_func: P, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result<(), glib::Error> {
//pub fn save_to_callbackv<P: FnMut(&Vec<u8>, usize, &glib::Error) -> bool, Q: AsRef<str>, R: AsRef<str>>(&self, save_func: P, type_: &str, option_keys: &[Q], option_values: &[R]) -> Result<(), glib::Error> {
// unsafe { TODO: call ffi:gdk_pixbuf_save_to_callbackv() }
//}

Expand Down
2 changes: 1 addition & 1 deletion gdk-pixbuf/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion gdk-pixbuf/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
7 changes: 6 additions & 1 deletion gio/src/app_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ impl<O: IsA<AppInfo>> AppInfoExtManual for O {
uris: &[S],
context: Option<&P>,
) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
let uris = uris.as_ref().iter().copied().map(String::from).collect::<Vec<_>>();
let uris = uris
.as_ref()
.iter()
.copied()
.map(String::from)
.collect::<Vec<_>>();
let context = context.map(ToOwned::to_owned);
Box_::pin(crate::GioFuture::new(self, move |obj, send| {
let cancellable = Cancellable::new();
Expand Down
14 changes: 7 additions & 7 deletions gio/src/auto/app_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ pub trait AppInfoExt: 'static {
) -> Result<(), glib::Error>;

#[doc(alias = "g_app_info_launch_uris")]
fn launch_uris<P: IsA<AppLaunchContext>>(
fn launch_uris<P: AsRef<str>, Q: IsA<AppLaunchContext>>(
&self,
uris: &[&str],
context: Option<&P>,
uris: &[P],
context: Option<&Q>,
) -> Result<(), glib::Error>;

#[doc(alias = "g_app_info_remove_supports_type")]
Expand Down Expand Up @@ -416,16 +416,16 @@ impl<O: IsA<AppInfo>> AppInfoExt for O {
}
}

fn launch_uris<P: IsA<AppLaunchContext>>(
fn launch_uris<P: AsRef<str>, Q: IsA<AppLaunchContext>>(
&self,
uris: &[&str],
context: Option<&P>,
uris: &[P],
context: Option<&Q>,
) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::g_app_info_launch_uris(
self.as_ref().to_glib_none().0,
uris.to_glib_none().0,
uris.as_ref().to_glib_none().0,
context.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
Expand Down
16 changes: 8 additions & 8 deletions gio/src/auto/desktop_app_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,16 @@ impl DesktopAppInfo {
}

#[doc(alias = "g_desktop_app_info_launch_uris_as_manager")]
pub fn launch_uris_as_manager<P: IsA<AppLaunchContext>>(
pub fn launch_uris_as_manager<P: AsRef<str>, Q: IsA<AppLaunchContext>>(
&self,
uris: &[&str],
launch_context: Option<&P>,
uris: &[P],
launch_context: Option<&Q>,
spawn_flags: glib::SpawnFlags,
user_setup: Option<Box_<dyn FnOnce() + 'static>>,
pid_callback: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))>,
) -> Result<(), glib::Error> {
let user_setup_data: Box_<Option<Box_<dyn FnOnce() + 'static>>> = Box_::new(user_setup);
unsafe extern "C" fn user_setup_func<P: IsA<AppLaunchContext>>(
unsafe extern "C" fn user_setup_func<P: AsRef<str>, Q: IsA<AppLaunchContext>>(
user_data: glib::ffi::gpointer,
) {
let callback: Box_<Option<Box_<dyn FnOnce() + 'static>>> =
Expand All @@ -225,12 +225,12 @@ impl DesktopAppInfo {
callback()
}
let user_setup = if user_setup_data.is_some() {
Some(user_setup_func::<P> as _)
Some(user_setup_func::<P, Q> as _)
} else {
None
};
let pid_callback_data: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))> = pid_callback;
unsafe extern "C" fn pid_callback_func<P: IsA<AppLaunchContext>>(
unsafe extern "C" fn pid_callback_func<P: AsRef<str>, Q: IsA<AppLaunchContext>>(
appinfo: *mut ffi::GDesktopAppInfo,
pid: glib::ffi::GPid,
user_data: glib::ffi::gpointer,
Expand All @@ -247,7 +247,7 @@ impl DesktopAppInfo {
};
}
let pid_callback = if pid_callback_data.is_some() {
Some(pid_callback_func::<P> as _)
Some(pid_callback_func::<P, Q> as _)
} else {
None
};
Expand All @@ -258,7 +258,7 @@ impl DesktopAppInfo {
let mut error = ptr::null_mut();
let _ = ffi::g_desktop_app_info_launch_uris_as_manager(
self.to_glib_none().0,
uris.to_glib_none().0,
uris.as_ref().to_glib_none().0,
launch_context.map(|p| p.as_ref()).to_glib_none().0,
spawn_flags.into_glib(),
user_setup,
Expand Down
4 changes: 2 additions & 2 deletions gio/src/auto/file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ impl FileInfo {
}

#[doc(alias = "g_file_info_set_attribute_stringv")]
pub fn set_attribute_stringv(&self, attribute: &str, attr_value: &[&str]) {
pub fn set_attribute_stringv<P: AsRef<str>>(&self, attribute: &str, attr_value: &[P]) {
unsafe {
ffi::g_file_info_set_attribute_stringv(
self.to_glib_none().0,
attribute.to_glib_none().0,
attr_value.to_glib_none().0,
attr_value.as_ref().to_glib_none().0,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions gio/src/auto/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ pub fn content_type_is_unknown(type_: &str) -> bool {
#[cfg(any(feature = "v2_60", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
#[doc(alias = "g_content_type_set_mime_dirs")]
pub fn content_type_set_mime_dirs(dirs: &[&str]) {
pub fn content_type_set_mime_dirs<P: AsRef<str>>(dirs: &[P]) {
unsafe {
ffi::g_content_type_set_mime_dirs(dirs.to_glib_none().0);
ffi::g_content_type_set_mime_dirs(dirs.as_ref().to_glib_none().0);
}
}

Expand Down
11 changes: 8 additions & 3 deletions gio/src/auto/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ pub trait SettingsExt: 'static {
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>;
fn set_strv<P: AsRef<str>>(&self, key: &str, value: &[P])
-> Result<(), glib::error::BoolError>;

#[doc(alias = "g_settings_set_uint")]
fn set_uint(&self, key: &str, value: u32) -> Result<(), glib::error::BoolError>;
Expand Down Expand Up @@ -561,13 +562,17 @@ impl<O: IsA<Settings>> SettingsExt for O {
}
}

fn set_strv(&self, key: &str, value: &[&str]) -> Result<(), glib::error::BoolError> {
fn set_strv<P: AsRef<str>>(
&self,
key: &str,
value: &[P],
) -> 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
value.as_ref().to_glib_none().0
),
"Can't set readonly key"
)
Expand Down
4 changes: 2 additions & 2 deletions gio/src/auto/settings_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait SettingsBackendExt: 'static {
//fn changed_tree(&self, tree: /*Ignored*/&glib::Tree, origin_tag: /*Unimplemented*/Option<Fundamental: Pointer>);

//#[doc(alias = "g_settings_backend_keys_changed")]
//fn keys_changed(&self, path: &str, items: &[&str], origin_tag: /*Unimplemented*/Option<Fundamental: Pointer>);
//fn keys_changed<P: AsRef<str>>(&self, path: &str, items: &[P], origin_tag: /*Unimplemented*/Option<Fundamental: Pointer>);

//#[doc(alias = "g_settings_backend_path_changed")]
//fn path_changed(&self, path: &str, origin_tag: /*Unimplemented*/Option<Fundamental: Pointer>);
Expand All @@ -58,7 +58,7 @@ impl<O: IsA<SettingsBackend>> SettingsBackendExt for O {
// unsafe { TODO: call ffi:g_settings_backend_changed_tree() }
//}

//fn keys_changed(&self, path: &str, items: &[&str], origin_tag: /*Unimplemented*/Option<Fundamental: Pointer>) {
//fn keys_changed<P: AsRef<str>>(&self, path: &str, items: &[P], origin_tag: /*Unimplemented*/Option<Fundamental: Pointer>) {
// unsafe { TODO: call ffi:g_settings_backend_keys_changed() }
//}

Expand Down
4 changes: 2 additions & 2 deletions gio/src/auto/themed_icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ impl ThemedIcon {

#[doc(alias = "g_themed_icon_new_from_names")]
#[doc(alias = "new_from_names")]
pub fn from_names(iconnames: &[&str]) -> ThemedIcon {
pub fn from_names<P: AsRef<str>>(iconnames: &[P]) -> ThemedIcon {
let len = iconnames.len() as i32;
unsafe {
from_glib_full(ffi::g_themed_icon_new_from_names(
iconnames.to_glib_none().0,
iconnames.as_ref().to_glib_none().0,
len,
))
}
Expand Down
6 changes: 3 additions & 3 deletions gio/src/auto/tls_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub trait TlsConnectionExt: 'static {
#[cfg(any(feature = "v2_60", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
#[doc(alias = "g_tls_connection_set_advertised_protocols")]
fn set_advertised_protocols(&self, protocols: &[&str]);
fn set_advertised_protocols<P: AsRef<str>>(&self, protocols: &[P]);

#[doc(alias = "g_tls_connection_set_certificate")]
fn set_certificate<P: IsA<TlsCertificate>>(&self, certificate: &P);
Expand Down Expand Up @@ -314,11 +314,11 @@ impl<O: IsA<TlsConnection>> TlsConnectionExt for O {

#[cfg(any(feature = "v2_60", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
fn set_advertised_protocols(&self, protocols: &[&str]) {
fn set_advertised_protocols<P: AsRef<str>>(&self, protocols: &[P]) {
unsafe {
ffi::g_tls_connection_set_advertised_protocols(
self.as_ref().to_glib_none().0,
protocols.to_glib_none().0,
protocols.as_ref().to_glib_none().0,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gio/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion gio/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion glib/gobject-sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion glib/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
9 changes: 8 additions & 1 deletion glib/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ use std::ptr;
#[cfg_attr(feature = "dox", doc(cfg(all(feature = "v2_58", not(windows)))))]
#[allow(clippy::too_many_arguments)]
#[doc(alias = "g_spawn_async_with_fds")]
pub fn spawn_async_with_fds<P: AsRef<std::path::Path>, T: AsRawFd, U: AsRawFd, V: AsRawFd, A: AsRef<str>, E: AsRef<str>>(
pub fn spawn_async_with_fds<
P: AsRef<std::path::Path>,
T: AsRawFd,
U: AsRawFd,
V: AsRawFd,
A: AsRef<str>,
E: AsRef<str>,
>(
working_directory: P,
argv: &[A],
envp: &[E],
Expand Down
2 changes: 1 addition & 1 deletion glib/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion graphene/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion graphene/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion pango/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion pango/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion pangocairo/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
2 changes: 1 addition & 1 deletion pangocairo/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
Generated by gir (https://github.com/gtk-rs/gir @ b823540+)
from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)

0 comments on commit 80f23aa

Please sign in to comment.