gio/auto/
application.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    ffi, ActionGroup, ActionMap, ApplicationCommandLine, ApplicationFlags, Cancellable,
7    DBusConnection, File, Notification,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// `GApplication` is the core class for application support.
19    ///
20    /// A `GApplication` is the foundation of an application. It wraps some
21    /// low-level platform-specific services and is intended to act as the
22    /// foundation for higher-level application classes such as
23    /// `GtkApplication` or `MxApplication`. In general, you should not use
24    /// this class outside of a higher level framework.
25    ///
26    /// `GApplication` provides convenient life-cycle management by maintaining
27    /// a "use count" for the primary application instance. The use count can
28    /// be changed using [`ApplicationExtManual::hold()`][crate::prelude::ApplicationExtManual::hold()] and
29    /// [`ApplicationExtManual::release()`][crate::prelude::ApplicationExtManual::release()]. If it drops to zero, the application
30    /// exits. Higher-level classes such as `GtkApplication` employ the use count
31    /// to ensure that the application stays alive as long as it has any opened
32    /// windows.
33    ///
34    /// Another feature that `GApplication` (optionally) provides is process
35    /// uniqueness. Applications can make use of this functionality by
36    /// providing a unique application ID. If given, only one application
37    /// with this ID can be running at a time per session. The session
38    /// concept is platform-dependent, but corresponds roughly to a graphical
39    /// desktop login. When your application is launched again, its
40    /// arguments are passed through platform communication to the already
41    /// running program. The already running instance of the program is
42    /// called the "primary instance"; for non-unique applications this is
43    /// always the current instance. On Linux, the D-Bus session bus
44    /// is used for communication.
45    ///
46    /// The use of `GApplication` differs from some other commonly-used
47    /// uniqueness libraries (such as libunique) in important ways. The
48    /// application is not expected to manually register itself and check
49    /// if it is the primary instance. Instead, the main() function of a
50    /// `GApplication` should do very little more than instantiating the
51    /// application instance, possibly connecting signal handlers, then
52    /// calling [`ApplicationExtManual::run()`][crate::prelude::ApplicationExtManual::run()]. All checks for uniqueness are done
53    /// internally. If the application is the primary instance then the
54    /// startup signal is emitted and the mainloop runs. If the application
55    /// is not the primary instance then a signal is sent to the primary
56    /// instance and [`ApplicationExtManual::run()`][crate::prelude::ApplicationExtManual::run()] promptly returns. See the code
57    /// examples below.
58    ///
59    /// If used, the expected form of an application identifier is the
60    /// same as that of a
61    /// [D-Bus well-known bus name](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus).
62    /// Examples include: `com.example.MyApp`, `org.example.internal_apps.Calculator`,
63    /// `org._7_zip.Archiver`.
64    /// For details on valid application identifiers, see [`id_is_valid()`][Self::id_is_valid()].
65    ///
66    /// On Linux, the application identifier is claimed as a well-known bus name
67    /// on the user's session bus. This means that the uniqueness of your
68    /// application is scoped to the current session. It also means that your
69    /// application may provide additional services (through registration of other
70    /// object paths) at that bus name. The registration of these object paths
71    /// should be done with the shared GDBus session bus. Note that due to the
72    /// internal architecture of GDBus, method calls can be dispatched at any time
73    /// (even if a main loop is not running). For this reason, you must ensure that
74    /// any object paths that you wish to register are registered before #GApplication
75    /// attempts to acquire the bus name of your application (which happens in
76    /// [`ApplicationExt::register()`][crate::prelude::ApplicationExt::register()]). Unfortunately, this means that you cannot
77    /// use [`is-remote`][struct@crate::Application#is-remote] to decide if you want to register
78    /// object paths.
79    ///
80    /// `GApplication` also implements the [`ActionGroup`][crate::ActionGroup] and [`ActionMap`][crate::ActionMap]
81    /// interfaces and lets you easily export actions by adding them with
82    /// [`ActionMapExt::add_action()`][crate::prelude::ActionMapExt::add_action()]. When invoking an action by calling
83    /// [`ActionGroupExt::activate_action()`][crate::prelude::ActionGroupExt::activate_action()] on the application, it is always
84    /// invoked in the primary instance. The actions are also exported on
85    /// the session bus, and GIO provides the [`DBusActionGroup`][crate::DBusActionGroup] wrapper to
86    /// conveniently access them remotely. GIO provides a [`DBusMenuModel`][crate::DBusMenuModel] wrapper
87    /// for remote access to exported [`MenuModel`][crate::MenuModel]s.
88    ///
89    /// Note: Due to the fact that actions are exported on the session bus,
90    /// using `maybe` parameters is not supported, since D-Bus does not support
91    /// `maybe` types.
92    ///
93    /// There is a number of different entry points into a `GApplication`:
94    ///
95    /// - via 'Activate' (i.e. just starting the application)
96    ///
97    /// - via 'Open' (i.e. opening some files)
98    ///
99    /// - by handling a command-line
100    ///
101    /// - via activating an action
102    ///
103    /// The [`startup`][struct@crate::Application#startup] signal lets you handle the application
104    /// initialization for all of these in a single place.
105    ///
106    /// Regardless of which of these entry points is used to start the
107    /// application, `GApplication` passes some ‘platform data’ from the
108    /// launching instance to the primary instance, in the form of a
109    /// [`glib::Variant`][struct@crate::glib::Variant] dictionary mapping strings to variants. To use platform
110    /// data, override the [`ApplicationImpl::before_emit()`][crate::subclass::prelude::ApplicationImpl::before_emit()] or
111    /// [`ApplicationImpl::after_emit()`][crate::subclass::prelude::ApplicationImpl::after_emit()] virtual functions
112    /// in your `GApplication` subclass. When dealing with
113    /// [`ApplicationCommandLine`][crate::ApplicationCommandLine] objects, the platform data is
114    /// directly available via [`ApplicationCommandLineExt::cwd()`][crate::prelude::ApplicationCommandLineExt::cwd()],
115    /// [`ApplicationCommandLineExt::environ()`][crate::prelude::ApplicationCommandLineExt::environ()] and
116    /// [`ApplicationCommandLineExt::platform_data()`][crate::prelude::ApplicationCommandLineExt::platform_data()].
117    ///
118    /// As the name indicates, the platform data may vary depending on the
119    /// operating system, but it always includes the current directory (key
120    /// `cwd`), and optionally the environment (ie the set of environment
121    /// variables and their values) of the calling process (key `environ`).
122    /// The environment is only added to the platform data if the
123    /// `G_APPLICATION_SEND_ENVIRONMENT` flag is set. `GApplication` subclasses
124    /// can add their own platform data by overriding the
125    /// `vfunc::Gio::Application::add_platform_data` virtual function. For instance,
126    /// `GtkApplication` adds startup notification data in this way.
127    ///
128    /// To parse commandline arguments you may handle the
129    /// [`command-line`][struct@crate::Application#command-line] signal or override the
130    /// `vfunc::Gio::Application::local_command_line` virtual function, to parse them in
131    /// either the primary instance or the local instance, respectively.
132    ///
133    /// For an example of opening files with a `GApplication`, see
134    /// [gapplication-example-open.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-open.c).
135    ///
136    /// For an example of using actions with `GApplication`, see
137    /// [gapplication-example-actions.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-actions.c).
138    ///
139    /// For an example of using extra D-Bus hooks with `GApplication`, see
140    /// [gapplication-example-dbushooks.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-dbushooks.c).
141    ///
142    /// ## Properties
143    ///
144    ///
145    /// #### `action-group`
146    ///  The group of actions that the application exports.
147    ///
148    /// Writeable
149    ///
150    ///
151    /// #### `application-id`
152    ///  The unique identifier for the application.
153    ///
154    /// Readable | Writeable | Construct
155    ///
156    ///
157    /// #### `flags`
158    ///  Flags specifying the behaviour of the application.
159    ///
160    /// Readable | Writeable
161    ///
162    ///
163    /// #### `inactivity-timeout`
164    ///  Time (in milliseconds) to stay alive after becoming idle.
165    ///
166    /// Readable | Writeable
167    ///
168    ///
169    /// #### `is-busy`
170    ///  Whether the application is currently marked as busy through
171    /// g_application_mark_busy() or g_application_bind_busy_property().
172    ///
173    /// Readable
174    ///
175    ///
176    /// #### `is-registered`
177    ///  Whether [`ApplicationExt::register()`][crate::prelude::ApplicationExt::register()] has been called.
178    ///
179    /// Readable
180    ///
181    ///
182    /// #### `is-remote`
183    ///  Whether this application instance is remote.
184    ///
185    /// Readable
186    ///
187    ///
188    /// #### `resource-base-path`
189    ///  The base resource path for the application.
190    ///
191    /// Readable | Writeable
192    ///
193    ///
194    /// #### `version`
195    ///  The human-readable version number of the application.
196    ///
197    /// Readable | Writeable
198    ///
199    /// ## Signals
200    ///
201    ///
202    /// #### `activate`
203    ///  The ::activate signal is emitted on the primary instance when an
204    /// activation occurs. See g_application_activate().
205    ///
206    ///
207    ///
208    ///
209    /// #### `command-line`
210    ///  The ::command-line signal is emitted on the primary instance when
211    /// a commandline is not handled locally. See g_application_run() and
212    /// the #GApplicationCommandLine documentation for more information.
213    ///
214    ///
215    ///
216    ///
217    /// #### `handle-local-options`
218    ///  The ::handle-local-options signal is emitted on the local instance
219    /// after the parsing of the commandline options has occurred.
220    ///
221    /// You can add options to be recognised during commandline option
222    /// parsing using g_application_add_main_option_entries() and
223    /// g_application_add_option_group().
224    ///
225    /// Signal handlers can inspect @options (along with values pointed to
226    /// from the @arg_data of an installed #GOptionEntrys) in order to
227    /// decide to perform certain actions, including direct local handling
228    /// (which may be useful for options like --version).
229    ///
230    /// In the event that the application is marked
231    /// [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] the "normal processing" will
232    /// send the @options dictionary to the primary instance where it can be
233    /// read with g_application_command_line_get_options_dict().  The signal
234    /// handler can modify the dictionary before returning, and the
235    /// modified dictionary will be sent.
236    ///
237    /// In the event that [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] is not set,
238    /// "normal processing" will treat the remaining uncollected command
239    /// line arguments as filenames or URIs.  If there are no arguments,
240    /// the application is activated by g_application_activate().  One or
241    /// more arguments results in a call to g_application_open().
242    ///
243    /// If you want to handle the local commandline arguments for yourself
244    /// by converting them to calls to g_application_open() or
245    /// g_action_group_activate_action() then you must be sure to register
246    /// the application first.  You should probably not call
247    /// g_application_activate() for yourself, however: just return -1 and
248    /// allow the default handler to do it for you.  This will ensure that
249    /// the `--gapplication-service` switch works properly (i.e. no activation
250    /// in that case).
251    ///
252    /// Note that this signal is emitted from the default implementation of
253    /// local_command_line().  If you override that function and don't
254    /// chain up then this signal will never be emitted.
255    ///
256    /// You can override local_command_line() if you need more powerful
257    /// capabilities than what is provided here, but this should not
258    /// normally be required.
259    ///
260    ///
261    ///
262    ///
263    /// #### `name-lost`
264    ///  The ::name-lost signal is emitted only on the registered primary instance
265    /// when a new instance has taken over. This can only happen if the application
266    /// is using the [`ApplicationFlags::ALLOW_REPLACEMENT`][crate::ApplicationFlags::ALLOW_REPLACEMENT] flag.
267    ///
268    /// The default handler for this signal calls g_application_quit().
269    ///
270    ///
271    ///
272    ///
273    /// #### `open`
274    ///  The ::open signal is emitted on the primary instance when there are
275    /// files to open. See g_application_open() for more information.
276    ///
277    ///
278    ///
279    ///
280    /// #### `shutdown`
281    ///  The ::shutdown signal is emitted only on the registered primary instance
282    /// immediately after the main loop terminates.
283    ///
284    ///
285    ///
286    ///
287    /// #### `startup`
288    ///  The ::startup signal is emitted on the primary instance immediately
289    /// after registration. See g_application_register().
290    ///
291    ///
292    /// <details><summary><h4>ActionGroup</h4></summary>
293    ///
294    ///
295    /// #### `action-added`
296    ///  Signals that a new action was just added to the group.
297    ///
298    /// This signal is emitted after the action has been added
299    /// and is now visible.
300    ///
301    /// Detailed
302    ///
303    ///
304    /// #### `action-enabled-changed`
305    ///  Signals that the enabled status of the named action has changed.
306    ///
307    /// Detailed
308    ///
309    ///
310    /// #### `action-removed`
311    ///  Signals that an action is just about to be removed from the group.
312    ///
313    /// This signal is emitted before the action is removed, so the action
314    /// is still visible and can be queried from the signal handler.
315    ///
316    /// Detailed
317    ///
318    ///
319    /// #### `action-state-changed`
320    ///  Signals that the state of the named action has changed.
321    ///
322    /// Detailed
323    /// </details>
324    ///
325    /// # Implements
326    ///
327    /// [`ApplicationExt`][trait@crate::prelude::ApplicationExt], [`trait@glib::ObjectExt`], [`ActionGroupExt`][trait@crate::prelude::ActionGroupExt], [`ActionMapExt`][trait@crate::prelude::ActionMapExt], [`ApplicationExtManual`][trait@crate::prelude::ApplicationExtManual], [`ActionMapExtManual`][trait@crate::prelude::ActionMapExtManual]
328    #[doc(alias = "GApplication")]
329    pub struct Application(Object<ffi::GApplication, ffi::GApplicationClass>) @implements ActionGroup, ActionMap;
330
331    match fn {
332        type_ => || ffi::g_application_get_type(),
333    }
334}
335
336impl Application {
337    pub const NONE: Option<&'static Application> = None;
338
339    /// Creates a new #GApplication instance.
340    ///
341    /// If non-[`None`], the application id must be valid.  See
342    /// g_application_id_is_valid().
343    ///
344    /// If no application ID is given then some features of #GApplication
345    /// (most notably application uniqueness) will be disabled.
346    /// ## `application_id`
347    /// the application id
348    /// ## `flags`
349    /// the application flags
350    ///
351    /// # Returns
352    ///
353    /// a new #GApplication instance
354    #[doc(alias = "g_application_new")]
355    pub fn new(application_id: Option<&str>, flags: ApplicationFlags) -> Application {
356        unsafe {
357            from_glib_full(ffi::g_application_new(
358                application_id.to_glib_none().0,
359                flags.into_glib(),
360            ))
361        }
362    }
363
364    // rustdoc-stripper-ignore-next
365    /// Creates a new builder-pattern struct instance to construct [`Application`] objects.
366    ///
367    /// This method returns an instance of [`ApplicationBuilder`](crate::builders::ApplicationBuilder) which can be used to create [`Application`] objects.
368    pub fn builder() -> ApplicationBuilder {
369        ApplicationBuilder::new()
370    }
371
372    /// Returns the default #GApplication instance for this process.
373    ///
374    /// Normally there is only one #GApplication per process and it becomes
375    /// the default when it is created.  You can exercise more control over
376    /// this by using g_application_set_default().
377    ///
378    /// If there is no default application then [`None`] is returned.
379    ///
380    /// # Returns
381    ///
382    /// the default application for this process, or [`None`]
383    #[doc(alias = "g_application_get_default")]
384    #[doc(alias = "get_default")]
385    #[allow(clippy::should_implement_trait)]
386    pub fn default() -> Option<Application> {
387        unsafe { from_glib_none(ffi::g_application_get_default()) }
388    }
389
390    /// Checks if @application_id is a valid application identifier.
391    ///
392    /// A valid ID is required for calls to g_application_new() and
393    /// g_application_set_application_id().
394    ///
395    /// Application identifiers follow the same format as
396    /// [D-Bus well-known bus names](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus).
397    /// For convenience, the restrictions on application identifiers are
398    /// reproduced here:
399    ///
400    /// - Application identifiers are composed of 1 or more elements separated by a
401    ///   period (`.`) character. All elements must contain at least one character.
402    ///
403    /// - Each element must only contain the ASCII characters `[A-Z][a-z][0-9]_-`,
404    ///   with `-` discouraged in new application identifiers. Each element must not
405    ///   begin with a digit.
406    ///
407    /// - Application identifiers must contain at least one `.` (period) character
408    ///   (and thus at least two elements).
409    ///
410    /// - Application identifiers must not begin with a `.` (period) character.
411    ///
412    /// - Application identifiers must not exceed 255 characters.
413    ///
414    /// Note that the hyphen (`-`) character is allowed in application identifiers,
415    /// but is problematic or not allowed in various specifications and APIs that
416    /// refer to D-Bus, such as
417    /// [Flatpak application IDs](http://docs.flatpak.org/en/latest/introduction.html#identifiers),
418    /// the
419    /// [`DBusActivatable` interface in the Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus),
420    /// and the convention that an application's "main" interface and object path
421    /// resemble its application identifier and bus name. To avoid situations that
422    /// require special-case handling, it is recommended that new application
423    /// identifiers consistently replace hyphens with underscores.
424    ///
425    /// Like D-Bus interface names, application identifiers should start with the
426    /// reversed DNS domain name of the author of the interface (in lower-case), and
427    /// it is conventional for the rest of the application identifier to consist of
428    /// words run together, with initial capital letters.
429    ///
430    /// As with D-Bus interface names, if the author's DNS domain name contains
431    /// hyphen/minus characters they should be replaced by underscores, and if it
432    /// contains leading digits they should be escaped by prepending an underscore.
433    /// For example, if the owner of 7-zip.org used an application identifier for an
434    /// archiving application, it might be named `org._7_zip.Archiver`.
435    /// ## `application_id`
436    /// a potential application identifier
437    ///
438    /// # Returns
439    ///
440    /// [`true`] if @application_id is valid
441    #[doc(alias = "g_application_id_is_valid")]
442    pub fn id_is_valid(application_id: &str) -> bool {
443        unsafe {
444            from_glib(ffi::g_application_id_is_valid(
445                application_id.to_glib_none().0,
446            ))
447        }
448    }
449}
450
451impl Default for Application {
452    fn default() -> Self {
453        glib::object::Object::new::<Self>()
454    }
455}
456
457// rustdoc-stripper-ignore-next
458/// A [builder-pattern] type to construct [`Application`] objects.
459///
460/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
461#[must_use = "The builder must be built to be used"]
462pub struct ApplicationBuilder {
463    builder: glib::object::ObjectBuilder<'static, Application>,
464}
465
466impl ApplicationBuilder {
467    fn new() -> Self {
468        Self {
469            builder: glib::object::Object::builder(),
470        }
471    }
472
473    /// The unique identifier for the application.
474    pub fn application_id(self, application_id: impl Into<glib::GString>) -> Self {
475        Self {
476            builder: self
477                .builder
478                .property("application-id", application_id.into()),
479        }
480    }
481
482    /// Flags specifying the behaviour of the application.
483    pub fn flags(self, flags: ApplicationFlags) -> Self {
484        Self {
485            builder: self.builder.property("flags", flags),
486        }
487    }
488
489    /// Time (in milliseconds) to stay alive after becoming idle.
490    pub fn inactivity_timeout(self, inactivity_timeout: u32) -> Self {
491        Self {
492            builder: self
493                .builder
494                .property("inactivity-timeout", inactivity_timeout),
495        }
496    }
497
498    /// The base resource path for the application.
499    pub fn resource_base_path(self, resource_base_path: impl Into<glib::GString>) -> Self {
500        Self {
501            builder: self
502                .builder
503                .property("resource-base-path", resource_base_path.into()),
504        }
505    }
506
507    /// The human-readable version number of the application.
508    #[cfg(feature = "v2_80")]
509    #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))]
510    pub fn version(self, version: impl Into<glib::GString>) -> Self {
511        Self {
512            builder: self.builder.property("version", version.into()),
513        }
514    }
515
516    // rustdoc-stripper-ignore-next
517    /// Build the [`Application`].
518    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
519    pub fn build(self) -> Application {
520        self.builder.build()
521    }
522}
523
524/// Trait containing all [`struct@Application`] methods.
525///
526/// # Implementors
527///
528/// [`Application`][struct@crate::Application]
529pub trait ApplicationExt: IsA<Application> + 'static {
530    /// Activates the application.
531    ///
532    /// In essence, this results in the #GApplication::activate signal being
533    /// emitted in the primary instance.
534    ///
535    /// The application must be registered before calling this function.
536    #[doc(alias = "g_application_activate")]
537    fn activate(&self) {
538        unsafe {
539            ffi::g_application_activate(self.as_ref().to_glib_none().0);
540        }
541    }
542
543    /// Add an option to be handled by @self.
544    ///
545    /// Calling this function is the equivalent of calling
546    /// g_application_add_main_option_entries() with a single #GOptionEntry
547    /// that has its arg_data member set to [`None`].
548    ///
549    /// The parsed arguments will be packed into a #GVariantDict which
550    /// is passed to #GApplication::handle-local-options. If
551    /// [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] is set, then it will also
552    /// be sent to the primary instance. See
553    /// g_application_add_main_option_entries() for more details.
554    ///
555    /// See #GOptionEntry for more documentation of the arguments.
556    /// ## `long_name`
557    /// the long name of an option used to specify it in a commandline
558    /// ## `short_name`
559    /// the short name of an option
560    /// ## `flags`
561    /// flags from #GOptionFlags
562    /// ## `arg`
563    /// the type of the option, as a #GOptionArg
564    /// ## `description`
565    /// the description for the option in `--help` output
566    /// ## `arg_description`
567    /// the placeholder to use for the extra argument
568    ///    parsed by the option in `--help` output
569    #[doc(alias = "g_application_add_main_option")]
570    fn add_main_option(
571        &self,
572        long_name: &str,
573        short_name: glib::Char,
574        flags: glib::OptionFlags,
575        arg: glib::OptionArg,
576        description: &str,
577        arg_description: Option<&str>,
578    ) {
579        unsafe {
580            ffi::g_application_add_main_option(
581                self.as_ref().to_glib_none().0,
582                long_name.to_glib_none().0,
583                short_name.into_glib(),
584                flags.into_glib(),
585                arg.into_glib(),
586                description.to_glib_none().0,
587                arg_description.to_glib_none().0,
588            );
589        }
590    }
591
592    //#[doc(alias = "g_application_add_main_option_entries")]
593    //fn add_main_option_entries(&self, entries: /*Ignored*/&[glib::OptionEntry]) {
594    //    unsafe { TODO: call ffi:g_application_add_main_option_entries() }
595    //}
596
597    //#[doc(alias = "g_application_add_option_group")]
598    //fn add_option_group(&self, group: /*Ignored*/glib::OptionGroup) {
599    //    unsafe { TODO: call ffi:g_application_add_option_group() }
600    //}
601
602    /// Marks @self as busy (see g_application_mark_busy()) while
603    /// @property on @object is [`true`].
604    ///
605    /// The binding holds a reference to @self while it is active, but
606    /// not to @object. Instead, the binding is destroyed when @object is
607    /// finalized.
608    /// ## `object`
609    /// a #GObject
610    /// ## `property`
611    /// the name of a boolean property of @object
612    #[doc(alias = "g_application_bind_busy_property")]
613    fn bind_busy_property(&self, object: &impl IsA<glib::Object>, property: &str) {
614        unsafe {
615            ffi::g_application_bind_busy_property(
616                self.as_ref().to_glib_none().0,
617                object.as_ref().to_glib_none().0,
618                property.to_glib_none().0,
619            );
620        }
621    }
622
623    /// Gets the unique identifier for @self.
624    ///
625    /// # Returns
626    ///
627    /// the identifier for @self, owned by @self
628    #[doc(alias = "g_application_get_application_id")]
629    #[doc(alias = "get_application_id")]
630    #[doc(alias = "application-id")]
631    fn application_id(&self) -> Option<glib::GString> {
632        unsafe {
633            from_glib_none(ffi::g_application_get_application_id(
634                self.as_ref().to_glib_none().0,
635            ))
636        }
637    }
638
639    /// Gets the #GDBusConnection being used by the application, or [`None`].
640    ///
641    /// If #GApplication is using its D-Bus backend then this function will
642    /// return the #GDBusConnection being used for uniqueness and
643    /// communication with the desktop environment and other instances of the
644    /// application.
645    ///
646    /// If #GApplication is not using D-Bus then this function will return
647    /// [`None`].  This includes the situation where the D-Bus backend would
648    /// normally be in use but we were unable to connect to the bus.
649    ///
650    /// This function must not be called before the application has been
651    /// registered.  See g_application_get_is_registered().
652    ///
653    /// # Returns
654    ///
655    /// a #GDBusConnection, or [`None`]
656    #[doc(alias = "g_application_get_dbus_connection")]
657    #[doc(alias = "get_dbus_connection")]
658    fn dbus_connection(&self) -> Option<DBusConnection> {
659        unsafe {
660            from_glib_none(ffi::g_application_get_dbus_connection(
661                self.as_ref().to_glib_none().0,
662            ))
663        }
664    }
665
666    /// Gets the D-Bus object path being used by the application, or [`None`].
667    ///
668    /// If #GApplication is using its D-Bus backend then this function will
669    /// return the D-Bus object path that #GApplication is using.  If the
670    /// application is the primary instance then there is an object published
671    /// at this path.  If the application is not the primary instance then
672    /// the result of this function is undefined.
673    ///
674    /// If #GApplication is not using D-Bus then this function will return
675    /// [`None`].  This includes the situation where the D-Bus backend would
676    /// normally be in use but we were unable to connect to the bus.
677    ///
678    /// This function must not be called before the application has been
679    /// registered.  See g_application_get_is_registered().
680    ///
681    /// # Returns
682    ///
683    /// the object path, or [`None`]
684    #[doc(alias = "g_application_get_dbus_object_path")]
685    #[doc(alias = "get_dbus_object_path")]
686    fn dbus_object_path(&self) -> Option<glib::GString> {
687        unsafe {
688            from_glib_none(ffi::g_application_get_dbus_object_path(
689                self.as_ref().to_glib_none().0,
690            ))
691        }
692    }
693
694    /// Gets the flags for @self.
695    ///
696    /// See #GApplicationFlags.
697    ///
698    /// # Returns
699    ///
700    /// the flags for @self
701    #[doc(alias = "g_application_get_flags")]
702    #[doc(alias = "get_flags")]
703    fn flags(&self) -> ApplicationFlags {
704        unsafe { from_glib(ffi::g_application_get_flags(self.as_ref().to_glib_none().0)) }
705    }
706
707    /// Gets the current inactivity timeout for the application.
708    ///
709    /// This is the amount of time (in milliseconds) after the last call to
710    /// g_application_release() before the application stops running.
711    ///
712    /// # Returns
713    ///
714    /// the timeout, in milliseconds
715    #[doc(alias = "g_application_get_inactivity_timeout")]
716    #[doc(alias = "get_inactivity_timeout")]
717    #[doc(alias = "inactivity-timeout")]
718    fn inactivity_timeout(&self) -> u32 {
719        unsafe { ffi::g_application_get_inactivity_timeout(self.as_ref().to_glib_none().0) }
720    }
721
722    /// Gets the application's current busy state, as set through
723    /// g_application_mark_busy() or g_application_bind_busy_property().
724    ///
725    /// # Returns
726    ///
727    /// [`true`] if @self is currently marked as busy
728    #[doc(alias = "g_application_get_is_busy")]
729    #[doc(alias = "get_is_busy")]
730    #[doc(alias = "is-busy")]
731    fn is_busy(&self) -> bool {
732        unsafe {
733            from_glib(ffi::g_application_get_is_busy(
734                self.as_ref().to_glib_none().0,
735            ))
736        }
737    }
738
739    /// Checks if @self is registered.
740    ///
741    /// An application is registered if g_application_register() has been
742    /// successfully called.
743    ///
744    /// # Returns
745    ///
746    /// [`true`] if @self is registered
747    #[doc(alias = "g_application_get_is_registered")]
748    #[doc(alias = "get_is_registered")]
749    #[doc(alias = "is-registered")]
750    fn is_registered(&self) -> bool {
751        unsafe {
752            from_glib(ffi::g_application_get_is_registered(
753                self.as_ref().to_glib_none().0,
754            ))
755        }
756    }
757
758    /// Checks if @self is remote.
759    ///
760    /// If @self is remote then it means that another instance of
761    /// application already exists (the 'primary' instance).  Calls to
762    /// perform actions on @self will result in the actions being
763    /// performed by the primary instance.
764    ///
765    /// The value of this property cannot be accessed before
766    /// g_application_register() has been called.  See
767    /// g_application_get_is_registered().
768    ///
769    /// # Returns
770    ///
771    /// [`true`] if @self is remote
772    #[doc(alias = "g_application_get_is_remote")]
773    #[doc(alias = "get_is_remote")]
774    #[doc(alias = "is-remote")]
775    fn is_remote(&self) -> bool {
776        unsafe {
777            from_glib(ffi::g_application_get_is_remote(
778                self.as_ref().to_glib_none().0,
779            ))
780        }
781    }
782
783    /// Gets the resource base path of @self.
784    ///
785    /// See g_application_set_resource_base_path() for more information.
786    ///
787    /// # Returns
788    ///
789    /// the base resource path, if one is set
790    #[doc(alias = "g_application_get_resource_base_path")]
791    #[doc(alias = "get_resource_base_path")]
792    #[doc(alias = "resource-base-path")]
793    fn resource_base_path(&self) -> Option<glib::GString> {
794        unsafe {
795            from_glib_none(ffi::g_application_get_resource_base_path(
796                self.as_ref().to_glib_none().0,
797            ))
798        }
799    }
800
801    /// Gets the version of @self.
802    ///
803    /// # Returns
804    ///
805    /// the version of @self
806    #[cfg(feature = "v2_80")]
807    #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))]
808    #[doc(alias = "g_application_get_version")]
809    #[doc(alias = "get_version")]
810    fn version(&self) -> Option<glib::GString> {
811        unsafe {
812            from_glib_none(ffi::g_application_get_version(
813                self.as_ref().to_glib_none().0,
814            ))
815        }
816    }
817
818    /// Opens the given files.
819    ///
820    /// In essence, this results in the #GApplication::open signal being emitted
821    /// in the primary instance.
822    ///
823    /// @n_files must be greater than zero.
824    ///
825    /// @hint is simply passed through to the ::open signal.  It is
826    /// intended to be used by applications that have multiple modes for
827    /// opening files (eg: "view" vs "edit", etc).  Unless you have a need
828    /// for this functionality, you should use "".
829    ///
830    /// The application must be registered before calling this function
831    /// and it must have the [`ApplicationFlags::HANDLES_OPEN`][crate::ApplicationFlags::HANDLES_OPEN] flag set.
832    /// ## `files`
833    /// an array of #GFiles to open
834    /// ## `hint`
835    /// a hint (or ""), but never [`None`]
836    #[doc(alias = "g_application_open")]
837    fn open(&self, files: &[File], hint: &str) {
838        let n_files = files.len() as _;
839        unsafe {
840            ffi::g_application_open(
841                self.as_ref().to_glib_none().0,
842                files.to_glib_none().0,
843                n_files,
844                hint.to_glib_none().0,
845            );
846        }
847    }
848
849    /// Immediately quits the application.
850    ///
851    /// Upon return to the mainloop, g_application_run() will return,
852    /// calling only the 'shutdown' function before doing so.
853    ///
854    /// The hold count is ignored.
855    /// Take care if your code has called g_application_hold() on the application and
856    /// is therefore still expecting it to exist.
857    /// (Note that you may have called g_application_hold() indirectly, for example
858    /// through gtk_application_add_window().)
859    ///
860    /// The result of calling g_application_run() again after it returns is
861    /// unspecified.
862    #[doc(alias = "g_application_quit")]
863    fn quit(&self) {
864        unsafe {
865            ffi::g_application_quit(self.as_ref().to_glib_none().0);
866        }
867    }
868
869    /// Attempts registration of the application.
870    ///
871    /// This is the point at which the application discovers if it is the
872    /// primary instance or merely acting as a remote for an already-existing
873    /// primary instance.  This is implemented by attempting to acquire the
874    /// application identifier as a unique bus name on the session bus using
875    /// GDBus.
876    ///
877    /// If there is no application ID or if [`ApplicationFlags::NON_UNIQUE`][crate::ApplicationFlags::NON_UNIQUE] was
878    /// given, then this process will always become the primary instance.
879    ///
880    /// Due to the internal architecture of GDBus, method calls can be
881    /// dispatched at any time (even if a main loop is not running).  For
882    /// this reason, you must ensure that any object paths that you wish to
883    /// register are registered before calling this function.
884    ///
885    /// If the application has already been registered then [`true`] is
886    /// returned with no work performed.
887    ///
888    /// The #GApplication::startup signal is emitted if registration succeeds
889    /// and @self is the primary instance (including the non-unique
890    /// case).
891    ///
892    /// In the event of an error (such as @cancellable being cancelled, or a
893    /// failure to connect to the session bus), [`false`] is returned and @error
894    /// is set appropriately.
895    ///
896    /// Note: the return value of this function is not an indicator that this
897    /// instance is or is not the primary instance of the application.  See
898    /// g_application_get_is_remote() for that.
899    /// ## `cancellable`
900    /// a #GCancellable, or [`None`]
901    ///
902    /// # Returns
903    ///
904    /// [`true`] if registration succeeded
905    #[doc(alias = "g_application_register")]
906    fn register(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), glib::Error> {
907        unsafe {
908            let mut error = std::ptr::null_mut();
909            let is_ok = ffi::g_application_register(
910                self.as_ref().to_glib_none().0,
911                cancellable.map(|p| p.as_ref()).to_glib_none().0,
912                &mut error,
913            );
914            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
915            if error.is_null() {
916                Ok(())
917            } else {
918                Err(from_glib_full(error))
919            }
920        }
921    }
922
923    /// Sends a notification on behalf of @self to the desktop shell.
924    /// There is no guarantee that the notification is displayed immediately,
925    /// or even at all.
926    ///
927    /// Notifications may persist after the application exits. It will be
928    /// D-Bus-activated when the notification or one of its actions is
929    /// activated.
930    ///
931    /// Modifying @notification after this call has no effect. However, the
932    /// object can be reused for a later call to this function.
933    ///
934    /// @id may be any string that uniquely identifies the event for the
935    /// application. It does not need to be in any special format. For
936    /// example, "new-message" might be appropriate for a notification about
937    /// new messages.
938    ///
939    /// If a previous notification was sent with the same @id, it will be
940    /// replaced with @notification and shown again as if it was a new
941    /// notification. This works even for notifications sent from a previous
942    /// execution of the application, as long as @id is the same string.
943    ///
944    /// @id may be `NULL`, but it is impossible to replace or withdraw
945    /// notifications without an id.
946    ///
947    /// If @notification is no longer relevant, it can be withdrawn with
948    /// [`withdraw_notification()`][Self::withdraw_notification()].
949    ///
950    /// It is an error to call this function if @self has no
951    /// application ID.
952    /// ## `id`
953    /// id of the notification, or [`None`]
954    /// ## `notification`
955    /// the #GNotification to send
956    #[doc(alias = "g_application_send_notification")]
957    fn send_notification(&self, id: Option<&str>, notification: &Notification) {
958        unsafe {
959            ffi::g_application_send_notification(
960                self.as_ref().to_glib_none().0,
961                id.to_glib_none().0,
962                notification.to_glib_none().0,
963            );
964        }
965    }
966
967    /// Sets the unique identifier for @self.
968    ///
969    /// The application id can only be modified if @self has not yet
970    /// been registered.
971    ///
972    /// If non-[`None`], the application id must be valid.  See
973    /// g_application_id_is_valid().
974    /// ## `application_id`
975    /// the identifier for @self
976    #[doc(alias = "g_application_set_application_id")]
977    #[doc(alias = "application-id")]
978    fn set_application_id(&self, application_id: Option<&str>) {
979        unsafe {
980            ffi::g_application_set_application_id(
981                self.as_ref().to_glib_none().0,
982                application_id.to_glib_none().0,
983            );
984        }
985    }
986
987    /// Sets or unsets the default application for the process, as returned
988    /// by g_application_get_default().
989    ///
990    /// This function does not take its own reference on @self.  If
991    /// @self is destroyed then the default application will revert
992    /// back to [`None`].
993    #[doc(alias = "g_application_set_default")]
994    fn set_default(&self) {
995        unsafe {
996            ffi::g_application_set_default(self.as_ref().to_glib_none().0);
997        }
998    }
999
1000    /// Sets the flags for @self.
1001    ///
1002    /// The flags can only be modified if @self has not yet been
1003    /// registered.
1004    ///
1005    /// See #GApplicationFlags.
1006    /// ## `flags`
1007    /// the flags for @self
1008    #[doc(alias = "g_application_set_flags")]
1009    #[doc(alias = "flags")]
1010    fn set_flags(&self, flags: ApplicationFlags) {
1011        unsafe {
1012            ffi::g_application_set_flags(self.as_ref().to_glib_none().0, flags.into_glib());
1013        }
1014    }
1015
1016    /// Sets the current inactivity timeout for the application.
1017    ///
1018    /// This is the amount of time (in milliseconds) after the last call to
1019    /// g_application_release() before the application stops running.
1020    ///
1021    /// This call has no side effects of its own.  The value set here is only
1022    /// used for next time g_application_release() drops the use count to
1023    /// zero.  Any timeouts currently in progress are not impacted.
1024    /// ## `inactivity_timeout`
1025    /// the timeout, in milliseconds
1026    #[doc(alias = "g_application_set_inactivity_timeout")]
1027    #[doc(alias = "inactivity-timeout")]
1028    fn set_inactivity_timeout(&self, inactivity_timeout: u32) {
1029        unsafe {
1030            ffi::g_application_set_inactivity_timeout(
1031                self.as_ref().to_glib_none().0,
1032                inactivity_timeout,
1033            );
1034        }
1035    }
1036
1037    /// Adds a description to the @self option context.
1038    ///
1039    /// See g_option_context_set_description() for more information.
1040    /// ## `description`
1041    /// a string to be shown in `--help` output
1042    ///  after the list of options, or [`None`]
1043    #[doc(alias = "g_application_set_option_context_description")]
1044    fn set_option_context_description(&self, description: Option<&str>) {
1045        unsafe {
1046            ffi::g_application_set_option_context_description(
1047                self.as_ref().to_glib_none().0,
1048                description.to_glib_none().0,
1049            );
1050        }
1051    }
1052
1053    /// Sets the parameter string to be used by the commandline handling of @self.
1054    ///
1055    /// This function registers the argument to be passed to g_option_context_new()
1056    /// when the internal #GOptionContext of @self is created.
1057    ///
1058    /// See g_option_context_new() for more information about @parameter_string.
1059    /// ## `parameter_string`
1060    /// a string which is displayed
1061    ///   in the first line of `--help` output, after the usage summary `programname [OPTION...]`.
1062    #[doc(alias = "g_application_set_option_context_parameter_string")]
1063    fn set_option_context_parameter_string(&self, parameter_string: Option<&str>) {
1064        unsafe {
1065            ffi::g_application_set_option_context_parameter_string(
1066                self.as_ref().to_glib_none().0,
1067                parameter_string.to_glib_none().0,
1068            );
1069        }
1070    }
1071
1072    /// Adds a summary to the @self option context.
1073    ///
1074    /// See g_option_context_set_summary() for more information.
1075    /// ## `summary`
1076    /// a string to be shown in `--help` output
1077    ///  before the list of options, or [`None`]
1078    #[doc(alias = "g_application_set_option_context_summary")]
1079    fn set_option_context_summary(&self, summary: Option<&str>) {
1080        unsafe {
1081            ffi::g_application_set_option_context_summary(
1082                self.as_ref().to_glib_none().0,
1083                summary.to_glib_none().0,
1084            );
1085        }
1086    }
1087
1088    /// Sets (or unsets) the base resource path of @self.
1089    ///
1090    /// The path is used to automatically load various
1091    /// [application resources][`Resource`][crate::Resource] such as menu layouts and
1092    /// action descriptions. The various types of resources will be found at
1093    /// fixed names relative to the given base path.
1094    ///
1095    /// By default, the resource base path is determined from the application
1096    /// ID by prefixing '/' and replacing each '.' with '/'.  This is done at
1097    /// the time that the #GApplication object is constructed.  Changes to
1098    /// the application ID after that point will not have an impact on the
1099    /// resource base path.
1100    ///
1101    /// As an example, if the application has an ID of "org.example.app" then
1102    /// the default resource base path will be "/org/example/app".  If this
1103    /// is a #GtkApplication (and you have not manually changed the path)
1104    /// then Gtk will then search for the menus of the application at
1105    /// "/org/example/app/gtk/menus.ui".
1106    ///
1107    /// See #GResource for more information about adding resources to your
1108    /// application.
1109    ///
1110    /// You can disable automatic resource loading functionality by setting
1111    /// the path to [`None`].
1112    ///
1113    /// Changing the resource base path once the application is running is
1114    /// not recommended.  The point at which the resource path is consulted
1115    /// for forming paths for various purposes is unspecified.  When writing
1116    /// a sub-class of #GApplication you should either set the
1117    /// #GApplication:resource-base-path property at construction time, or call
1118    /// this function during the instance initialization. Alternatively, you
1119    /// can call this function in the #GApplicationClass.startup virtual function,
1120    /// before chaining up to the parent implementation.
1121    /// ## `resource_path`
1122    /// the resource path to use
1123    #[doc(alias = "g_application_set_resource_base_path")]
1124    #[doc(alias = "resource-base-path")]
1125    fn set_resource_base_path(&self, resource_path: Option<&str>) {
1126        unsafe {
1127            ffi::g_application_set_resource_base_path(
1128                self.as_ref().to_glib_none().0,
1129                resource_path.to_glib_none().0,
1130            );
1131        }
1132    }
1133
1134    /// Sets the version number of @self. This will be used to implement
1135    /// a `--version` command line argument
1136    ///
1137    /// The application version can only be modified if @self has not yet
1138    /// been registered.
1139    /// ## `version`
1140    /// the version of @self
1141    #[cfg(feature = "v2_80")]
1142    #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))]
1143    #[doc(alias = "g_application_set_version")]
1144    #[doc(alias = "version")]
1145    fn set_version(&self, version: &str) {
1146        unsafe {
1147            ffi::g_application_set_version(
1148                self.as_ref().to_glib_none().0,
1149                version.to_glib_none().0,
1150            );
1151        }
1152    }
1153
1154    /// Destroys a binding between @property and the busy state of
1155    /// @self that was previously created with
1156    /// g_application_bind_busy_property().
1157    /// ## `object`
1158    /// a #GObject
1159    /// ## `property`
1160    /// the name of a boolean property of @object
1161    #[doc(alias = "g_application_unbind_busy_property")]
1162    fn unbind_busy_property(&self, object: &impl IsA<glib::Object>, property: &str) {
1163        unsafe {
1164            ffi::g_application_unbind_busy_property(
1165                self.as_ref().to_glib_none().0,
1166                object.as_ref().to_glib_none().0,
1167                property.to_glib_none().0,
1168            );
1169        }
1170    }
1171
1172    /// Withdraws a notification that was sent with
1173    /// g_application_send_notification().
1174    ///
1175    /// This call does nothing if a notification with @id doesn't exist or
1176    /// the notification was never sent.
1177    ///
1178    /// This function works even for notifications sent in previous
1179    /// executions of this application, as long @id is the same as it was for
1180    /// the sent notification.
1181    ///
1182    /// Note that notifications are dismissed when the user clicks on one
1183    /// of the buttons in a notification or triggers its default action, so
1184    /// there is no need to explicitly withdraw the notification in that case.
1185    /// ## `id`
1186    /// id of a previously sent notification
1187    #[doc(alias = "g_application_withdraw_notification")]
1188    fn withdraw_notification(&self, id: &str) {
1189        unsafe {
1190            ffi::g_application_withdraw_notification(
1191                self.as_ref().to_glib_none().0,
1192                id.to_glib_none().0,
1193            );
1194        }
1195    }
1196
1197    /// The ::activate signal is emitted on the primary instance when an
1198    /// activation occurs. See g_application_activate().
1199    #[doc(alias = "activate")]
1200    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1201        unsafe extern "C" fn activate_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1202            this: *mut ffi::GApplication,
1203            f: glib::ffi::gpointer,
1204        ) {
1205            let f: &F = &*(f as *const F);
1206            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1207        }
1208        unsafe {
1209            let f: Box_<F> = Box_::new(f);
1210            connect_raw(
1211                self.as_ptr() as *mut _,
1212                c"activate".as_ptr() as *const _,
1213                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1214                    activate_trampoline::<Self, F> as *const (),
1215                )),
1216                Box_::into_raw(f),
1217            )
1218        }
1219    }
1220
1221    /// The ::command-line signal is emitted on the primary instance when
1222    /// a commandline is not handled locally. See g_application_run() and
1223    /// the #GApplicationCommandLine documentation for more information.
1224    /// ## `command_line`
1225    /// a #GApplicationCommandLine representing the
1226    ///     passed commandline
1227    ///
1228    /// # Returns
1229    ///
1230    /// An integer that is set as the exit status for the calling
1231    ///   process. See g_application_command_line_set_exit_status().
1232    #[doc(alias = "command-line")]
1233    fn connect_command_line<F: Fn(&Self, &ApplicationCommandLine) -> i32 + 'static>(
1234        &self,
1235        f: F,
1236    ) -> SignalHandlerId {
1237        unsafe extern "C" fn command_line_trampoline<
1238            P: IsA<Application>,
1239            F: Fn(&P, &ApplicationCommandLine) -> i32 + 'static,
1240        >(
1241            this: *mut ffi::GApplication,
1242            command_line: *mut ffi::GApplicationCommandLine,
1243            f: glib::ffi::gpointer,
1244        ) -> std::ffi::c_int {
1245            let f: &F = &*(f as *const F);
1246            f(
1247                Application::from_glib_borrow(this).unsafe_cast_ref(),
1248                &from_glib_borrow(command_line),
1249            )
1250        }
1251        unsafe {
1252            let f: Box_<F> = Box_::new(f);
1253            connect_raw(
1254                self.as_ptr() as *mut _,
1255                c"command-line".as_ptr() as *const _,
1256                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1257                    command_line_trampoline::<Self, F> as *const (),
1258                )),
1259                Box_::into_raw(f),
1260            )
1261        }
1262    }
1263
1264    /// The ::handle-local-options signal is emitted on the local instance
1265    /// after the parsing of the commandline options has occurred.
1266    ///
1267    /// You can add options to be recognised during commandline option
1268    /// parsing using g_application_add_main_option_entries() and
1269    /// g_application_add_option_group().
1270    ///
1271    /// Signal handlers can inspect @options (along with values pointed to
1272    /// from the @arg_data of an installed #GOptionEntrys) in order to
1273    /// decide to perform certain actions, including direct local handling
1274    /// (which may be useful for options like --version).
1275    ///
1276    /// In the event that the application is marked
1277    /// [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] the "normal processing" will
1278    /// send the @options dictionary to the primary instance where it can be
1279    /// read with g_application_command_line_get_options_dict().  The signal
1280    /// handler can modify the dictionary before returning, and the
1281    /// modified dictionary will be sent.
1282    ///
1283    /// In the event that [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] is not set,
1284    /// "normal processing" will treat the remaining uncollected command
1285    /// line arguments as filenames or URIs.  If there are no arguments,
1286    /// the application is activated by g_application_activate().  One or
1287    /// more arguments results in a call to g_application_open().
1288    ///
1289    /// If you want to handle the local commandline arguments for yourself
1290    /// by converting them to calls to g_application_open() or
1291    /// g_action_group_activate_action() then you must be sure to register
1292    /// the application first.  You should probably not call
1293    /// g_application_activate() for yourself, however: just return -1 and
1294    /// allow the default handler to do it for you.  This will ensure that
1295    /// the `--gapplication-service` switch works properly (i.e. no activation
1296    /// in that case).
1297    ///
1298    /// Note that this signal is emitted from the default implementation of
1299    /// local_command_line().  If you override that function and don't
1300    /// chain up then this signal will never be emitted.
1301    ///
1302    /// You can override local_command_line() if you need more powerful
1303    /// capabilities than what is provided here, but this should not
1304    /// normally be required.
1305    /// ## `options`
1306    /// the options dictionary
1307    ///
1308    /// # Returns
1309    ///
1310    /// an exit code. If you have handled your options and want
1311    /// to exit the process, return a non-negative option, 0 for success,
1312    /// and a positive value for failure. To continue, return -1 to let
1313    /// the default option processing continue.
1314    #[doc(alias = "handle-local-options")]
1315    fn connect_handle_local_options<F: Fn(&Self, &glib::VariantDict) -> i32 + 'static>(
1316        &self,
1317        f: F,
1318    ) -> SignalHandlerId {
1319        unsafe extern "C" fn handle_local_options_trampoline<
1320            P: IsA<Application>,
1321            F: Fn(&P, &glib::VariantDict) -> i32 + 'static,
1322        >(
1323            this: *mut ffi::GApplication,
1324            options: *mut glib::ffi::GVariantDict,
1325            f: glib::ffi::gpointer,
1326        ) -> std::ffi::c_int {
1327            let f: &F = &*(f as *const F);
1328            f(
1329                Application::from_glib_borrow(this).unsafe_cast_ref(),
1330                &from_glib_borrow(options),
1331            )
1332        }
1333        unsafe {
1334            let f: Box_<F> = Box_::new(f);
1335            connect_raw(
1336                self.as_ptr() as *mut _,
1337                c"handle-local-options".as_ptr() as *const _,
1338                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1339                    handle_local_options_trampoline::<Self, F> as *const (),
1340                )),
1341                Box_::into_raw(f),
1342            )
1343        }
1344    }
1345
1346    /// The ::name-lost signal is emitted only on the registered primary instance
1347    /// when a new instance has taken over. This can only happen if the application
1348    /// is using the [`ApplicationFlags::ALLOW_REPLACEMENT`][crate::ApplicationFlags::ALLOW_REPLACEMENT] flag.
1349    ///
1350    /// The default handler for this signal calls g_application_quit().
1351    ///
1352    /// # Returns
1353    ///
1354    /// [`true`] if the signal has been handled
1355    #[cfg(feature = "v2_60")]
1356    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
1357    #[doc(alias = "name-lost")]
1358    fn connect_name_lost<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
1359        unsafe extern "C" fn name_lost_trampoline<
1360            P: IsA<Application>,
1361            F: Fn(&P) -> bool + 'static,
1362        >(
1363            this: *mut ffi::GApplication,
1364            f: glib::ffi::gpointer,
1365        ) -> glib::ffi::gboolean {
1366            let f: &F = &*(f as *const F);
1367            f(Application::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
1368        }
1369        unsafe {
1370            let f: Box_<F> = Box_::new(f);
1371            connect_raw(
1372                self.as_ptr() as *mut _,
1373                c"name-lost".as_ptr() as *const _,
1374                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1375                    name_lost_trampoline::<Self, F> as *const (),
1376                )),
1377                Box_::into_raw(f),
1378            )
1379        }
1380    }
1381
1382    /// The ::shutdown signal is emitted only on the registered primary instance
1383    /// immediately after the main loop terminates.
1384    #[doc(alias = "shutdown")]
1385    fn connect_shutdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1386        unsafe extern "C" fn shutdown_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1387            this: *mut ffi::GApplication,
1388            f: glib::ffi::gpointer,
1389        ) {
1390            let f: &F = &*(f as *const F);
1391            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1392        }
1393        unsafe {
1394            let f: Box_<F> = Box_::new(f);
1395            connect_raw(
1396                self.as_ptr() as *mut _,
1397                c"shutdown".as_ptr() as *const _,
1398                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1399                    shutdown_trampoline::<Self, F> as *const (),
1400                )),
1401                Box_::into_raw(f),
1402            )
1403        }
1404    }
1405
1406    /// The ::startup signal is emitted on the primary instance immediately
1407    /// after registration. See g_application_register().
1408    #[doc(alias = "startup")]
1409    fn connect_startup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1410        unsafe extern "C" fn startup_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1411            this: *mut ffi::GApplication,
1412            f: glib::ffi::gpointer,
1413        ) {
1414            let f: &F = &*(f as *const F);
1415            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1416        }
1417        unsafe {
1418            let f: Box_<F> = Box_::new(f);
1419            connect_raw(
1420                self.as_ptr() as *mut _,
1421                c"startup".as_ptr() as *const _,
1422                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1423                    startup_trampoline::<Self, F> as *const (),
1424                )),
1425                Box_::into_raw(f),
1426            )
1427        }
1428    }
1429
1430    #[doc(alias = "application-id")]
1431    fn connect_application_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1432        unsafe extern "C" fn notify_application_id_trampoline<
1433            P: IsA<Application>,
1434            F: Fn(&P) + 'static,
1435        >(
1436            this: *mut ffi::GApplication,
1437            _param_spec: glib::ffi::gpointer,
1438            f: glib::ffi::gpointer,
1439        ) {
1440            let f: &F = &*(f as *const F);
1441            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1442        }
1443        unsafe {
1444            let f: Box_<F> = Box_::new(f);
1445            connect_raw(
1446                self.as_ptr() as *mut _,
1447                c"notify::application-id".as_ptr() as *const _,
1448                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1449                    notify_application_id_trampoline::<Self, F> as *const (),
1450                )),
1451                Box_::into_raw(f),
1452            )
1453        }
1454    }
1455
1456    #[doc(alias = "flags")]
1457    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1458        unsafe extern "C" fn notify_flags_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1459            this: *mut ffi::GApplication,
1460            _param_spec: glib::ffi::gpointer,
1461            f: glib::ffi::gpointer,
1462        ) {
1463            let f: &F = &*(f as *const F);
1464            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1465        }
1466        unsafe {
1467            let f: Box_<F> = Box_::new(f);
1468            connect_raw(
1469                self.as_ptr() as *mut _,
1470                c"notify::flags".as_ptr() as *const _,
1471                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1472                    notify_flags_trampoline::<Self, F> as *const (),
1473                )),
1474                Box_::into_raw(f),
1475            )
1476        }
1477    }
1478
1479    #[doc(alias = "inactivity-timeout")]
1480    fn connect_inactivity_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1481        unsafe extern "C" fn notify_inactivity_timeout_trampoline<
1482            P: IsA<Application>,
1483            F: Fn(&P) + 'static,
1484        >(
1485            this: *mut ffi::GApplication,
1486            _param_spec: glib::ffi::gpointer,
1487            f: glib::ffi::gpointer,
1488        ) {
1489            let f: &F = &*(f as *const F);
1490            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1491        }
1492        unsafe {
1493            let f: Box_<F> = Box_::new(f);
1494            connect_raw(
1495                self.as_ptr() as *mut _,
1496                c"notify::inactivity-timeout".as_ptr() as *const _,
1497                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1498                    notify_inactivity_timeout_trampoline::<Self, F> as *const (),
1499                )),
1500                Box_::into_raw(f),
1501            )
1502        }
1503    }
1504
1505    #[doc(alias = "is-busy")]
1506    fn connect_is_busy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1507        unsafe extern "C" fn notify_is_busy_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1508            this: *mut ffi::GApplication,
1509            _param_spec: glib::ffi::gpointer,
1510            f: glib::ffi::gpointer,
1511        ) {
1512            let f: &F = &*(f as *const F);
1513            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1514        }
1515        unsafe {
1516            let f: Box_<F> = Box_::new(f);
1517            connect_raw(
1518                self.as_ptr() as *mut _,
1519                c"notify::is-busy".as_ptr() as *const _,
1520                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1521                    notify_is_busy_trampoline::<Self, F> as *const (),
1522                )),
1523                Box_::into_raw(f),
1524            )
1525        }
1526    }
1527
1528    #[doc(alias = "is-registered")]
1529    fn connect_is_registered_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1530        unsafe extern "C" fn notify_is_registered_trampoline<
1531            P: IsA<Application>,
1532            F: Fn(&P) + 'static,
1533        >(
1534            this: *mut ffi::GApplication,
1535            _param_spec: glib::ffi::gpointer,
1536            f: glib::ffi::gpointer,
1537        ) {
1538            let f: &F = &*(f as *const F);
1539            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1540        }
1541        unsafe {
1542            let f: Box_<F> = Box_::new(f);
1543            connect_raw(
1544                self.as_ptr() as *mut _,
1545                c"notify::is-registered".as_ptr() as *const _,
1546                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1547                    notify_is_registered_trampoline::<Self, F> as *const (),
1548                )),
1549                Box_::into_raw(f),
1550            )
1551        }
1552    }
1553
1554    #[doc(alias = "is-remote")]
1555    fn connect_is_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1556        unsafe extern "C" fn notify_is_remote_trampoline<
1557            P: IsA<Application>,
1558            F: Fn(&P) + 'static,
1559        >(
1560            this: *mut ffi::GApplication,
1561            _param_spec: glib::ffi::gpointer,
1562            f: glib::ffi::gpointer,
1563        ) {
1564            let f: &F = &*(f as *const F);
1565            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1566        }
1567        unsafe {
1568            let f: Box_<F> = Box_::new(f);
1569            connect_raw(
1570                self.as_ptr() as *mut _,
1571                c"notify::is-remote".as_ptr() as *const _,
1572                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1573                    notify_is_remote_trampoline::<Self, F> as *const (),
1574                )),
1575                Box_::into_raw(f),
1576            )
1577        }
1578    }
1579
1580    #[doc(alias = "resource-base-path")]
1581    fn connect_resource_base_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1582        unsafe extern "C" fn notify_resource_base_path_trampoline<
1583            P: IsA<Application>,
1584            F: Fn(&P) + 'static,
1585        >(
1586            this: *mut ffi::GApplication,
1587            _param_spec: glib::ffi::gpointer,
1588            f: glib::ffi::gpointer,
1589        ) {
1590            let f: &F = &*(f as *const F);
1591            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1592        }
1593        unsafe {
1594            let f: Box_<F> = Box_::new(f);
1595            connect_raw(
1596                self.as_ptr() as *mut _,
1597                c"notify::resource-base-path".as_ptr() as *const _,
1598                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1599                    notify_resource_base_path_trampoline::<Self, F> as *const (),
1600                )),
1601                Box_::into_raw(f),
1602            )
1603        }
1604    }
1605
1606    #[cfg(feature = "v2_80")]
1607    #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))]
1608    #[doc(alias = "version")]
1609    fn connect_version_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1610        unsafe extern "C" fn notify_version_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1611            this: *mut ffi::GApplication,
1612            _param_spec: glib::ffi::gpointer,
1613            f: glib::ffi::gpointer,
1614        ) {
1615            let f: &F = &*(f as *const F);
1616            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1617        }
1618        unsafe {
1619            let f: Box_<F> = Box_::new(f);
1620            connect_raw(
1621                self.as_ptr() as *mut _,
1622                c"notify::version".as_ptr() as *const _,
1623                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1624                    notify_version_trampoline::<Self, F> as *const (),
1625                )),
1626                Box_::into_raw(f),
1627            )
1628        }
1629    }
1630}
1631
1632impl<O: IsA<Application>> ApplicationExt for O {}