Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate with latest gir #1091

Merged
merged 5 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gdk-pixbuf/src/auto/pixbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl Pixbuf {
unsafe { FromGlibPtrContainer::from_glib_container(ffi::gdk_pixbuf_get_formats()) }
}

#[cfg(any(feature = "v2_40"))]
Copy link
Member

@GuillaumeGomez GuillaumeGomez May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be a clippy lint.

EDIT: I made myself a memo to add it.

#[cfg(feature = "v2_40")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_40")))]
#[doc(alias = "gdk_pixbuf_init_modules")]
pub fn init_modules(path: &str) -> Result<(), glib::Error> {
Expand Down
24 changes: 8 additions & 16 deletions gdk-pixbuf/src/auto/pixbuf_animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,15 @@ impl PixbufAnimation {
}
}

pub trait PixbufAnimationExt: 'static {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging this we should make sure that it's impossible for external code to implement these traits on anything. Otherwise we need to mark the trait unsafe or implement one of the many sealing mechanisms.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have opened #1093 to keep track of this task

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is already happening as it requires IsA<T> and that is unsafe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we merge this now?

pub trait PixbufAnimationExt: IsA<PixbufAnimation> + 'static {
#[doc(alias = "gdk_pixbuf_animation_get_height")]
#[doc(alias = "get_height")]
fn height(&self) -> i32;

#[doc(alias = "gdk_pixbuf_animation_get_static_image")]
#[doc(alias = "get_static_image")]
fn static_image(&self) -> Option<Pixbuf>;

#[doc(alias = "gdk_pixbuf_animation_get_width")]
#[doc(alias = "get_width")]
fn width(&self) -> i32;

#[doc(alias = "gdk_pixbuf_animation_is_static_image")]
fn is_static_image(&self) -> bool;
}

