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