diff --git a/gio/Gir.toml b/gio/Gir.toml index 616b028ea77f..504e94347e48 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -346,6 +346,7 @@ generate_builder = true [[object]] name = "Gio.ApplicationCommandLine" status = "generate" +manual_traits = ["ApplicationCommandLineExtManual"] [[object.function]] name = "create_file_for_arg" [[object.function.parameter]] @@ -364,6 +365,16 @@ status = "generate" [[object.function.parameter]] name = "name" string_type = "os_string" + [[object.function]] + name = "set_exit_status" + # Uses glib::ExitCode for consitency with gio::Application interfaces + manual = true + doc_trait_name = "ApplicationCommandLineExtManual" + [[object.function]] + name = "get_exit_status" + # Uses glib::ExitCode for consitency with gio::Application interfaces + manual = true + doc_trait_name = "ApplicationCommandLineExtManual" [[object]] name = "Gio.ApplicationFlags" diff --git a/gio/src/application_command_line.rs b/gio/src/application_command_line.rs new file mode 100644 index 000000000000..a99a4270c5fb --- /dev/null +++ b/gio/src/application_command_line.rs @@ -0,0 +1,36 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use std::{boxed::Box as Box_, mem::transmute, ops::ControlFlow}; + +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, + ExitCode, GString, +}; + +use crate::{ffi, Application, ApplicationCommandLine, ExitCode, File}; + +pub trait ApplicationCommandLineExtManual: IsA { + #[doc(alias = "g_application_command_line_get_exit_status")] + #[doc(alias = "get_exit_status")] + fn exit_code(&self) -> ExitCode { + let status = unsafe { + ffi::g_application_command_line_get_exit_status(self.as_ref().to_glib_none().0) + }; + + ExitCode::try_from(status).unwrap() + } + + #[doc(alias = "g_application_command_line_set_exit_status")] + #[doc(alias = "set_exit_status")] + fn set_exit_code(&self, exit_code: ExitCode) { + let status = i32::from(exit_code.get()); + + unsafe { + ffi::g_application_command_line_set_exit_status(self.as_ref().to_glib_none().0, status); + } + } +} + +impl> ApplicationExtManual for O {} diff --git a/gio/src/auto/application_command_line.rs b/gio/src/auto/application_command_line.rs index b1179cae8287..fbacd238cdf3 100644 --- a/gio/src/auto/application_command_line.rs +++ b/gio/src/auto/application_command_line.rs @@ -79,12 +79,6 @@ pub trait ApplicationCommandLineExt: IsA + 'static { } } - #[doc(alias = "g_application_command_line_get_exit_status")] - #[doc(alias = "get_exit_status")] - fn exit_status(&self) -> i32 { - unsafe { ffi::g_application_command_line_get_exit_status(self.as_ref().to_glib_none().0) } - } - #[doc(alias = "g_application_command_line_get_is_remote")] #[doc(alias = "get_is_remote")] #[doc(alias = "is-remote")] @@ -170,16 +164,6 @@ pub trait ApplicationCommandLineExt: IsA + 'static { } } - #[doc(alias = "g_application_command_line_set_exit_status")] - fn set_exit_status(&self, exit_status: i32) { - unsafe { - ffi::g_application_command_line_set_exit_status( - self.as_ref().to_glib_none().0, - exit_status, - ); - } - } - #[doc(alias = "is-remote")] fn connect_is_remote_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_remote_trampoline<