[][src]Trait gio::ApplicationCommandLineExt

pub trait ApplicationCommandLineExt: 'static {
    fn create_file_for_arg<P: AsRef<OsStr>>(&self, arg: P) -> Option<File>;
fn get_arguments(&self) -> Vec<OsString>;
fn get_cwd(&self) -> Option<PathBuf>;
fn get_environ(&self) -> Vec<OsString>;
fn get_exit_status(&self) -> i32;
fn get_is_remote(&self) -> bool;
fn get_platform_data(&self) -> Option<Variant>;
fn get_stdin(&self) -> Option<InputStream>;
fn getenv<P: AsRef<OsStr>>(&self, name: P) -> Option<GString>;
fn set_exit_status(&self, exit_status: i32);
fn connect_property_is_remote_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all ApplicationCommandLine methods.

Implementors

ApplicationCommandLine

Required methods

fn create_file_for_arg<P: AsRef<OsStr>>(&self, arg: P) -> Option<File>

Creates a File corresponding to a filename that was given as part of the invocation of self.

This differs from File::new_for_commandline_arg in that it resolves relative pathnames using the current working directory of the invoking process rather than the local process.

arg

an argument from self

Returns

a new File

fn get_arguments(&self) -> Vec<OsString>

Gets the list of arguments that was passed on the command line.

The strings in the array may contain non-UTF-8 data on UNIX (such as filenames or arguments given in the system locale) but are always in UTF-8 on Windows.

If you wish to use the return value with glib::OptionContext, you must use glib::OptionContext::parse_strv.

The return value is None-terminated and should be freed using g_strfreev.

argc

the length of the arguments array, or None

Returns

the string array containing the arguments (the argv)

fn get_cwd(&self) -> Option<PathBuf>

Gets the working directory of the command line invocation. The string may contain non-utf8 data.

It is possible that the remote application did not send a working directory, so this may be None.

The return value should not be modified or freed and is valid for as long as self exists.

Returns

the current directory, or None

fn get_environ(&self) -> Vec<OsString>

Gets the contents of the 'environ' variable of the command line invocation, as would be returned by g_get_environ, ie as a None-terminated list of strings in the form 'NAME=VALUE'. The strings may contain non-utf8 data.

The remote application usually does not send an environment. Use ApplicationFlags::SendEnvironment to affect that. Even with this flag set it is possible that the environment is still not available (due to invocation messages from other applications).

The return value should not be modified or freed and is valid for as long as self exists.

See ApplicationCommandLineExt::getenv if you are only interested in the value of a single environment variable.

Returns

the environment strings, or None if they were not sent

fn get_exit_status(&self) -> i32

Gets the exit status of self. See ApplicationCommandLineExt::set_exit_status for more information.

Returns

the exit status

fn get_is_remote(&self) -> bool

Determines if self represents a remote invocation.

Returns

true if the invocation was remote

fn get_platform_data(&self) -> Option<Variant>

Gets the platform data associated with the invocation of self.

This is a glib::Variant dictionary containing information about the context in which the invocation occurred. It typically contains information like the current working directory and the startup notification ID.

For local invocation, it will be None.

Returns

the platform data, or None

fn get_stdin(&self) -> Option<InputStream>

Gets the stdin of the invoking process.

The InputStream can be used to read data passed to the standard input of the invoking process. This doesn't work on all platforms. Presently, it is only available on UNIX when using a DBus daemon capable of passing file descriptors. If stdin is not available then None will be returned. In the future, support may be expanded to other platforms.

You must only call this function once per commandline invocation.

Returns

a InputStream for stdin

fn getenv<P: AsRef<OsStr>>(&self, name: P) -> Option<GString>

Gets the value of a particular environment variable of the command line invocation, as would be returned by g_getenv. The strings may contain non-utf8 data.

The remote application usually does not send an environment. Use ApplicationFlags::SendEnvironment to affect that. Even with this flag set it is possible that the environment is still not available (due to invocation messages from other applications).

The return value should not be modified or freed and is valid for as long as self exists.

name

the environment variable to get

Returns

the value of the variable, or None if unset or unsent

fn set_exit_status(&self, exit_status: i32)

Sets the exit status that will be used when the invoking process exits.

The return value of the Application::command-line signal is passed to this function when the handler returns. This is the usual way of setting the exit status.

In the event that you want the remote invocation to continue running and want to decide on the exit status in the future, you can use this call. For the case of a remote invocation, the remote process will typically exit when the last reference is dropped on self. The exit status of the remote process will be equal to the last value that was set with this function.

In the case that the commandline invocation is local, the situation is slightly more complicated. If the commandline invocation results in the mainloop running (ie: because the use-count of the application increased to a non-zero value) then the application is considered to have been 'successful' in a certain sense, and the exit status is always zero. If the application use count is zero, though, the exit status of the local ApplicationCommandLine is used.

exit_status

the exit status

fn connect_property_is_remote_notify<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

Loading content...

Implementors

impl<O: IsA<ApplicationCommandLine>> ApplicationCommandLineExt for O[src]

Loading content...