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