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::{ffi, ApplicationInhibitFlags, Window};
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    /// 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            let f: &F = &*(f as *const F);
1050            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1051        }
1052        unsafe {
1053            let f: Box_<F> = Box_::new(f);
1054            connect_raw(
1055                self.as_ptr() as *mut _,
1056                c"query-end".as_ptr() as *const _,
1057                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1058                    query_end_trampoline::<Self, F> as *const (),
1059                )),
1060                Box_::into_raw(f),
1061            )
1062        }
1063    }
1064
1065    /// Emitted when application global state is restored.
1066    ///
1067    /// The handler for this signal should do the opposite of what the
1068    /// corresponding handler for [`save-state`][struct@crate::Application#save-state]
1069    /// does.
1070    /// ## `reason`
1071    /// the reason for restoring state
1072    /// ## `state`
1073    /// an "a{sv}" `GVariant` with state to restore
1074    ///
1075    /// # Returns
1076    ///
1077    /// true to stop stop further handlers from running
1078    #[cfg(feature = "v4_22")]
1079    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1080    #[doc(alias = "restore-state")]
1081    fn connect_restore_state<F: Fn(&Self, RestoreReason, &glib::Variant) -> bool + 'static>(
1082        &self,
1083        f: F,
1084    ) -> SignalHandlerId {
1085        unsafe extern "C" fn restore_state_trampoline<
1086            P: IsA<Application>,
1087            F: Fn(&P, RestoreReason, &glib::Variant) -> bool + 'static,
1088        >(
1089            this: *mut ffi::GtkApplication,
1090            reason: ffi::GtkRestoreReason,
1091            state: *mut glib::ffi::GVariant,
1092            f: glib::ffi::gpointer,
1093        ) -> glib::ffi::gboolean {
1094            let f: &F = &*(f as *const F);
1095            f(
1096                Application::from_glib_borrow(this).unsafe_cast_ref(),
1097                from_glib(reason),
1098                &from_glib_borrow(state),
1099            )
1100            .into_glib()
1101        }
1102        unsafe {
1103            let f: Box_<F> = Box_::new(f);
1104            connect_raw(
1105                self.as_ptr() as *mut _,
1106                c"restore-state".as_ptr() as *const _,
1107                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1108                    restore_state_trampoline::<Self, F> as *const (),
1109                )),
1110                Box_::into_raw(f),
1111            )
1112        }
1113    }
1114
1115    /// Emitted when an application's per-window state is restored.
1116    ///
1117    /// In response to this signal, you should create a new application
1118    /// window, add it to @application, apply the provided @state, and present it.
1119    /// The application can use the @reason to determine how much of the state
1120    /// should be restored.
1121    ///
1122    /// You must be careful to be robust in the face of app upgrades and downgrades:
1123    /// the @state might have been created by a previous or occasionally even a future
1124    /// version of your app. Do not assume that a given key exists in the state.
1125    /// Apps must try to restore state saved by a previous version, but are free to
1126    /// discard state if it was written by a future version.
1127    ///
1128    /// GTK will remember which window the user was using most recently, and will
1129    /// emit this signal for that window first. Thus, if you decide that the provided
1130    /// @reason means that only one window should be restored, you can reliably
1131    /// ignore emissions if a window already exists
1132    ///
1133    /// Note that this signal is not emitted only during the app's initial launch.
1134    /// If all windows are closed but the app keeps running, the signal will be
1135    /// emitted the next time a new window is opened.
1136    /// ## `reason`
1137    /// the reason this window is restored
1138    /// ## `state`
1139    /// an "a{sv}" `GVariant` with state to restore, as saved by a [`save-state`][struct@crate::ApplicationWindow#save-state] handler
1140    #[cfg(feature = "v4_22")]
1141    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1142    #[doc(alias = "restore-window")]
1143    fn connect_restore_window<F: Fn(&Self, RestoreReason, &glib::Variant) + 'static>(
1144        &self,
1145        f: F,
1146    ) -> SignalHandlerId {
1147        unsafe extern "C" fn restore_window_trampoline<
1148            P: IsA<Application>,
1149            F: Fn(&P, RestoreReason, &glib::Variant) + 'static,
1150        >(
1151            this: *mut ffi::GtkApplication,
1152            reason: ffi::GtkRestoreReason,
1153            state: *mut glib::ffi::GVariant,
1154            f: glib::ffi::gpointer,
1155        ) {
1156            let f: &F = &*(f as *const F);
1157            f(
1158                Application::from_glib_borrow(this).unsafe_cast_ref(),
1159                from_glib(reason),
1160                &from_glib_borrow(state),
1161            )
1162        }
1163        unsafe {
1164            let f: Box_<F> = Box_::new(f);
1165            connect_raw(
1166                self.as_ptr() as *mut _,
1167                c"restore-window".as_ptr() as *const _,
1168                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1169                    restore_window_trampoline::<Self, F> as *const (),
1170                )),
1171                Box_::into_raw(f),
1172            )
1173        }
1174    }
1175
1176    /// Emitted when the application is saving global state.
1177    ///
1178    /// The handler for this signal should persist any
1179    /// global state of @application into @dict.
1180    ///
1181    /// See [`restore-state`][struct@crate::Application#restore-state] for how to
1182    /// restore global state, and [`save-state`][struct@crate::ApplicationWindow#save-state]
1183    /// and [`restore-window`][struct@crate::Application#restore-window] for handling
1184    /// per-window state.
1185    /// ## `dict`
1186    /// a `GVariantDict`
1187    ///
1188    /// # Returns
1189    ///
1190    /// true to stop stop further handlers from running
1191    #[cfg(feature = "v4_22")]
1192    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1193    #[doc(alias = "save-state")]
1194    fn connect_save_state<F: Fn(&Self, &glib::VariantDict) -> bool + 'static>(
1195        &self,
1196        f: F,
1197    ) -> SignalHandlerId {
1198        unsafe extern "C" fn save_state_trampoline<
1199            P: IsA<Application>,
1200            F: Fn(&P, &glib::VariantDict) -> bool + 'static,
1201        >(
1202            this: *mut ffi::GtkApplication,
1203            dict: *mut glib::ffi::GVariantDict,
1204            f: glib::ffi::gpointer,
1205        ) -> glib::ffi::gboolean {
1206            let f: &F = &*(f as *const F);
1207            f(
1208                Application::from_glib_borrow(this).unsafe_cast_ref(),
1209                &from_glib_borrow(dict),
1210            )
1211            .into_glib()
1212        }
1213        unsafe {
1214            let f: Box_<F> = Box_::new(f);
1215            connect_raw(
1216                self.as_ptr() as *mut _,
1217                c"save-state".as_ptr() as *const _,
1218                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1219                    save_state_trampoline::<Self, F> as *const (),
1220                )),
1221                Box_::into_raw(f),
1222            )
1223        }
1224    }
1225
1226    /// Emitted when a window is added to an application.
1227    ///
1228    /// See [`add_window()`][Self::add_window()].
1229    /// ## `window`
1230    /// the newly-added window
1231    #[doc(alias = "window-added")]
1232    fn connect_window_added<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId {
1233        unsafe extern "C" fn window_added_trampoline<
1234            P: IsA<Application>,
1235            F: Fn(&P, &Window) + 'static,
1236        >(
1237            this: *mut ffi::GtkApplication,
1238            window: *mut ffi::GtkWindow,
1239            f: glib::ffi::gpointer,
1240        ) {
1241            let f: &F = &*(f as *const F);
1242            f(
1243                Application::from_glib_borrow(this).unsafe_cast_ref(),
1244                &from_glib_borrow(window),
1245            )
1246        }
1247        unsafe {
1248            let f: Box_<F> = Box_::new(f);
1249            connect_raw(
1250                self.as_ptr() as *mut _,
1251                c"window-added".as_ptr() as *const _,
1252                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1253                    window_added_trampoline::<Self, F> as *const (),
1254                )),
1255                Box_::into_raw(f),
1256            )
1257        }
1258    }
1259
1260    /// Emitted when a window is removed from an application.
1261    ///
1262    /// This can happen as a side-effect of the window being destroyed
1263    /// or explicitly through [`remove_window()`][Self::remove_window()].
1264    /// ## `window`
1265    /// the window that is being removed
1266    #[doc(alias = "window-removed")]
1267    fn connect_window_removed<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId {
1268        unsafe extern "C" fn window_removed_trampoline<
1269            P: IsA<Application>,
1270            F: Fn(&P, &Window) + 'static,
1271        >(
1272            this: *mut ffi::GtkApplication,
1273            window: *mut ffi::GtkWindow,
1274            f: glib::ffi::gpointer,
1275        ) {
1276            let f: &F = &*(f as *const F);
1277            f(
1278                Application::from_glib_borrow(this).unsafe_cast_ref(),
1279                &from_glib_borrow(window),
1280            )
1281        }
1282        unsafe {
1283            let f: Box_<F> = Box_::new(f);
1284            connect_raw(
1285                self.as_ptr() as *mut _,
1286                c"window-removed".as_ptr() as *const _,
1287                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1288                    window_removed_trampoline::<Self, F> as *const (),
1289                )),
1290                Box_::into_raw(f),
1291            )
1292        }
1293    }
1294
1295    #[doc(alias = "active-window")]
1296    fn connect_active_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1297        unsafe extern "C" fn notify_active_window_trampoline<
1298            P: IsA<Application>,
1299            F: Fn(&P) + 'static,
1300        >(
1301            this: *mut ffi::GtkApplication,
1302            _param_spec: glib::ffi::gpointer,
1303            f: glib::ffi::gpointer,
1304        ) {
1305            let f: &F = &*(f as *const F);
1306            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1307        }
1308        unsafe {
1309            let f: Box_<F> = Box_::new(f);
1310            connect_raw(
1311                self.as_ptr() as *mut _,
1312                c"notify::active-window".as_ptr() as *const _,
1313                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1314                    notify_active_window_trampoline::<Self, F> as *const (),
1315                )),
1316                Box_::into_raw(f),
1317            )
1318        }
1319    }
1320
1321    #[cfg(feature = "v4_22")]
1322    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1323    #[doc(alias = "autosave-interval")]
1324    fn connect_autosave_interval_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1325        unsafe extern "C" fn notify_autosave_interval_trampoline<
1326            P: IsA<Application>,
1327            F: Fn(&P) + 'static,
1328        >(
1329            this: *mut ffi::GtkApplication,
1330            _param_spec: glib::ffi::gpointer,
1331            f: glib::ffi::gpointer,
1332        ) {
1333            let f: &F = &*(f as *const F);
1334            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1335        }
1336        unsafe {
1337            let f: Box_<F> = Box_::new(f);
1338            connect_raw(
1339                self.as_ptr() as *mut _,
1340                c"notify::autosave-interval".as_ptr() as *const _,
1341                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1342                    notify_autosave_interval_trampoline::<Self, F> as *const (),
1343                )),
1344                Box_::into_raw(f),
1345            )
1346        }
1347    }
1348
1349    #[doc(alias = "menubar")]
1350    fn connect_menubar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1351        unsafe extern "C" fn notify_menubar_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
1352            this: *mut ffi::GtkApplication,
1353            _param_spec: glib::ffi::gpointer,
1354            f: glib::ffi::gpointer,
1355        ) {
1356            let f: &F = &*(f as *const F);
1357            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1358        }
1359        unsafe {
1360            let f: Box_<F> = Box_::new(f);
1361            connect_raw(
1362                self.as_ptr() as *mut _,
1363                c"notify::menubar".as_ptr() as *const _,
1364                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1365                    notify_menubar_trampoline::<Self, F> as *const (),
1366                )),
1367                Box_::into_raw(f),
1368            )
1369        }
1370    }
1371
1372    #[cfg_attr(feature = "v4_22", deprecated = "Since 4.22")]
1373    #[doc(alias = "register-session")]
1374    fn connect_register_session_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1375        unsafe extern "C" fn notify_register_session_trampoline<
1376            P: IsA<Application>,
1377            F: Fn(&P) + 'static,
1378        >(
1379            this: *mut ffi::GtkApplication,
1380            _param_spec: glib::ffi::gpointer,
1381            f: glib::ffi::gpointer,
1382        ) {
1383            let f: &F = &*(f as *const F);
1384            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1385        }
1386        unsafe {
1387            let f: Box_<F> = Box_::new(f);
1388            connect_raw(
1389                self.as_ptr() as *mut _,
1390                c"notify::register-session".as_ptr() as *const _,
1391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1392                    notify_register_session_trampoline::<Self, F> as *const (),
1393                )),
1394                Box_::into_raw(f),
1395            )
1396        }
1397    }
1398
1399    #[doc(alias = "screensaver-active")]
1400    fn connect_screensaver_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1401        unsafe extern "C" fn notify_screensaver_active_trampoline<
1402            P: IsA<Application>,
1403            F: Fn(&P) + 'static,
1404        >(
1405            this: *mut ffi::GtkApplication,
1406            _param_spec: glib::ffi::gpointer,
1407            f: glib::ffi::gpointer,
1408        ) {
1409            let f: &F = &*(f as *const F);
1410            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1411        }
1412        unsafe {
1413            let f: Box_<F> = Box_::new(f);
1414            connect_raw(
1415                self.as_ptr() as *mut _,
1416                c"notify::screensaver-active".as_ptr() as *const _,
1417                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1418                    notify_screensaver_active_trampoline::<Self, F> as *const (),
1419                )),
1420                Box_::into_raw(f),
1421            )
1422        }
1423    }
1424
1425    #[cfg(feature = "v4_22")]
1426    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1427    #[doc(alias = "support-save")]
1428    fn connect_support_save_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1429        unsafe extern "C" fn notify_support_save_trampoline<
1430            P: IsA<Application>,
1431            F: Fn(&P) + 'static,
1432        >(
1433            this: *mut ffi::GtkApplication,
1434            _param_spec: glib::ffi::gpointer,
1435            f: glib::ffi::gpointer,
1436        ) {
1437            let f: &F = &*(f as *const F);
1438            f(Application::from_glib_borrow(this).unsafe_cast_ref())
1439        }
1440        unsafe {
1441            let f: Box_<F> = Box_::new(f);
1442            connect_raw(
1443                self.as_ptr() as *mut _,
1444                c"notify::support-save".as_ptr() as *const _,
1445                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1446                    notify_support_save_trampoline::<Self, F> as *const (),
1447                )),
1448                Box_::into_raw(f),
1449            )
1450        }
1451    }
1452}
1453
1454impl<O: IsA<Application>> GtkApplicationExt for O {}