Skip to main content

gtk4/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
5#[cfg(feature = "v4_22")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
7use crate::RestoreReason;
8use crate::{ApplicationInhibitFlags, Window, ffi};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{SignalHandlerId, connect_raw},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// A high-level API for writing applications.
19    ///
20    /// [`Application`][crate::Application] supports many aspects of writing a GTK application
21    /// in a convenient fashion, without enforcing a one-size-fits-all model.
22    ///
23    /// Currently, it handles GTK initialization, application uniqueness, session
24    /// management, provides some basic scriptability and desktop shell integration
25    /// by exporting actions and menus and manages a list of toplevel windows whose
26    /// life-cycle is automatically tied to the life-cycle of your application.
27    ///
28    /// While [`Application`][crate::Application] works fine with plain [`Window`][crate::Window]s,
29    /// it is recommended to use it together with [`ApplicationWindow`][crate::ApplicationWindow].
30    ///
31    /// ## Initialization
32    ///
33    /// A typical [`Application`][crate::Application] will create a window in its
34    /// [`activate`][struct@crate::GIO::Application#activate], [`open`][struct@crate::GIO::Application#open]
35    /// or [`command-line`][struct@crate::GIO::Application#command-line] handlers. Note that all
36    /// of these signals may be emitted multiple times, so handlers must
37    /// be careful to take existing windows into account.
38    ///
39    /// A typical ::activate handler should look like this:
40    ///
41    /// ```text
42    /// static void
43    /// activate (GApplication *gapp)
44    /// {
45    ///   GtkApplication *app = GTK_APPLICATION (gapp);
46    ///   GtkWindow *window;
47    ///
48    ///   window = gtk_application_get_active_window (app);
49    ///   if (!window)
50    ///     window = create_window (app);
51    ///
52    ///   gtk_window_present (window);
53    /// }
54    /// ```
55    ///
56    /// ## Automatic resources
57    ///
58    /// [`Application`][crate::Application] will automatically load menus from the [`Builder`][crate::Builder]
59    /// resource located at "gtk/menus.ui", relative to the application's
60    /// resource base path (see [`ApplicationExtManual::set_resource_base_path()`][crate::gio::prelude::ApplicationExtManual::set_resource_base_path()]).
61    /// The menu with the ID "menubar" is taken as the application's
62    /// menubar. Additional menus (most interesting submenus) can be named
63    /// and accessed via [`GtkApplicationExt::menu_by_id()`][crate::prelude::GtkApplicationExt::menu_by_id()] which allows for
64    /// dynamic population of a part of the menu structure.
65    ///
66    /// Note that automatic resource loading uses the resource base path
67    /// that is set at construction time and will not work if the resource
68    /// base path is changed at a later time.
69    ///
70    /// It is also possible to provide the menubar manually using
71    /// [`GtkApplicationExt::set_menubar()`][crate::prelude::GtkApplicationExt::set_menubar()].
72    ///
73    /// [`Application`][crate::Application] will also automatically setup an icon search path for
74    /// the default icon theme by appending "icons" to the resource base
75    /// path. This allows your application to easily store its icons as
76    /// resources. See [`IconTheme::add_resource_path()`][crate::IconTheme::add_resource_path()] for more
77    /// information.
78    ///
79    /// If there is a resource located at `gtk/help-overlay.ui` which
80    /// defines a [`ShortcutsWindow`][crate::ShortcutsWindow] with ID `help_overlay` then
81    /// [`Application`][crate::Application] associates an instance of this shortcuts window with
82    /// each [`ApplicationWindow`][crate::ApplicationWindow] and sets up the keyboard accelerator
83    /// <kbd>Control</kbd>+<kbd>?</kbd> to open it. To create a menu item that
84    /// displays the shortcuts window, associate the item with the action
85    /// `win.show-help-overlay`.
86    ///
87    /// [`Application`][crate::Application] will also automatically set the application id as the
88    /// default window icon. Use [`Window::set_default_icon_name()`][crate::Window::set_default_icon_name()] or
89    /// [`icon-name`][struct@crate::Window#icon-name] to override that behavior.
90    ///
91    /// ## State saving
92    ///
93    /// [`Application`][crate::Application] registers with a session manager if possible and
94    /// offers various functionality related to the session life-cycle,
95    /// such as state saving.
96    ///
97    /// State-saving functionality can be enabled by setting the
98    /// [`support-save`][struct@crate::Application#support-save] property to true.
99    ///
100    /// In order to save and restore per-window state, applications must
101    /// connect to the [`restore-window`][struct@crate::Application#restore-window] signal and
102    /// handle the [`save-state`][struct@crate::ApplicationWindow#save-state] signal. There
103    /// are also [`restore-state`][struct@crate::Application#restore-state] and
104    /// [`save-state`][struct@crate::GtkApplication#save-state] signals, which can be used
105    /// for global state that is not connected to any window.
106    ///
107    /// [`Application`][crate::Application] automatically saves state before app shutdown, and by
108    /// default periodically auto-saves app state (as configured by the
109    /// [`autosave-interval`][struct@crate::Application#autosave-interval] property). Applications can
110    /// also call [`GtkApplicationExt::save()`][crate::prelude::GtkApplicationExt::save()] themselves at opportune times.
111    ///
112    /// # Inhibiting
113    ///
114    /// An application can block various ways to end the session with
115    /// the [`GtkApplicationExt::inhibit()`][crate::prelude::GtkApplicationExt::inhibit()] function. Typical use cases for
116    /// this kind of inhibiting are long-running, uninterruptible operations,
117    /// such as burning a CD or performing a disk backup. The session
118    /// manager may not honor the inhibitor, but it can be expected to
119    /// inform the user about the negative consequences of ending the
120    /// session while inhibitors are present.
121    ///
122    /// ## A simple application
123    ///
124    /// [A simple example](https://gitlab.gnome.org/GNOME/gtk/tree/main/examples/bp/bloatpad.c)
125    /// is available in the GTK source code repository
126    ///
127    /// ## See Also
128    ///
129    /// - [Using GtkApplication](https://developer.gnome.org/documentation/tutorials/application.html)
130    /// - [Getting Started with GTK: Basics](getting_started.html#basics)
131    ///
132    /// ## Properties
133    ///
134    ///
135    /// #### `active-window`
136    ///  The currently focused window of the application.
137    ///
138    /// Readable
139    ///
140    ///
141    /// #### `autosave-interval`
142    ///  The number of seconds between automatic state saves. Defaults to 15.
143    /// A value of 0 will opt out of automatic state saving.
144    ///
145    /// Readable | Writeable
146    ///
147    ///
148    /// #### `menubar`
149    ///  The menu model to be used for the application's menu bar.
150    ///
151    /// Readable | Writeable
152    ///
153    ///
154    /// #### `register-session`
155    ///  Set this property to true to register with the session manager.
156    ///
157    /// This will make GTK track the session state (such as the
158    /// [`screensaver-active`][struct@crate::Application#screensaver-active] property).
159    ///
160    /// Readable | Writeable
161    ///
162    ///
163    /// #### `screensaver-active`
164    ///  This property is true if GTK believes that the screensaver
165    /// is currently active.
166    ///
167    /// Tracking the screensaver state is currently only supported on
168    /// Linux.
169    ///
170    /// Readable
171    ///
172    ///
173    /// #### `support-save`
174    ///  Set this property to true if the application supports
175    /// state saving and restoring.
176    ///
177    /// Readable | Writeable
178    /// <details><summary><h4>Application</h4></summary>
179    ///
180    ///
181    /// #### `action-group`
182    ///  The group of actions that the application exports.
183    ///
184    /// Writeable
185    ///
186    ///
187    /// #### `application-id`
188    ///  The unique identifier for the application.
189    ///
190    /// Readable | Writeable | Construct
191    ///
192    ///
193    /// #### `flags`
194    ///  Flags specifying the behaviour of the application.
195    ///
196    /// Readable | Writeable
197    ///
198    ///
199    /// #### `inactivity-timeout`
200    ///  Time (in milliseconds) to stay alive after becoming idle.
201    ///
202    /// Readable | Writeable
203    ///
204    ///
205    /// #### `is-busy`
206    ///  Whether the application is currently marked as busy through
207    /// g_application_mark_busy() or g_application_bind_busy_property().
208    ///
209    /// Readable
210    ///
211    ///
212    /// #### `is-registered`
213    ///  Whether [`ApplicationExtManual::register()`][crate::gio::prelude::ApplicationExtManual::register()] has been called.
214    ///
215    /// Readable
216    ///
217    ///
218    /// #### `is-remote`
219    ///  Whether this application instance is remote.
220    ///
221    /// Readable
222    ///
223    ///
224    /// #### `resource-base-path`
225    ///  The base resource path for the application.
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `version`
231    ///  The human-readable version number of the application.
232    ///
233    /// Readable | Writeable
234    /// </details>
235    ///
236    /// ## Signals
237    ///
238    ///
239    /// #### `query-end`
240    ///  Emitted when the session manager is about to end the session.
241    ///
242    /// Applications can connect to this signal and call
243    /// [`GtkApplicationExt::inhibit()`][crate::prelude::GtkApplicationExt::inhibit()] with [flags@Gtk.ApplicationInhibitFlags.logout]
244    /// to delay the end of the session until state has been saved.
245    ///
246    ///
247    ///
248    ///
249    /// #### `restore-state`
250    ///  Emitted when application global state is restored.
251    ///
252    /// The handler for this signal should do the opposite of what the
253    /// corresponding handler for [`save-state`][struct@crate::Application#save-state]
254    /// does.
255    ///
256    ///
257    ///
258    ///
259    /// #### `restore-window`
260    ///  Emitted when an application's per-window state is restored.
261    ///
262    /// In response to this signal, you should create a new application
263    /// window, add it to @application, apply the provided @state, and present it.
264    /// The application can use the @reason to determine how much of the state
265    /// should be restored.
266    ///
267    /// You must be careful to be robust in the face of app upgrades and downgrades:
268    /// the @state might have been created by a previous or occasionally even a future
269    /// version of your app. Do not assume that a given key exists in the state.
270    /// Apps must try to restore state saved by a previous version, but are free to
271    /// discard state if it was written by a future version.
272    ///
273    /// GTK will remember which window the user was using most recently, and will
274    /// emit this signal for that window first. Thus, if you decide that the provided
275    /// @reason means that only one window should be restored, you can reliably
276    /// ignore emissions if a window already exists
277    ///
278    /// Note that this signal is not emitted only during the app's initial launch.
279    /// If all windows are closed but the app keeps running, the signal will be
280    /// emitted the next time a new window is opened.
281    ///
282    ///
283    ///
284    ///
285    /// #### `save-state`
286    ///  Emitted when the application is saving global state.
287    ///
288    /// The handler for this signal should persist any
289    /// global state of @application into @dict.
290    ///
291    /// See [`restore-state`][struct@crate::Application#restore-state] for how to
292    /// restore global state, and [`save-state`][struct@crate::ApplicationWindow#save-state]
293    /// and [`restore-window`][struct@crate::Application#restore-window] for handling
294    /// per-window state.
295    ///
296    ///
297    ///
298    ///
299    /// #### `window-added`
300    ///  Emitted when a window is added to an application.
301    ///
302    /// See [`GtkApplicationExt::add_window()`][crate::prelude::GtkApplicationExt::add_window()].
303    ///
304    ///
305    ///
306    ///
307    /// #### `window-removed`
308    ///  Emitted when a window is removed from an application.
309    ///
310    /// This can happen as a side-effect of the window being destroyed
311    /// or explicitly through [`GtkApplicationExt::remove_window()`][crate::prelude::GtkApplicationExt::remove_window()].
312    ///
313    ///
314    /// <details><summary><h4>Application</h4></summary>
315    ///
316    ///
317    /// #### `activate`
318    ///  The ::activate signal is emitted on the primary instance when an
319    /// activation occurs. See g_application_activate().
320    ///
321    ///
322    ///
323    ///
324    /// #### `command-line`
325    ///  The ::command-line signal is emitted on the primary instance when
326    /// a commandline is not handled locally. See g_application_run() and
327    /// the #GApplicationCommandLine documentation for more information.
328    ///
329    ///
330    ///
331    ///
332    /// #### `handle-local-options`
333    ///  The ::handle-local-options signal is emitted on the local instance
334    /// after the parsing of the commandline options has occurred.
335    ///
336    /// You can add options to be recognised during commandline option
337    /// parsing using g_application_add_main_option_entries() and
338    /// g_application_add_option_group().
339    ///
340    /// Signal handlers can inspect @options (along with values pointed to
341    /// from the @arg_data of an installed #GOptionEntrys) in order to
342    /// decide to perform certain actions, including direct local handling
343    /// (which may be useful for options like --version).
344    ///
345    /// In the event that the application is marked
346    /// [`gio::ApplicationFlags::HANDLES_COMMAND_LINE`][crate::gio::ApplicationFlags::HANDLES_COMMAND_LINE] the "normal processing" will
347    /// send the @options dictionary to the primary instance where it can be
348    /// read with g_application_command_line_get_options_dict().  The signal
349    /// handler can modify the dictionary before returning, and the
350    /// modified dictionary will be sent.
351    ///
352    /// In the event that [`gio::ApplicationFlags::HANDLES_COMMAND_LINE`][crate::gio::ApplicationFlags::HANDLES_COMMAND_LINE] is not set,
353    /// "normal processing" will treat the remaining uncollected command
354    /// line arguments as filenames or URIs.  If there are no arguments,
355    /// the application is activated by g_application_activate().  One or
356    /// more arguments results in a call to g_application_open().
357    ///
358    /// If you want to handle the local commandline arguments for yourself
359    /// by converting them to calls to g_application_open() or
360    /// g_action_group_activate_action() then you must be sure to register
361    /// the application first.  You should probably not call
362    /// g_application_activate() for yourself, however: just return -1 and
363    /// allow the default handler to do it for you.  This will ensure that
364    /// the `--gapplication-service` switch works properly (i.e. no activation
365    /// in that case).
366    ///
367    /// Note that this signal is emitted from the default implementation of
368    /// local_command_line().  If you override that function and don't
369    /// chain up then this signal will never be emitted.
370    ///
371    /// You can override local_command_line() if you need more powerful
372    /// capabilities than what is provided here, but this should not
373    /// normally be required.
374    ///
375    ///
376    ///
377    ///
378    /// #### `name-lost`
379    ///  The ::name-lost signal is emitted only on the registered primary instance
380    /// when a new instance has taken over. This can only happen if the application
381    /// is using the [`gio::ApplicationFlags::ALLOW_REPLACEMENT`][crate::gio::ApplicationFlags::ALLOW_REPLACEMENT] flag.
382    ///
383    /// The default handler for this signal calls g_application_quit().
384    ///
385    ///
386    ///
387    ///
388    /// #### `open`
389    ///  The ::open signal is emitted on the primary instance when there are
390    /// files to open. See g_application_open() for more information.
391    ///
392    ///
393    ///
394    ///
395    /// #### `shutdown`
396    ///  The ::shutdown signal is emitted only on the registered primary instance
397    /// immediately after the main loop terminates.
398    ///
399    ///
400    ///
401    ///
402    /// #### `startup`
403    ///  The ::startup signal is emitted on the primary instance immediately
404    /// after registration. See g_application_register().
405    ///
406    ///
407    /// </details>
408    /// <details><summary><h4>ActionGroup</h4></summary>
409    ///
410    ///
411    /// #### `action-added`
412    ///  Signals that a new action was just added to the group.
413    ///
414    /// This signal is emitted after the action has been added
415    /// and is now visible.
416    ///
417    /// Detailed
418    ///
419    ///
420    /// #### `action-enabled-changed`
421    ///  Signals that the enabled status of the named action has changed.
422    ///
423    /// Detailed
424    ///
425    ///
426    /// #### `action-removed`
427    ///  Signals that an action is just about to be removed from the group.
428    ///
429    /// This signal is emitted before the action is removed, so the action
430    /// is still visible and can be queried from the signal handler.
431    ///
432    /// Detailed
433    ///
434    ///
435    /// #### `action-state-changed`
436    ///  Signals that the state of the named action has changed.
437    ///
438    /// Detailed
439    /// </details>
440    ///
441    /// # Implements
442    ///
443    /// [`GtkApplicationExt`][trait@crate::prelude::GtkApplicationExt], [`trait@gio::prelude::ApplicationExt`], [`trait@glib::ObjectExt`], [`trait@gio::prelude::ActionGroupExt`], [`trait@gio::prelude::ActionMapExt`]
444    #[doc(alias = "GtkApplication")]
445    pub struct Application(Object<ffi::GtkApplication, ffi::GtkApplicationClass>) @extends gio::Application, @implements gio::ActionGroup, gio::ActionMap;
446
447    match fn {
448        type_ => || ffi::gtk_application_get_type(),
449    }
450}
451
452impl Application {
453    pub const NONE: Option<&'static Application> = None;
454
455    // rustdoc-stripper-ignore-next
456    /// Creates a new builder-pattern struct instance to construct [`Application`] objects.
457    ///
458    /// This method returns an instance of [`ApplicationBuilder`](crate::builders::ApplicationBuilder) which can be used to create [`Application`] objects.
459    pub fn builder() -> ApplicationBuilder {
460        ApplicationBuilder::new()
461    }
462}
463
464// rustdoc-stripper-ignore-next
465/// A [builder-pattern] type to construct [`Application`] objects.
466///
467/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
468#[must_use = "The builder must be built to be used"]
469pub struct ApplicationBuilder {
470    builder: glib::object::ObjectBuilder<'static, Application>,
471}
472
473impl ApplicationBuilder {
474    fn new() -> Self {
475        Self {
476            builder: glib::object::Object::builder(),
477        }
478    }
479
480    /// The number of seconds between automatic state saves. Defaults to 15.
481    /// A value of 0 will opt out of automatic state saving.
482    #[cfg(feature = "v4_22")]
483    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
484    pub fn autosave_interval(self, autosave_interval: u32) -> Self {
485        Self {
486            builder: self
487                .builder
488                .property("autosave-interval", autosave_interval),
489        }
490    }
491
492    /// The menu model to be used for the application's menu bar.
493    pub fn menubar(self, menubar: &impl IsA<gio::MenuModel>) -> Self {
494        Self {
495            builder: self.builder.property("menubar", menubar.clone().upcast()),
496        }
497    }
498
499    /// Set this property to true to register with the session manager.
500    ///
501    /// This will make GTK track the session state (such as the
502    /// [`screensaver-active`][struct@crate::Application#screensaver-active] property).
503    /// This property is ignored. GTK always registers
504    /// with the session manager
505    #[cfg_attr(feature = "v4_22", deprecated = "Since 4.22")]
506    pub fn register_session(self, register_session: bool) -> Self {
507        Self {
508            builder: self.builder.property("register-session", register_session),
509        }
510    }
511
512    /// Set this property to true if the application supports
513    /// state saving and restoring.
514    #[cfg(feature = "v4_22")]
515    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
516    pub fn support_save(self, support_save: bool) -> Self {
517        Self {
518            builder: self.builder.property("support-save", support_save),
519        }
520    }
521
522    /// The unique identifier for the application.
523    pub fn application_id(self, application_id: impl Into<glib::GString>) -> Self {
524        Self {
525            builder: self
526                .builder
527                .property("application-id", application_id.into()),
528        }
529    }
530
531    /// Flags specifying the behaviour of the application.
532    pub fn flags(self, flags: gio::ApplicationFlags) -> Self {
533        Self {
534            builder: self.builder.property("flags", flags),
535        }
536    }
537
538    /// Time (in milliseconds) to stay alive after becoming idle.
539    pub fn inactivity_timeout(self, inactivity_timeout: u32) -> Self {
540        Self {
541            builder: self
542                .builder
543                .property("inactivity-timeout", inactivity_timeout),
544        }
545    }
546
547    /// The base resource path for the application.
548    pub fn resource_base_path(self, resource_base_path: impl Into<glib::GString>) -> Self {
549        Self {
550            builder: self
551                .builder
552                .property("resource-base-path", resource_base_path.into()),
553        }
554    }
555
556    /// The human-readable version number of the application.
557    #[cfg(feature = "gio_v2_80")]
558    #[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_80")))]
559    pub fn version(self, version: impl Into<glib::GString>) -> Self {
560        Self {
561            builder: self.builder.property("version", version.into()),
562        }
563    }
564
565    // rustdoc-stripper-ignore-next
566    /// Build the [`Application`].
567    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
568    pub fn build(self) -> Application {
569        let ret = self.builder.build();
570        {
571            Application::register_startup_hook(&ret);
572        }
573        ret
574    }
575}
576
577/// Trait containing all [`struct@Application`] methods.
578///
579/// # Implementors
580///
581/// [`Application`][struct@crate::Application]
582pub trait GtkApplicationExt: IsA<Application> + 'static {
583    /// Adds a window to the application.
584    ///
585    /// This call can only happen after the application has started;
586    /// typically, you should add new application windows in response
587    /// to the emission of the [`activate`][struct@crate::GIO::Application#activate] signal.
588    ///
589    /// This call is equivalent to setting the [`application`][struct@crate::Window#application]
590    /// property of the window to @self.
591    ///
592    /// Normally, the connection between the application and the window
593    /// will remain until the window is destroyed, but you can explicitly
594    /// remove it with [`remove_window()`][Self::remove_window()].
595    ///
596    /// GTK will keep the application running as long as it has any windows.
597    /// ## `window`
598    /// a window
599    #[doc(alias = "gtk_application_add_window")]
600    fn add_window(&self, window: &impl IsA<Window>) {
601        unsafe {
602            ffi::gtk_application_add_window(
603                self.as_ref().to_glib_none().0,
604                window.as_ref().to_glib_none().0,
605            );
606        }
607    }
608
609    /// Forget state that has been previously saved and prevent
610    /// further automatic state saving.
611    ///
612    /// In order to reenable state saving, call
613    /// [`save()`][Self::save()].
614    #[cfg(feature = "v4_22")]
615    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
616    #[doc(alias = "gtk_application_forget")]
617    fn forget(&self) {
618        unsafe {
619            ffi::gtk_application_forget(self.as_ref().to_glib_none().0);
620        }
621    }
622
623    /// Gets the accelerators that are currently associated with
624    /// the given action.
625    /// ## `detailed_action_name`
626    /// a detailed action name, specifying an action
627    ///   and target to obtain accelerators for
628    ///
629    /// # Returns
630    ///
631    ///
632    ///   accelerators for @detailed_action_name
633    #[doc(alias = "gtk_application_get_accels_for_action")]
634    #[doc(alias = "get_accels_for_action")]
635    fn accels_for_action(&self, detailed_action_name: &str) -> Vec<glib::GString> {
636        unsafe {
637            FromGlibPtrContainer::from_glib_full(ffi::gtk_application_get_accels_for_action(
638                self.as_ref().to_glib_none().0,
639                detailed_action_name.to_glib_none().0,
640            ))
641        }
642    }
643
644    /// Returns the list of actions (possibly empty) that the accelerator maps to.
645    ///
646    /// Each item in the list is a detailed action name in the usual form.
647    ///
648    /// This might be useful to discover if an accel already exists in
649    /// order to prevent installation of a conflicting accelerator (from
650    /// an accelerator editor or a plugin system, for example). Note that
651    /// having more than one action per accelerator may not be a bad thing
652    /// and might make sense in cases where the actions never appear in the
653    /// same context.
654    ///
655    /// In case there are no actions for a given accelerator, an empty array
656    /// is returned. `NULL` is never returned.
657    ///
658    /// It is a programmer error to pass an invalid accelerator string.
659    ///
660    /// If you are unsure, check it with [`accelerator_parse()`][crate::accelerator_parse()] first.
661    /// ## `accel`
662    /// an accelerator that can be parsed by [`accelerator_parse()`][crate::accelerator_parse()]
663    ///
664    /// # Returns
665    ///
666    /// actions for @accel
667    #[doc(alias = "gtk_application_get_actions_for_accel")]
668    #[doc(alias = "get_actions_for_accel")]
669    fn actions_for_accel(&self, accel: &str) -> Vec<glib::GString> {
670        unsafe {
671            FromGlibPtrContainer::from_glib_full(ffi::gtk_application_get_actions_for_accel(
672                self.as_ref().to_glib_none().0,
673                accel.to_glib_none().0,
674            ))
675        }
676    }
677
678    /// Gets the “active” window for the application.
679    ///
680    /// The active window is the one that was most recently focused
681    /// (within the application). This window may not have the focus
682    /// at the moment if another application has it — this is just
683    /// the most recently-focused window within this application.
684    ///
685    /// # Returns
686    ///
687    /// the active window
688    #[doc(alias = "gtk_application_get_active_window")]
689    #[doc(alias = "get_active_window")]
690    #[doc(alias = "active-window")]
691    fn active_window(&self) -> Option<Window> {
692        unsafe {
693            from_glib_none(ffi::gtk_application_get_active_window(
694                self.as_ref().to_glib_none().0,
695            ))
696        }
697    }
698
699    /// Gets a menu from automatically loaded resources.
700    ///
701    /// See [the section on Automatic resources](class.Application.html#automatic-resources)
702    /// for more information.
703    /// ## `id`
704    /// the ID of the menu to look up
705    ///
706    /// # Returns
707    ///
708    /// Gets the menu with the
709    ///   given ID from the automatically loaded resources
710    #[doc(alias = "gtk_application_get_menu_by_id")]
711    #[doc(alias = "get_menu_by_id")]
712    fn menu_by_id(&self, id: &str) -> Option<gio::Menu> {
713        unsafe {
714            from_glib_none(ffi::gtk_application_get_menu_by_id(
715                self.as_ref().to_glib_none().0,
716                id.to_glib_none().0,
717            ))
718        }
719    }
720
721    /// Returns the menu model for the menu bar of the application.
722    ///
723    /// # Returns
724    ///
725    /// the menubar for windows of the application
726    #[doc(alias = "gtk_application_get_menubar")]
727    #[doc(alias = "get_menubar")]
728    fn menubar(&self) -> Option<gio::MenuModel> {
729        unsafe {
730            from_glib_none(ffi::gtk_application_get_menubar(
731                self.as_ref().to_glib_none().0,
732            ))
733        }
734    }
735
736    /// Returns the window with the given ID.
737    ///
738    /// The ID of a [`ApplicationWindow`][crate::ApplicationWindow] can be retrieved with
739    /// [`ApplicationWindowExt::id()`][crate::prelude::ApplicationWindowExt::id()].
740    /// ## `id`
741    /// an identifier number
742    ///
743    /// # Returns
744    ///
745    /// the window for the given ID
746    #[doc(alias = "gtk_application_get_window_by_id")]
747    #[doc(alias = "get_window_by_id")]
748    fn window_by_id(&self, id: u32) -> Option<Window> {
749        unsafe {
750            from_glib_none(ffi::gtk_application_get_window_by_id(
751                self.as_ref().to_glib_none().0,
752                id,
753            ))
754        }
755    }
756
757    /// Gets a list of the window associated with the application.
758    ///
759    /// The list is sorted by most recently focused window, such that the first
760    /// element is the currently focused window. (Useful for choosing a parent
761    /// for a transient window.)
762    ///
763    /// The list that is returned should not be modified in any way. It will
764    /// only remain valid until the next focus change or window creation or
765    /// deletion.
766    ///
767    /// # Returns
768    ///
769    /// the list of windows
770    #[doc(alias = "gtk_application_get_windows")]
771    #[doc(alias = "get_windows")]
772    fn windows(&self) -> Vec<Window> {
773        unsafe {
774            FromGlibPtrContainer::from_glib_none(ffi::gtk_application_get_windows(
775                self.as_ref().to_glib_none().0,
776            ))
777        }
778    }
779
780    /// Informs the session manager that certain types of actions should be
781    /// inhibited.
782    ///
783    /// This is not guaranteed to work on all platforms and for all types of
784    /// actions.
785    ///
786    /// Applications should invoke this method when they begin an operation
787    /// that should not be interrupted, such as creating a CD or DVD. The
788    /// types of actions that may be blocked are specified by the @flags
789    /// parameter. When the application completes the operation it should
790    /// call [`uninhibit()`][Self::uninhibit()] to remove the inhibitor. Note
791    /// that an application can have multiple inhibitors, and all of them must
792    /// be individually removed. Inhibitors are also cleared when the
793    /// application exits.
794    ///
795    /// Applications should not expect that they will always be able to block
796    /// the action. In most cases, users will be given the option to force
797    /// the action to take place.
798    ///
799    /// The @reason message should be short and to the point.
800    ///
801    /// If a window is given, the session manager may point the user to
802    /// this window to find out more about why the action is inhibited.
803    ///
804    /// The cookie that is returned by this function  should be used as an
805    /// argument to [`uninhibit()`][Self::uninhibit()] in order to remove
806    /// the request.
807    /// ## `window`
808    /// a window
809    /// ## `flags`
810    /// what types of actions should be inhibited
811    /// ## `reason`
812    /// a short, human-readable string that explains
813    ///   why these operations are inhibited
814    ///
815    /// # Returns
816    ///
817    /// A non-zero cookie that is used to uniquely identify this, or
818    ///   0 if the platform does not support inhibiting or the request failed
819    ///   for some reason
820    #[doc(alias = "gtk_application_inhibit")]
821    fn inhibit(
822        &self,
823        window: Option<&impl IsA<Window>>,
824        flags: ApplicationInhibitFlags,
825        reason: Option<&str>,
826    ) -> u32 {
827        unsafe {
828            ffi::gtk_application_inhibit(
829                self.as_ref().to_glib_none().0,
830                window.map(|p| p.as_ref()).to_glib_none().0,
831                flags.into_glib(),
832                reason.to_glib_none().0,
833            )
834        }
835    }
836
837    /// Lists the detailed action names which have associated accelerators.
838    ///
839    /// See [`set_accels_for_action()`][Self::set_accels_for_action()].
840    ///
841    /// # Returns
842    ///
843    /// the detailed action names
844    #[doc(alias = "gtk_application_list_action_descriptions")]
845    fn list_action_descriptions(&self) -> Vec<glib::GString> {
846        unsafe {
847            FromGlibPtrContainer::from_glib_full(ffi::gtk_application_list_action_descriptions(
848                self.as_ref().to_glib_none().0,
849            ))
850        }
851    }
852
853    /// Remove a window from the application.
854    ///
855    /// If the window belongs to the application then this call is
856    /// equivalent to setting the [`application`][struct@crate::Window#application]
857    /// property of the window to `NULL`.
858    ///
859    /// The application may stop running as a result of a call to this
860    /// function, if the window was the last window of the application.
861    /// ## `window`
862    /// a window
863    #[doc(alias = "gtk_application_remove_window")]
864    fn remove_window(&self, window: &impl IsA<Window>) {
865        unsafe {
866            ffi::gtk_application_remove_window(
867                self.as_ref().to_glib_none().0,
868                window.as_ref().to_glib_none().0,
869            );
870        }
871    }
872
873    /// Saves the state of application.
874    ///
875    /// See [`forget()`][Self::forget()] for a way to forget the state.
876    ///
877    /// If [`register-session`][struct@crate::Application#register-session] is set, [`Application`][crate::Application]
878    /// calls this function automatically when the application is closed or
879    /// the session ends.
880    #[cfg(feature = "v4_22")]
881    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
882    #[doc(alias = "gtk_application_save")]
883    fn save(&self) {
884        unsafe {
885            ffi::gtk_application_save(self.as_ref().to_glib_none().0);
886        }
887    }
888
889    /// Sets zero or more keyboard accelerators that will trigger the
890    /// given action.
891    ///
892    /// The first item in @accels will be the primary accelerator,
893    /// which may be displayed in the UI.
894    ///
895    /// To remove all accelerators for an action, use an empty,
896    /// zero-terminated array for @accels.
897    ///
898    /// For the @detailed_action_name, see [`gio::Action::parse_detailed_name()`][crate::gio::Action::parse_detailed_name()]
899    /// and [Gio.Action.print_detailed_name].
900    /// ## `detailed_action_name`
901    /// a detailed action name, specifying an action
902    ///   and target to associate accelerators with
903    /// ## `accels`
904    /// a list of accelerators in the format
905    ///   understood by [`accelerator_parse()`][crate::accelerator_parse()]
906    #[doc(alias = "gtk_application_set_accels_for_action")]
907    fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]) {
908        unsafe {
909            ffi::gtk_application_set_accels_for_action(
910                self.as_ref().to_glib_none().0,
911                detailed_action_name.to_glib_none().0,
912                accels.to_glib_none().0,
913            );
914        }
915    }
916
917    /// Sets or unsets the menubar for windows of the application.
918    ///
919    /// This is a menubar in the traditional sense.
920    ///
921    /// This can only be done in the primary instance of the application,
922    /// after it has been registered. `vfunc::GIO::Application::startup` is
923    /// a good place to call this.
924    ///
925    /// Depending on the desktop environment, this may appear at the top of
926    /// each window, or at the top of the screen. In some environments, if
927    /// both the application menu and the menubar are set, the application
928    /// menu will be presented as if it were the first item of the menubar.
929    /// Other environments treat the two as completely separate — for example,
930    /// the application menu may be rendered by the desktop shell while the
931    /// menubar (if set) remains in each individual window.
932    ///
933    /// Use the base `GActionMap` interface to add actions, to respond to the
934    /// user selecting these menu items.
935    /// ## `menubar`
936    /// a menu model
937    #[doc(alias = "gtk_application_set_menubar")]
938    #[doc(alias = "menubar")]
939    fn set_menubar(&self, menubar: Option<&impl IsA<gio::MenuModel>>) {
940        unsafe {
941            ffi::gtk_application_set_menubar(
942                self.as_ref().to_glib_none().0,
943                menubar.map(|p| p.as_ref()).to_glib_none().0,
944            );
945        }
946    }
947
948    /// Removes an inhibitor that has been previously established.
949    ///
950    /// See [`inhibit()`][Self::inhibit()].
951    ///
952    /// Inhibitors are also cleared when the application exits.
953    /// ## `cookie`
954    /// a cookie that was returned by [`inhibit()`][Self::inhibit()]
955    #[doc(alias = "gtk_application_uninhibit")]
956    fn uninhibit(&self, cookie: u32) {
957        unsafe {
958            ffi::gtk_application_uninhibit(self.as_ref().to_glib_none().0, cookie);
959        }
960    }
961
962    /// The number of seconds between automatic state saves. Defaults to 15.
963    /// A value of 0 will opt out of automatic state saving.
964    #[cfg(feature = "v4_22")]
965    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
966    #[doc(alias = "autosave-interval")]
967    fn autosave_interval(&self) -> u32 {
968        ObjectExt::property(self.as_ref(), "autosave-interval")
969    }
970
971    /// The number of seconds between automatic state saves. Defaults to 15.
972    /// A value of 0 will opt out of automatic state saving.
973    #[cfg(feature = "v4_22")]
974    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
975    #[doc(alias = "autosave-interval")]
976    fn set_autosave_interval(&self, autosave_interval: u32) {
977        ObjectExt::set_property(self.as_ref(), "autosave-interval", autosave_interval)
978    }
979
980    /// Set this property to true to register with the session manager.
981    ///
982    /// This will make GTK track the session state (such as the
983    /// [`screensaver-active`][struct@crate::Application#screensaver-active] property).
984    ///
985    /// # Deprecated since 4.22
986    ///
987    /// This property is ignored. GTK always registers
988    /// with the session manager
989    #[cfg_attr(feature = "v4_22", deprecated = "Since 4.22")]
990    #[doc(alias = "register-session")]
991    fn is_register_session(&self) -> bool {
992        ObjectExt::property(self.as_ref(), "register-session")
993    }
994
995    /// Set this property to true to register with the session manager.
996    ///
997    /// This will make GTK track the session state (such as the
998    /// [`screensaver-active`][struct@crate::Application#screensaver-active] property).
999    ///
1000    /// # Deprecated since 4.22
1001    ///
1002    /// This property is ignored. GTK always registers
1003    /// with the session manager
1004    #[cfg_attr(feature = "v4_22", deprecated = "Since 4.22")]
1005    #[doc(alias = "register-session")]
1006    fn set_register_session(&self, register_session: bool) {
1007        ObjectExt::set_property(self.as_ref(), "register-session", register_session)
1008    }
1009
1010    /// This property is true if GTK believes that the screensaver
1011    /// is currently active.
1012    ///
1013    /// Tracking the screensaver state is currently only supported on
1014    /// Linux.
1015    #[doc(alias = "screensaver-active")]
1016    fn is_screensaver_active(&self) -> bool {
1017        ObjectExt::property(self.as_ref(), "screensaver-active")
1018    }
1019
1020    /// Set this property to true if the application supports
1021    /// state saving and restoring.
1022    #[cfg(feature = "v4_22")]
1023    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1024    #[doc(alias = "support-save")]
1025    fn supports_save(&self) -> bool {
1026        ObjectExt::property(self.as_ref(), "support-save")
1027    }
1028
1029    /// Set this property to true if the application supports
1030    /// state saving and restoring.
1031    #[cfg(feature = "v4_22")]
1032    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1033    #[doc(alias = "support-save")]
1034    fn set_support_save(&self, support_save: bool) {
1035        ObjectExt::set_property(self.as_ref(), "support-save", support_save)
1036    }
1037
1038    /// Emitted when the session manager is about to end the session.
1039    ///
1040    /// Applications can connect to this signal and call
1041    /// [`inhibit()`][Self::inhibit()] with [flags@Gtk.ApplicationInhibitFlags.logout]
1042    /// to delay the end of the session until state has been saved.
1043    #[doc(alias = "query-end")]
1044    fn connect_query_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1045        unsafe extern "C" fn query_end_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1046            this: *mut ffi::GtkApplication,
1047            f: glib::ffi::gpointer,
1048        ) {
1049            unsafe {
1050                let f: &F = &*(f as *const F);
1051                f(Application::from_glib_borrow(this).unsafe_cast_ref())
1052            }
1053        }
1054        unsafe {
1055            let f: Box_<F> = Box_::new(f);
1056            connect_raw(
1057                self.as_ptr() as *mut _,
1058                c"query-end".as_ptr() as *const _,
1059                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1060                    query_end_trampoline::<Self, F> as *const (),
1061                )),
1062                Box_::into_raw(f),
1063            )
1064        }
1065    }
1066
1067    /// Emitted when application global state is restored.
1068    ///
1069    /// The handler for this signal should do the opposite of what the
1070    /// corresponding handler for [`save-state`][struct@crate::Application#save-state]
1071    /// does.
1072    /// ## `reason`
1073    /// the reason for restoring state
1074    /// ## `state`
1075    /// an "a{sv}" `GVariant` with state to restore
1076    ///
1077    /// # Returns
1078    ///
1079    /// true to stop stop further handlers from running
1080    #[cfg(feature = "v4_22")]
1081    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1082    #[doc(alias = "restore-state")]
1083    fn connect_restore_state<F: Fn(&Self, RestoreReason, &glib::Variant) -> bool + 'static>(
1084        &self,
1085        f: F,
1086    ) -> SignalHandlerId {
1087        unsafe extern "C" fn restore_state_trampoline<
1088            P: IsA<Application>,
1089            F: Fn(&P, RestoreReason, &glib::Variant) -> bool + 'static,
1090        >(
1091            this: *mut ffi::GtkApplication,
1092            reason: ffi::GtkRestoreReason,
1093            state: *mut glib::ffi::GVariant,
1094            f: glib::ffi::gpointer,
1095        ) -> glib::ffi::gboolean {
1096            unsafe {
1097                let f: &F = &*(f as *const F);
1098                f(
1099                    Application::from_glib_borrow(this).unsafe_cast_ref(),
1100                    from_glib(reason),
1101                    &from_glib_borrow(state),
1102                )
1103                .into_glib()
1104            }
1105        }
1106        unsafe {
1107            let f: Box_<F> = Box_::new(f);
1108            connect_raw(
1109                self.as_ptr() as *mut _,
1110                c"restore-state".as_ptr() as *const _,
1111                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1112                    restore_state_trampoline::<Self, F> as *const (),
1113                )),
1114                Box_::into_raw(f),
1115            )
1116        }
1117    }
1118
1119    /// Emitted when an application's per-window state is restored.
1120    ///
1121    /// In response to this signal, you should create a new application
1122    /// window, add it to @application, apply the provided @state, and present it.
1123    /// The application can use the @reason to determine how much of the state
1124    /// should be restored.
1125    ///
1126    /// You must be careful to be robust in the face of app upgrades and downgrades:
1127    /// the @state might have been created by a previous or occasionally even a future
1128    /// version of your app. Do not assume that a given key exists in the state.
1129    /// Apps must try to restore state saved by a previous version, but are free to
1130    /// discard state if it was written by a future version.
1131    ///
1132    /// GTK will remember which window the user was using most recently, and will
1133    /// emit this signal for that window first. Thus, if you decide that the provided
1134    /// @reason means that only one window should be restored, you can reliably
1135    /// ignore emissions if a window already exists
1136    ///
1137    /// Note that this signal is not emitted only during the app's initial launch.
1138    /// If all windows are closed but the app keeps running, the signal will be
1139    /// emitted the next time a new window is opened.
1140    /// ## `reason`
1141    /// the reason this window is restored
1142    /// ## `state`
1143    /// an "a{sv}" `GVariant` with state to restore, as saved by a [`save-state`][struct@crate::ApplicationWindow#save-state] handler
1144    #[cfg(feature = "v4_22")]
1145    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1146    #[doc(alias = "restore-window")]
1147    fn connect_restore_window<F: Fn(&Self, RestoreReason, &glib::Variant) + 'static>(
1148        &self,
1149        f: F,
1150    ) -> SignalHandlerId {
1151        unsafe extern "C" fn restore_window_trampoline<
1152            P: IsA<Application>,
1153            F: Fn(&P, RestoreReason, &glib::Variant) + 'static,
1154        >(
1155            this: *mut ffi::GtkApplication,
1156            reason: ffi::GtkRestoreReason,
1157            state: *mut glib::ffi::GVariant,
1158            f: glib::ffi::gpointer,
1159        ) {
1160            unsafe {
1161                let f: &F = &*(f as *const F);
1162                f(
1163                    Application::from_glib_borrow(this).unsafe_cast_ref(),
1164                    from_glib(reason),
1165                    &from_glib_borrow(state),
1166                )
1167            }
1168        }
1169        unsafe {
1170            let f: Box_<F> = Box_::new(f);
1171            connect_raw(
1172                self.as_ptr() as *mut _,
1173                c"restore-window".as_ptr() as *const _,
1174                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1175                    restore_window_trampoline::<Self, F> as *const (),
1176                )),
1177                Box_::into_raw(f),
1178            )
1179        }
1180    }
1181
1182    /// Emitted when the application is saving global state.
1183    ///
1184    /// The handler for this signal should persist any
1185    /// global state of @application into @dict.
1186    ///
1187    /// See [`restore-state`][struct@crate::Application#restore-state] for how to
1188    /// restore global state, and [`save-state`][struct@crate::ApplicationWindow#save-state]
1189    /// and [`restore-window`][struct@crate::Application#restore-window] for handling
1190    /// per-window state.
1191    /// ## `dict`
1192    /// a `GVariantDict`
1193    ///
1194    /// # Returns
1195    ///
1196    /// true to stop stop further handlers from running
1197    #[cfg(feature = "v4_22")]
1198    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1199    #[doc(alias = "save-state")]
1200    fn connect_save_state<F: Fn(&Self, &glib::VariantDict) -> bool + 'static>(
1201        &self,
1202        f: F,
1203    ) -> SignalHandlerId {
1204        unsafe extern "C" fn save_state_trampoline<
1205            P: IsA<Application>,
1206            F: Fn(&P, &glib::VariantDict) -> bool + 'static,
1207        >(
1208            this: *mut ffi::GtkApplication,
1209            dict: *mut glib::ffi::GVariantDict,
1210            f: glib::ffi::gpointer,
1211        ) -> glib::ffi::gboolean {
1212            unsafe {
1213                let f: &F = &*(f as *const F);
1214                f(
1215                    Application::from_glib_borrow(this).unsafe_cast_ref(),
1216                    &from_glib_borrow(dict),
1217                )
1218                .into_glib()
1219            }
1220        }
1221        unsafe {
1222            let f: Box_<F> = Box_::new(f);
1223            connect_raw(
1224                self.as_ptr() as *mut _,
1225                c"save-state".as_ptr() as *const _,
1226                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1227                    save_state_trampoline::<Self, F> as *const (),
1228                )),
1229                Box_::into_raw(f),
1230            )
1231        }
1232    }
1233
1234    /// Emitted when a window is added to an application.
1235    ///
1236    /// See [`add_window()`][Self::add_window()].
1237    /// ## `window`
1238    /// the newly-added window
1239    #[doc(alias = "window-added")]
1240    fn connect_window_added<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId {
1241        unsafe extern "C" fn window_added_trampoline<
1242            P: IsA<Application>,
1243            F: Fn(&P, &Window) + 'static,
1244        >(
1245            this: *mut ffi::GtkApplication,
1246            window: *mut ffi::GtkWindow,
1247            f: glib::ffi::gpointer,
1248        ) {
1249            unsafe {
1250                let f: &F = &*(f as *const F);
1251                f(
1252                    Application::from_glib_borrow(this).unsafe_cast_ref(),
1253                    &from_glib_borrow(window),
1254                )
1255            }
1256        }
1257        unsafe {
1258            let f: Box_<F> = Box_::new(f);
1259            connect_raw(
1260                self.as_ptr() as *mut _,
1261                c"window-added".as_ptr() as *const _,
1262                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1263                    window_added_trampoline::<Self, F> as *const (),
1264                )),
1265                Box_::into_raw(f),
1266            )
1267        }
1268    }
1269
1270    /// Emitted when a window is removed from an application.
1271    ///
1272    /// This can happen as a side-effect of the window being destroyed
1273    /// or explicitly through [`remove_window()`][Self::remove_window()].
1274    /// ## `window`
1275    /// the window that is being removed
1276    #[doc(alias = "window-removed")]
1277    fn connect_window_removed<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId {
1278        unsafe extern "C" fn window_removed_trampoline<
1279            P: IsA<Application>,
1280            F: Fn(&P, &Window) + 'static,
1281        >(
1282            this: *mut ffi::GtkApplication,
1283            window: *mut ffi::GtkWindow,
1284            f: glib::ffi::gpointer,
1285        ) {
1286            unsafe {
1287                let f: &F = &*(f as *const F);
1288                f(
1289                    Application::from_glib_borrow(this).unsafe_cast_ref(),
1290                    &from_glib_borrow(window),
1291                )
1292            }
1293        }
1294        unsafe {
1295            let f: Box_<F> = Box_::new(f);
1296            connect_raw(
1297                self.as_ptr() as *mut _,
1298                c"window-removed".as_ptr() as *const _,
1299                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1300                    window_removed_trampoline::<Self, F> as *const (),
1301                )),
1302                Box_::into_raw(f),
1303            )
1304        }
1305    }
1306
1307    #[doc(alias = "active-window")]
1308    fn connect_active_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1309        unsafe extern "C" fn notify_active_window_trampoline<
1310            P: IsA<Application>,
1311            F: Fn(&P) + 'static,
1312        >(
1313            this: *mut ffi::GtkApplication,
1314            _param_spec: glib::ffi::gpointer,
1315            f: glib::ffi::gpointer,
1316        ) {
1317            unsafe {
1318                let f: &F = &*(f as *const F);
1319                f(Application::from_glib_borrow(this).unsafe_cast_ref())
1320            }
1321        }
1322        unsafe {
1323            let f: Box_<F> = Box_::new(f);
1324            connect_raw(
1325                self.as_ptr() as *mut _,
1326                c"notify::active-window".as_ptr() as *const _,
1327                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1328                    notify_active_window_trampoline::<Self, F> as *const (),
1329                )),
1330                Box_::into_raw(f),
1331            )
1332        }
1333    }
1334
1335    #[cfg(feature = "v4_22")]
1336    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1337    #[doc(alias = "autosave-interval")]
1338    fn connect_autosave_interval_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1339        unsafe extern "C" fn notify_autosave_interval_trampoline<
1340            P: IsA<Application>,
1341            F: Fn(&P) + 'static,
1342        >(
1343            this: *mut ffi::GtkApplication,
1344            _param_spec: glib::ffi::gpointer,
1345            f: glib::ffi::gpointer,
1346        ) {
1347            unsafe {
1348                let f: &F = &*(f as *const F);
1349                f(Application::from_glib_borrow(this).unsafe_cast_ref())
1350            }
1351        }
1352        unsafe {
1353            let f: Box_<F> = Box_::new(f);
1354            connect_raw(
1355                self.as_ptr() as *mut _,
1356                c"notify::autosave-interval".as_ptr() as *const _,
1357                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1358                    notify_autosave_interval_trampoline::<Self, F> as *const (),
1359                )),
1360                Box_::into_raw(f),
1361            )
1362        }
1363    }
1364
1365    #[doc(alias = "menubar")]
1366    fn connect_menubar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1367        unsafe extern "C" fn notify_menubar_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1368            this: *mut ffi::GtkApplication,
1369            _param_spec: glib::ffi::gpointer,
1370            f: glib::ffi::gpointer,
1371        ) {
1372            unsafe {
1373                let f: &F = &*(f as *const F);
1374                f(Application::from_glib_borrow(this).unsafe_cast_ref())
1375            }
1376        }
1377        unsafe {
1378            let f: Box_<F> = Box_::new(f);
1379            connect_raw(
1380                self.as_ptr() as *mut _,
1381                c"notify::menubar".as_ptr() as *const _,
1382                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1383                    notify_menubar_trampoline::<Self, F> as *const (),
1384                )),
1385                Box_::into_raw(f),
1386            )
1387        }
1388    }
1389
1390    #[cfg_attr(feature = "v4_22", deprecated = "Since 4.22")]
1391    #[doc(alias = "register-session")]
1392    fn connect_register_session_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1393        unsafe extern "C" fn notify_register_session_trampoline<
1394            P: IsA<Application>,
1395            F: Fn(&P) + 'static,
1396        >(
1397            this: *mut ffi::GtkApplication,
1398            _param_spec: glib::ffi::gpointer,
1399            f: glib::ffi::gpointer,
1400        ) {
1401            unsafe {
1402                let f: &F = &*(f as *const F);
1403                f(Application::from_glib_borrow(this).unsafe_cast_ref())
1404            }
1405        }
1406        unsafe {
1407            let f: Box_<F> = Box_::new(f);
1408            connect_raw(
1409                self.as_ptr() as *mut _,
1410                c"notify::register-session".as_ptr() as *const _,
1411                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1412                    notify_register_session_trampoline::<Self, F> as *const (),
1413                )),
1414                Box_::into_raw(f),
1415            )
1416        }
1417    }
1418
1419    #[doc(alias = "screensaver-active")]
1420    fn connect_screensaver_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1421        unsafe extern "C" fn notify_screensaver_active_trampoline<
1422            P: IsA<Application>,
1423            F: Fn(&P) + 'static,
1424        >(
1425            this: *mut ffi::GtkApplication,
1426            _param_spec: glib::ffi::gpointer,
1427            f: glib::ffi::gpointer,
1428        ) {
1429            unsafe {
1430                let f: &F = &*(f as *const F);
1431                f(Application::from_glib_borrow(this).unsafe_cast_ref())
1432            }
1433        }
1434        unsafe {
1435            let f: Box_<F> = Box_::new(f);
1436            connect_raw(
1437                self.as_ptr() as *mut _,
1438                c"notify::screensaver-active".as_ptr() as *const _,
1439                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1440                    notify_screensaver_active_trampoline::<Self, F> as *const (),
1441                )),
1442                Box_::into_raw(f),
1443            )
1444        }
1445    }
1446
1447    #[cfg(feature = "v4_22")]
1448    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1449    #[doc(alias = "support-save")]
1450    fn connect_support_save_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1451        unsafe extern "C" fn notify_support_save_trampoline<
1452            P: IsA<Application>,
1453            F: Fn(&P) + 'static,
1454        >(
1455            this: *mut ffi::GtkApplication,
1456            _param_spec: glib::ffi::gpointer,
1457            f: glib::ffi::gpointer,
1458        ) {
1459            unsafe {
1460                let f: &F = &*(f as *const F);
1461                f(Application::from_glib_borrow(this).unsafe_cast_ref())
1462            }
1463        }
1464        unsafe {
1465            let f: Box_<F> = Box_::new(f);
1466            connect_raw(
1467                self.as_ptr() as *mut _,
1468                c"notify::support-save".as_ptr() as *const _,
1469                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1470                    notify_support_save_trampoline::<Self, F> as *const (),
1471                )),
1472                Box_::into_raw(f),
1473            )
1474        }
1475    }
1476}
1477
1478impl<O: IsA<Application>> GtkApplicationExt for O {}