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