impl<O: IsA<PixbufAnimation>> PixbufAnimationExt for O {
fn height(&self) -> i32 {
unsafe { ffi::gdk_pixbuf_animation_get_height(self.as_ref().to_glib_none().0) }
}

#[doc(alias = "gdk_pixbuf_animation_get_static_image")]
#[doc(alias = "get_static_image")]
fn static_image(&self) -> Option<Pixbuf> {
unsafe {
from_glib_none(ffi::gdk_pixbuf_animation_get_static_image(
Expand All @@ -167,10 +154,13 @@ impl<O: IsA<PixbufAnimation>> PixbufAnimationExt for O {
}
}

#[doc(alias = "gdk_pixbuf_animation_get_width")]
#[doc(alias = "get_width")]
fn width(&self) -> i32 {
unsafe { ffi::gdk_pixbuf_animation_get_width(self.as_ref().to_glib_none().0) }
}

#[doc(alias = "gdk_pixbuf_animation_is_static_image")]
fn is_static_image(&self) -> bool {
unsafe {
from_glib(ffi::gdk_pixbuf_animation_is_static_image(
Expand All @@ -180,6 +170,8 @@ impl<O: IsA<PixbufAnimation>> PixbufAnimationExt for O {
}
}

impl<O: IsA<PixbufAnimation>> PixbufAnimationExt for O {}

impl fmt::Display for PixbufAnimation {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("PixbufAnimation")
Expand Down
57 changes: 16 additions & 41 deletions gdk-pixbuf/src/auto/pixbuf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,48 +63,8 @@ impl Default for PixbufLoader {
}
}

pub trait PixbufLoaderExt: 'static {
pub trait PixbufLoaderExt: IsA<PixbufLoader> + 'static {
#[doc(alias = "gdk_pixbuf_loader_close")]
fn close(&self) -> Result<(), glib::Error>;

#[doc(alias = "gdk_pixbuf_loader_get_animation")]
#[doc(alias = "get_animation")]
fn animation(&self) -> Option<PixbufAnimation>;

#[doc(alias = "gdk_pixbuf_loader_get_format")]
#[doc(alias = "get_format")]
fn format(&self) -> Option<PixbufFormat>;

#[doc(alias = "gdk_pixbuf_loader_get_pixbuf")]
#[doc(alias = "get_pixbuf")]
fn pixbuf(&self) -> Option<Pixbuf>;

#[doc(alias = "gdk_pixbuf_loader_set_size")]
fn set_size(&self, width: i32, height: i32);

#[doc(alias = "gdk_pixbuf_loader_write")]
fn write(&self, buf: &[u8]) -> Result<(), glib::Error>;

#[doc(alias = "gdk_pixbuf_loader_write_bytes")]
fn write_bytes(&self, buffer: &glib::Bytes) -> Result<(), glib::Error>;

#[doc(alias = "area-prepared")]
fn connect_area_prepared<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

#[doc(alias = "area-updated")]
fn connect_area_updated<F: Fn(&Self, i32, i32, i32, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId;

#[doc(alias = "closed")]
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

#[doc(alias = "size-prepared")]
fn connect_size_prepared<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
fn close(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
Expand All @@ -118,6 +78,8 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "gdk_pixbuf_loader_get_animation")]
#[doc(alias = "get_animation")]
fn animation(&self) -> Option<PixbufAnimation> {
unsafe {
from_glib_none(ffi::gdk_pixbuf_loader_get_animation(
Expand All @@ -126,6 +88,8 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "gdk_pixbuf_loader_get_format")]
#[doc(alias = "get_format")]
fn format(&self) -> Option<PixbufFormat> {
unsafe {
from_glib_none(ffi::gdk_pixbuf_loader_get_format(
Expand All @@ -134,6 +98,8 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "gdk_pixbuf_loader_get_pixbuf")]
#[doc(alias = "get_pixbuf")]
fn pixbuf(&self) -> Option<Pixbuf> {
unsafe {
from_glib_none(ffi::gdk_pixbuf_loader_get_pixbuf(
Expand All @@ -142,12 +108,14 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "gdk_pixbuf_loader_set_size")]
fn set_size(&self, width: i32, height: i32) {
unsafe {
ffi::gdk_pixbuf_loader_set_size(self.as_ref().to_glib_none().0, width, height);
}
}

#[doc(alias = "gdk_pixbuf_loader_write")]
fn write(&self, buf: &[u8]) -> Result<(), glib::Error> {
let count = buf.len() as _;
unsafe {
Expand All @@ -167,6 +135,7 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "gdk_pixbuf_loader_write_bytes")]
fn write_bytes(&self, buffer: &glib::Bytes) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
Expand All @@ -184,6 +153,7 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "area-prepared")]
fn connect_area_prepared<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn area_prepared_trampoline<P: IsA<PixbufLoader>, F: Fn(&P) + 'static>(
this: *mut ffi::GdkPixbufLoader,
Expand All @@ -205,6 +175,7 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "area-updated")]
fn connect_area_updated<F: Fn(&Self, i32, i32, i32, i32) + 'static>(
&self,
f: F,
Expand Down Expand Up @@ -242,6 +213,7 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "closed")]
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn closed_trampoline<P: IsA<PixbufLoader>, F: Fn(&P) + 'static>(
this: *mut ffi::GdkPixbufLoader,
Expand All @@ -263,6 +235,7 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

#[doc(alias = "size-prepared")]
fn connect_size_prepared<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn size_prepared_trampoline<
P: IsA<PixbufLoader>,
Expand Down Expand Up @@ -294,6 +267,8 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}
}

impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {}

impl fmt::Display for PixbufLoader {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("PixbufLoader")
Expand Down
4 changes: 2 additions & 2 deletions 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 @ 6a0603f52c3c)
from gir-files (https://github.com/gtk-rs/gir-files @ b42700b30bb2)
Generated by gir (https://github.com/gtk-rs/gir @ bf8c5e344a73)
from gir-files (https://github.com/gtk-rs/gir-files @ 43cac7495ff5)
2 changes: 1 addition & 1 deletion gdk-pixbuf/sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ extern "C" {
error: *mut *mut glib::GError,
) -> *mut GdkPixbufFormat;
pub fn gdk_pixbuf_get_formats() -> *mut glib::GSList;
#[cfg(any(feature = "v2_40"))]
#[cfg(feature = "v2_40")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_40")))]
pub fn gdk_pixbuf_init_modules(path: *const c_char, error: *mut *mut glib::GError) -> gboolean;
pub fn gdk_pixbuf_new_from_stream_async(
Expand Down
4 changes: 2 additions & 2 deletions 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 @ 6a0603f52c3c)
from gir-files (https://github.com/gtk-rs/gir-files @ b42700b30bb2)
Generated by gir (https://github.com/gtk-rs/gir @ bf8c5e344a73)
from gir-files (https://github.com/gtk-rs/gir-files @ 43cac7495ff5)
3 changes: 3 additions & 0 deletions gio/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ manual_traits = ["DebugControllerDBusExtManual"]
[[object]]
name = "Gio.DesktopAppInfo"
status = "generate"
manual_traits = ["DesktopAppInfoExtManual"]
cfg_condition = "all(not(windows),not(target_os = \"macos\"))"
[[object.function]]
name = "get_boolean"
Expand Down Expand Up @@ -845,6 +846,7 @@ concurrency = "send+sync"
[[object]]
name = "Gio.InetAddress"
status = "generate"
manual_traits = ["InetAddressExtManual"]
concurrency = "send+sync"
[[object.function]]
name = "new_from_bytes"
Expand Down Expand Up @@ -1124,6 +1126,7 @@ status = "generate"
[[object]]
name = "Gio.Settings"
status = "generate"
manual_traits = ["SettingsExtManual"]
[[object.signal]]
name = "writable-change-event"
inhibit = true
Expand Down
14 changes: 5 additions & 9 deletions gio/src/action_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ use glib::{clone, prelude::*};

use crate::{prelude::*, ActionEntry, ActionMap, SimpleAction};

pub trait ActionMapExtManual {
pub trait ActionMapExtManual: IsA<ActionMap> {
#[doc(alias = "g_action_map_add_action_entries")]
fn add_action_entries(&self, entries: impl IntoIterator<Item = ActionEntry<Self>>)
where
Self: IsA<ActionMap>;
}

impl<O: IsA<ActionMap>> ActionMapExtManual for O {
fn add_action_entries(&self, entries: impl IntoIterator<Item = ActionEntry<Self>>) {
for entry in entries.into_iter() {
let action = if let Some(state) = entry.state() {
Expand All @@ -23,16 +17,18 @@ impl<O: IsA<ActionMap>> ActionMapExtManual for O {
if let Some(callback) = entry.activate {
action.connect_activate(clone!(@strong action_map => move |action, state| {
// safe to unwrap as O: IsA<ActionMap>
callback(action_map.downcast_ref::<O>().unwrap(), action, state);
callback(action_map.downcast_ref::<Self>().unwrap(), action, state);
}));
}
if let Some(callback) = entry.change_state {
action.connect_change_state(clone!(@strong action_map => move |action, state| {
// safe to unwrap as O: IsA<ActionMap>
callback(action_map.downcast_ref::<O>().unwrap(), action, state);
callback(action_map.downcast_ref::<Self>().unwrap(), action, state);
}));
}
self.as_ref().add_action(&action);
}
}
}

impl<O: IsA<ActionMap>> ActionMapExtManual for O {}
28 changes: 3 additions & 25 deletions gio/src/app_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,10 @@ use crate::AppLaunchContext;
#[cfg(feature = "v2_60")]
use crate::Cancellable;

pub trait AppInfoExtManual: 'static {
pub trait AppInfoExtManual: IsA<AppInfo> + 'static {
#[cfg(feature = "v2_60")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
#[doc(alias = "g_app_info_launch_uris_async")]
fn launch_uris_async<
P: IsA<AppLaunchContext>,
Q: IsA<Cancellable>,
R: FnOnce(Result<(), glib::Error>) + 'static,
>(
&self,
uris: &[&str],
context: Option<&P>,
cancellable: Option<&Q>,
callback: R,
);

#[cfg(feature = "v2_60")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
fn launch_uris_future<P: IsA<AppLaunchContext> + Clone + 'static>(
&self,
uris: &[&str],
context: Option<&P>,
) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>;
}

impl<O: IsA<AppInfo>> AppInfoExtManual for O {
#[cfg(feature = "v2_60")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
fn launch_uris_async<
P: IsA<AppLaunchContext>,
Q: IsA<Cancellable>,
Expand Down Expand Up @@ -133,3 +109,5 @@ impl<O: IsA<AppInfo>> AppInfoExtManual for O {
))
}
}

impl<O: IsA<AppInfo>> AppInfoExtManual for O {}
22 changes: 6 additions & 16 deletions gio/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,12 @@ use glib::{

use crate::{Application, File};

pub trait ApplicationExtManual {
pub trait ApplicationExtManual: IsA<Application> {
#[doc(alias = "g_application_run")]
fn run(&self) -> ExitCode;
#[doc(alias = "g_application_run")]
fn run_with_args<S: AsRef<str>>(&self, args: &[S]) -> ExitCode;
fn connect_open<F: Fn(&Self, &[File], &str) + 'static>(&self, f: F) -> SignalHandlerId;

#[doc(alias = "g_application_hold")]
fn hold(&self) -> ApplicationHoldGuard;

#[doc(alias = "g_application_mark_busy")]
fn mark_busy(&self) -> ApplicationBusyGuard;
}

impl<O: IsA<Application>> ApplicationExtManual for O {
fn run(&self) -> ExitCode {
self.run_with_args(&std::env::args().collect::<Vec<_>>())
}

#[doc(alias = "g_application_run")]
fn run_with_args<S: AsRef<str>>(&self, args: &[S]) -> ExitCode {
let argv: Vec<&str> = args.iter().map(|a| a.as_ref()).collect();
let argc = argv.len() as i32;
Expand All @@ -38,7 +25,6 @@ impl<O: IsA<Application>> ApplicationExtManual for O {
};
ExitCode::from(exit_code)
}

fn connect_open<F: Fn(&Self, &[File], &str) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn open_trampoline<P, F: Fn(&P, &[File], &str) + 'static>(
this: *mut ffi::GApplication,
Expand Down Expand Up @@ -70,13 +56,15 @@ impl<O: IsA<Application>> ApplicationExtManual for O {
}
}

#[doc(alias = "g_application_hold")]
fn hold(&self) -> ApplicationHoldGuard {
unsafe {
ffi::g_application_hold(self.as_ref().to_glib_none().0);
}
ApplicationHoldGuard(self.as_ref().downgrade())
}

#[doc(alias = "g_application_mark_busy")]
fn mark_busy(&self) -> ApplicationBusyGuard {
unsafe {
ffi::g_application_mark_busy(self.as_ref().to_glib_none().0);
Expand All @@ -85,6 +73,8 @@ impl<O: IsA<Application>> ApplicationExtManual for O {
}
}

impl<O: IsA<Application>> ApplicationExtManual for O {}

#[derive(Debug)]
#[must_use = "if unused the Application will immediately be released"]
pub struct ApplicationHoldGuard(glib::WeakRef<Application>);
Expand Down
Loading