1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ActionGroup;
use crate::ActionMap;
use crate::ApplicationCommandLine;
use crate::ApplicationFlags;
use crate::Cancellable;
use crate::DBusConnection;
use crate::File;
use crate::Notification;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
use std::ptr;

glib::wrapper! {
    /// A [`Application`][crate::Application] is the foundation of an application. It wraps some
    /// low-level platform-specific services and is intended to act as the
    /// foundation for higher-level application classes such as
    /// `GtkApplication` or `MxApplication`. In general, you should not use
    /// this class outside of a higher level framework.
    ///
    /// GApplication provides convenient life cycle management by maintaining
    /// a "use count" for the primary application instance. The use count can
    /// be changed using [`ApplicationExtManual::hold()`][crate::prelude::ApplicationExtManual::hold()] and [`ApplicationExtManual::release()`][crate::prelude::ApplicationExtManual::release()]. If
    /// it drops to zero, the application exits. Higher-level classes such as
    /// `GtkApplication` employ the use count to ensure that the application
    /// stays alive as long as it has any opened windows.
    ///
    /// Another feature that GApplication (optionally) provides is process
    /// uniqueness. Applications can make use of this functionality by
    /// providing a unique application ID. If given, only one application
    /// with this ID can be running at a time per session. The session
    /// concept is platform-dependent, but corresponds roughly to a graphical
    /// desktop login. When your application is launched again, its
    /// arguments are passed through platform communication to the already
    /// running program. The already running instance of the program is
    /// called the "primary instance"; for non-unique applications this is
    /// always the current instance. On Linux, the D-Bus session bus
    /// is used for communication.
    ///
    /// The use of [`Application`][crate::Application] differs from some other commonly-used
    /// uniqueness libraries (such as libunique) in important ways. The
    /// application is not expected to manually register itself and check
    /// if it is the primary instance. Instead, the `main()` function of a
    /// [`Application`][crate::Application] should do very little more than instantiating the
    /// application instance, possibly connecting signal handlers, then
    /// calling [`ApplicationExtManual::run()`][crate::prelude::ApplicationExtManual::run()]. All checks for uniqueness are done
    /// internally. If the application is the primary instance then the
    /// startup signal is emitted and the mainloop runs. If the application
    /// is not the primary instance then a signal is sent to the primary
    /// instance and [`ApplicationExtManual::run()`][crate::prelude::ApplicationExtManual::run()] promptly returns. See the code
    /// examples below.
    ///
    /// If used, the expected form of an application identifier is the same as
    /// that of of a
    /// [D-Bus well-known bus name](https://dbus.freedesktop.org/doc/dbus-specification.html`message`-protocol-names-bus).
    /// Examples include: `com.example.MyApp`, `org.example.internal_apps.Calculator`,
    /// `org._7_zip.Archiver`.
    /// For details on valid application identifiers, see [`id_is_valid()`][Self::id_is_valid()].
    ///
    /// On Linux, the application identifier is claimed as a well-known bus name
    /// on the user's session bus. This means that the uniqueness of your
    /// application is scoped to the current session. It also means that your
    /// application may provide additional services (through registration of other
    /// object paths) at that bus name. The registration of these object paths
    /// should be done with the shared GDBus session bus. Note that due to the
    /// internal architecture of GDBus, method calls can be dispatched at any time
    /// (even if a main loop is not running). For this reason, you must ensure that
    /// any object paths that you wish to register are registered before [`Application`][crate::Application]
    /// attempts to acquire the bus name of your application (which happens in
    /// [`ApplicationExt::register()`][crate::prelude::ApplicationExt::register()]). Unfortunately, this means that you cannot use
    /// [`ApplicationExt::is_remote()`][crate::prelude::ApplicationExt::is_remote()] to decide if you want to register object paths.
    ///
    /// GApplication also implements the [`ActionGroup`][crate::ActionGroup] and [`ActionMap`][crate::ActionMap]
    /// interfaces and lets you easily export actions by adding them with
    /// [`ActionMapExt::add_action()`][crate::prelude::ActionMapExt::add_action()]. When invoking an action by calling
    /// [`ActionGroupExt::activate_action()`][crate::prelude::ActionGroupExt::activate_action()] on the application, it is always
    /// invoked in the primary instance. The actions are also exported on
    /// the session bus, and GIO provides the [`DBusActionGroup`][crate::DBusActionGroup] wrapper to
    /// conveniently access them remotely. GIO provides a [`DBusMenuModel`][crate::DBusMenuModel] wrapper
    /// for remote access to exported `GMenuModels`.
    ///
    /// There is a number of different entry points into a GApplication:
    ///
    /// - via 'Activate' (i.e. just starting the application)
    ///
    /// - via 'Open' (i.e. opening some files)
    ///
    /// - by handling a command-line
    ///
    /// - via activating an action
    ///
    /// The `signal::Application::startup` signal lets you handle the application
    /// initialization for all of these in a single place.
    ///
    /// Regardless of which of these entry points is used to start the
    /// application, GApplication passes some ‘platform data’ from the
    /// launching instance to the primary instance, in the form of a
    /// [`glib::Variant`][struct@crate::glib::Variant] dictionary mapping strings to variants. To use platform
    /// data, override the `before_emit` or `after_emit` virtual functions
    /// in your [`Application`][crate::Application] subclass. When dealing with
    /// [`ApplicationCommandLine`][crate::ApplicationCommandLine] objects, the platform data is
    /// directly available via [`ApplicationCommandLineExt::cwd()`][crate::prelude::ApplicationCommandLineExt::cwd()],
    /// [`ApplicationCommandLineExt::environ()`][crate::prelude::ApplicationCommandLineExt::environ()] and
    /// [`ApplicationCommandLineExt::platform_data()`][crate::prelude::ApplicationCommandLineExt::platform_data()].
    ///
    /// As the name indicates, the platform data may vary depending on the
    /// operating system, but it always includes the current directory (key
    /// "cwd"), and optionally the environment (ie the set of environment
    /// variables and their values) of the calling process (key "environ").
    /// The environment is only added to the platform data if the
    /// [`ApplicationFlags::SEND_ENVIRONMENT`][crate::ApplicationFlags::SEND_ENVIRONMENT] flag is set. [`Application`][crate::Application] subclasses
    /// can add their own platform data by overriding the `add_platform_data`
    /// virtual function. For instance, `GtkApplication` adds startup notification
    /// data in this way.
    ///
    /// To parse commandline arguments you may handle the
    /// `signal::Application::command-line` signal or override the `local_command_line()`
    /// vfunc, to parse them in either the primary instance or the local instance,
    /// respectively.
    ///
    /// For an example of opening files with a GApplication, see
    /// [gapplication-example-open.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-open.c).
    ///
    /// For an example of using actions with GApplication, see
    /// [gapplication-example-actions.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-actions.c).
    ///
    /// For an example of using extra D-Bus hooks with GApplication, see
    /// [gapplication-example-dbushooks.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-dbushooks.c).
    ///
    /// # Implements
    ///
    /// [`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]
    #[doc(alias = "GApplication")]
    pub struct Application(Object<ffi::GApplication, ffi::GApplicationClass>) @implements ActionGroup, ActionMap;

    match fn {
        type_ => || ffi::g_application_get_type(),
    }
}

impl Application {
    pub const NONE: Option<&'static Application> = None;

    /// Creates a new [`Application`][crate::Application] instance.
    ///
    /// If non-[`None`], the application id must be valid. See
    /// [`id_is_valid()`][Self::id_is_valid()].
    ///
    /// If no application ID is given then some features of [`Application`][crate::Application]
    /// (most notably application uniqueness) will be disabled.
    /// ## `application_id`
    /// the application id
    /// ## `flags`
    /// the application flags
    ///
    /// # Returns
    ///
    /// a new [`Application`][crate::Application] instance
    #[doc(alias = "g_application_new")]
    pub fn new(application_id: Option<&str>, flags: ApplicationFlags) -> Application {
        unsafe {
            from_glib_full(ffi::g_application_new(
                application_id.to_glib_none().0,
                flags.into_glib(),
            ))
        }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`Application`] objects.
    ///
    /// This method returns an instance of [`ApplicationBuilder`](crate::builders::ApplicationBuilder) which can be used to create [`Application`] objects.
    pub fn builder() -> ApplicationBuilder {
        ApplicationBuilder::default()
    }

    /// Returns the default [`Application`][crate::Application] instance for this process.
    ///
    /// Normally there is only one [`Application`][crate::Application] per process and it becomes
    /// the default when it is created. You can exercise more control over
    /// this by using [`ApplicationExt::set_default()`][crate::prelude::ApplicationExt::set_default()].
    ///
    /// If there is no default application then [`None`] is returned.
    ///
    /// # Returns
    ///
    /// the default application for this process, or [`None`]
    #[doc(alias = "g_application_get_default")]
    #[doc(alias = "get_default")]
    #[allow(clippy::should_implement_trait)]
    pub fn default() -> Option<Application> {
        unsafe { from_glib_none(ffi::g_application_get_default()) }
    }

    /// Checks if `application_id` is a valid application identifier.
    ///
    /// A valid ID is required for calls to [`new()`][Self::new()] and
    /// [`ApplicationExt::set_application_id()`][crate::prelude::ApplicationExt::set_application_id()].
    ///
    /// Application identifiers follow the same format as
    /// [D-Bus well-known bus names](https://dbus.freedesktop.org/doc/dbus-specification.html`message`-protocol-names-bus).
    /// For convenience, the restrictions on application identifiers are
    /// reproduced here:
    ///
    /// - Application identifiers are composed of 1 or more elements separated by a
    ///  period (`.`) character. All elements must contain at least one character.
    ///
    /// - Each element must only contain the ASCII characters `[A-Z][a-z][0-9]_-`,
    ///  with `-` discouraged in new application identifiers. Each element must not
    ///  begin with a digit.
    ///
    /// - Application identifiers must contain at least one `.` (period) character
    ///  (and thus at least two elements).
    ///
    /// - Application identifiers must not begin with a `.` (period) character.
    ///
    /// - Application identifiers must not exceed 255 characters.
    ///
    /// Note that the hyphen (`-`) character is allowed in application identifiers,
    /// but is problematic or not allowed in various specifications and APIs that
    /// refer to D-Bus, such as
    /// [Flatpak application IDs](http://docs.flatpak.org/en/latest/introduction.html`identifiers`),
    /// the
    /// [`DBusActivatable` interface in the Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html`dbus`),
    /// and the convention that an application's "main" interface and object path
    /// resemble its application identifier and bus name. To avoid situations that
    /// require special-case handling, it is recommended that new application
    /// identifiers consistently replace hyphens with underscores.
    ///
    /// Like D-Bus interface names, application identifiers should start with the
    /// reversed DNS domain name of the author of the interface (in lower-case), and
    /// it is conventional for the rest of the application identifier to consist of
    /// words run together, with initial capital letters.
    ///
    /// As with D-Bus interface names, if the author's DNS domain name contains
    /// hyphen/minus characters they should be replaced by underscores, and if it
    /// contains leading digits they should be escaped by prepending an underscore.
    /// For example, if the owner of 7-zip.org used an application identifier for an
    /// archiving application, it might be named `org._7_zip.Archiver`.
    /// ## `application_id`
    /// a potential application identifier
    ///
    /// # Returns
    ///
    /// [`true`] if `application_id` is valid
    #[doc(alias = "g_application_id_is_valid")]
    pub fn id_is_valid(application_id: &str) -> bool {
        unsafe {
            from_glib(ffi::g_application_id_is_valid(
                application_id.to_glib_none().0,
            ))
        }
    }
}

impl Default for Application {
    fn default() -> Self {
        glib::object::Object::new::<Self>(&[])
    }
}

#[derive(Clone, Default)]
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Application`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct ApplicationBuilder {
    action_group: Option<ActionGroup>,
    application_id: Option<String>,
    flags: Option<ApplicationFlags>,
    inactivity_timeout: Option<u32>,
    resource_base_path: Option<String>,
}

impl ApplicationBuilder {
    // rustdoc-stripper-ignore-next
    /// Create a new [`ApplicationBuilder`].
    pub fn new() -> Self {
        Self::default()
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`Application`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> Application {
        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
        if let Some(ref action_group) = self.action_group {
            properties.push(("action-group", action_group));
        }
        if let Some(ref application_id) = self.application_id {
            properties.push(("application-id", application_id));
        }
        if let Some(ref flags) = self.flags {
            properties.push(("flags", flags));
        }
        if let Some(ref inactivity_timeout) = self.inactivity_timeout {
            properties.push(("inactivity-timeout", inactivity_timeout));
        }
        if let Some(ref resource_base_path) = self.resource_base_path {
            properties.push(("resource-base-path", resource_base_path));
        }
        glib::Object::new::<Application>(&properties)
    }

    pub fn action_group(mut self, action_group: &impl IsA<ActionGroup>) -> Self {
        self.action_group = Some(action_group.clone().upcast());
        self
    }

    pub fn application_id(mut self, application_id: &str) -> Self {
        self.application_id = Some(application_id.to_string());
        self
    }

    pub fn flags(mut self, flags: ApplicationFlags) -> Self {
        self.flags = Some(flags);
        self
    }

    pub fn inactivity_timeout(mut self, inactivity_timeout: u32) -> Self {
        self.inactivity_timeout = Some(inactivity_timeout);
        self
    }

    pub fn resource_base_path(mut self, resource_base_path: &str) -> Self {
        self.resource_base_path = Some(resource_base_path.to_string());
        self
    }
}

/// Trait containing all [`struct@Application`] methods.
///
/// # Implementors
///
/// [`Application`][struct@crate::Application]
pub trait ApplicationExt: 'static {
    /// Activates the application.
    ///
    /// In essence, this results in the `signal::Application::activate` signal being
    /// emitted in the primary instance.
    ///
    /// The application must be registered before calling this function.
    #[doc(alias = "g_application_activate")]
    fn activate(&self);

    /// Add an option to be handled by `self`.
    ///
    /// Calling this function is the equivalent of calling
    /// `g_application_add_main_option_entries()` with a single `GOptionEntry`
    /// that has its arg_data member set to [`None`].
    ///
    /// The parsed arguments will be packed into a [`glib::VariantDict`][crate::glib::VariantDict] which
    /// is passed to `signal::Application::handle-local-options`. If
    /// [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] is set, then it will also
    /// be sent to the primary instance. See
    /// `g_application_add_main_option_entries()` for more details.
    ///
    /// See `GOptionEntry` for more documentation of the arguments.
    /// ## `long_name`
    /// the long name of an option used to specify it in a commandline
    /// ## `short_name`
    /// the short name of an option
    /// ## `flags`
    /// flags from [`glib::OptionFlags`][crate::glib::OptionFlags]
    /// ## `arg`
    /// the type of the option, as a [`glib::OptionArg`][crate::glib::OptionArg]
    /// ## `description`
    /// the description for the option in `--help` output
    /// ## `arg_description`
    /// the placeholder to use for the extra argument
    ///  parsed by the option in `--help` output
    #[doc(alias = "g_application_add_main_option")]
    fn add_main_option(
        &self,
        long_name: &str,
        short_name: glib::Char,
        flags: glib::OptionFlags,
        arg: glib::OptionArg,
        description: &str,
        arg_description: Option<&str>,
    );

    //#[doc(alias = "g_application_add_main_option_entries")]
    //fn add_main_option_entries(&self, entries: /*Ignored*/&[glib::OptionEntry]);

    //#[doc(alias = "g_application_add_option_group")]
    //fn add_option_group(&self, group: /*Ignored*/&glib::OptionGroup);

    /// Marks `self` as busy (see [`ApplicationExtManual::mark_busy()`][crate::prelude::ApplicationExtManual::mark_busy()]) while
    /// `property` on `object` is [`true`].
    ///
    /// The binding holds a reference to `self` while it is active, but
    /// not to `object`. Instead, the binding is destroyed when `object` is
    /// finalized.
    /// ## `object`
    /// a [`glib::Object`][crate::glib::Object]
    /// ## `property`
    /// the name of a boolean property of `object`
    #[doc(alias = "g_application_bind_busy_property")]
    fn bind_busy_property(&self, object: &impl IsA<glib::Object>, property: &str);

    /// Gets the unique identifier for `self`.
    ///
    /// # Returns
    ///
    /// the identifier for `self`, owned by `self`
    #[doc(alias = "g_application_get_application_id")]
    #[doc(alias = "get_application_id")]
    fn application_id(&self) -> Option<glib::GString>;

    /// Gets the [`DBusConnection`][crate::DBusConnection] being used by the application, or [`None`].
    ///
    /// If [`Application`][crate::Application] is using its D-Bus backend then this function will
    /// return the [`DBusConnection`][crate::DBusConnection] being used for uniqueness and
    /// communication with the desktop environment and other instances of the
    /// application.
    ///
    /// If [`Application`][crate::Application] is not using D-Bus then this function will return
    /// [`None`]. This includes the situation where the D-Bus backend would
    /// normally be in use but we were unable to connect to the bus.
    ///
    /// This function must not be called before the application has been
    /// registered. See [`is_registered()`][Self::is_registered()].
    ///
    /// # Returns
    ///
    /// a [`DBusConnection`][crate::DBusConnection], or [`None`]
    #[doc(alias = "g_application_get_dbus_connection")]
    #[doc(alias = "get_dbus_connection")]
    fn dbus_connection(&self) -> Option<DBusConnection>;

    /// Gets the D-Bus object path being used by the application, or [`None`].
    ///
    /// If [`Application`][crate::Application] is using its D-Bus backend then this function will
    /// return the D-Bus object path that [`Application`][crate::Application] is using. If the
    /// application is the primary instance then there is an object published
    /// at this path. If the application is not the primary instance then
    /// the result of this function is undefined.
    ///
    /// If [`Application`][crate::Application] is not using D-Bus then this function will return
    /// [`None`]. This includes the situation where the D-Bus backend would
    /// normally be in use but we were unable to connect to the bus.
    ///
    /// This function must not be called before the application has been
    /// registered. See [`is_registered()`][Self::is_registered()].
    ///
    /// # Returns
    ///
    /// the object path, or [`None`]
    #[doc(alias = "g_application_get_dbus_object_path")]
    #[doc(alias = "get_dbus_object_path")]
    fn dbus_object_path(&self) -> Option<glib::GString>;

    /// Gets the flags for `self`.
    ///
    /// See [`ApplicationFlags`][crate::ApplicationFlags].
    ///
    /// # Returns
    ///
    /// the flags for `self`
    #[doc(alias = "g_application_get_flags")]
    #[doc(alias = "get_flags")]
    fn flags(&self) -> ApplicationFlags;

    /// Gets the current inactivity timeout for the application.
    ///
    /// This is the amount of time (in milliseconds) after the last call to
    /// [`ApplicationExtManual::release()`][crate::prelude::ApplicationExtManual::release()] before the application stops running.
    ///
    /// # Returns
    ///
    /// the timeout, in milliseconds
    #[doc(alias = "g_application_get_inactivity_timeout")]
    #[doc(alias = "get_inactivity_timeout")]
    fn inactivity_timeout(&self) -> u32;

    /// Gets the application's current busy state, as set through
    /// [`ApplicationExtManual::mark_busy()`][crate::prelude::ApplicationExtManual::mark_busy()] or [`bind_busy_property()`][Self::bind_busy_property()].
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is currently marked as busy
    #[doc(alias = "g_application_get_is_busy")]
    #[doc(alias = "get_is_busy")]
    fn is_busy(&self) -> bool;

    /// Checks if `self` is registered.
    ///
    /// An application is registered if [`register()`][Self::register()] has been
    /// successfully called.
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is registered
    #[doc(alias = "g_application_get_is_registered")]
    #[doc(alias = "get_is_registered")]
    fn is_registered(&self) -> bool;

    /// Checks if `self` is remote.
    ///
    /// If `self` is remote then it means that another instance of
    /// application already exists (the 'primary' instance). Calls to
    /// perform actions on `self` will result in the actions being
    /// performed by the primary instance.
    ///
    /// The value of this property cannot be accessed before
    /// [`register()`][Self::register()] has been called. See
    /// [`is_registered()`][Self::is_registered()].
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is remote
    #[doc(alias = "g_application_get_is_remote")]
    #[doc(alias = "get_is_remote")]
    fn is_remote(&self) -> bool;

    /// Gets the resource base path of `self`.
    ///
    /// See [`set_resource_base_path()`][Self::set_resource_base_path()] for more information.
    ///
    /// # Returns
    ///
    /// the base resource path, if one is set
    #[doc(alias = "g_application_get_resource_base_path")]
    #[doc(alias = "get_resource_base_path")]
    fn resource_base_path(&self) -> Option<glib::GString>;

    /// Opens the given files.
    ///
    /// In essence, this results in the `signal::Application::open` signal being emitted
    /// in the primary instance.
    ///
    /// `n_files` must be greater than zero.
    ///
    /// `hint` is simply passed through to the ::open signal. It is
    /// intended to be used by applications that have multiple modes for
    /// opening files (eg: "view" vs "edit", etc). Unless you have a need
    /// for this functionality, you should use "".
    ///
    /// The application must be registered before calling this function
    /// and it must have the [`ApplicationFlags::HANDLES_OPEN`][crate::ApplicationFlags::HANDLES_OPEN] flag set.
    /// ## `files`
    /// an array of `GFiles` to open
    /// ## `hint`
    /// a hint (or ""), but never [`None`]
    #[doc(alias = "g_application_open")]
    fn open(&self, files: &[File], hint: &str);

    /// Immediately quits the application.
    ///
    /// Upon return to the mainloop, [`ApplicationExtManual::run()`][crate::prelude::ApplicationExtManual::run()] will return,
    /// calling only the 'shutdown' function before doing so.
    ///
    /// The hold count is ignored.
    /// Take care if your code has called [`ApplicationExtManual::hold()`][crate::prelude::ApplicationExtManual::hold()] on the application and
    /// is therefore still expecting it to exist.
    /// (Note that you may have called [`ApplicationExtManual::hold()`][crate::prelude::ApplicationExtManual::hold()] indirectly, for example
    /// through `gtk_application_add_window()`.)
    ///
    /// The result of calling [`ApplicationExtManual::run()`][crate::prelude::ApplicationExtManual::run()] again after it returns is
    /// unspecified.
    #[doc(alias = "g_application_quit")]
    fn quit(&self);

    /// Attempts registration of the application.
    ///
    /// This is the point at which the application discovers if it is the
    /// primary instance or merely acting as a remote for an already-existing
    /// primary instance. This is implemented by attempting to acquire the
    /// application identifier as a unique bus name on the session bus using
    /// GDBus.
    ///
    /// If there is no application ID or if [`ApplicationFlags::NON_UNIQUE`][crate::ApplicationFlags::NON_UNIQUE] was
    /// given, then this process will always become the primary instance.
    ///
    /// Due to the internal architecture of GDBus, method calls can be
    /// dispatched at any time (even if a main loop is not running). For
    /// this reason, you must ensure that any object paths that you wish to
    /// register are registered before calling this function.
    ///
    /// If the application has already been registered then [`true`] is
    /// returned with no work performed.
    ///
    /// The `signal::Application::startup` signal is emitted if registration succeeds
    /// and `self` is the primary instance (including the non-unique
    /// case).
    ///
    /// In the event of an error (such as `cancellable` being cancelled, or a
    /// failure to connect to the session bus), [`false`] is returned and `error`
    /// is set appropriately.
    ///
    /// Note: the return value of this function is not an indicator that this
    /// instance is or is not the primary instance of the application. See
    /// [`is_remote()`][Self::is_remote()] for that.
    /// ## `cancellable`
    /// a [`Cancellable`][crate::Cancellable], or [`None`]
    ///
    /// # Returns
    ///
    /// [`true`] if registration succeeded
    #[doc(alias = "g_application_register")]
    fn register(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), glib::Error>;

    /// Sends a notification on behalf of `self` to the desktop shell.
    /// There is no guarantee that the notification is displayed immediately,
    /// or even at all.
    ///
    /// Notifications may persist after the application exits. It will be
    /// D-Bus-activated when the notification or one of its actions is
    /// activated.
    ///
    /// Modifying `notification` after this call has no effect. However, the
    /// object can be reused for a later call to this function.
    ///
    /// `id` may be any string that uniquely identifies the event for the
    /// application. It does not need to be in any special format. For
    /// example, "new-message" might be appropriate for a notification about
    /// new messages.
    ///
    /// If a previous notification was sent with the same `id`, it will be
    /// replaced with `notification` and shown again as if it was a new
    /// notification. This works even for notifications sent from a previous
    /// execution of the application, as long as `id` is the same string.
    ///
    /// `id` may be [`None`], but it is impossible to replace or withdraw
    /// notifications without an id.
    ///
    /// If `notification` is no longer relevant, it can be withdrawn with
    /// [`withdraw_notification()`][Self::withdraw_notification()].
    /// ## `id`
    /// id of the notification, or [`None`]
    /// ## `notification`
    /// the [`Notification`][crate::Notification] to send
    #[doc(alias = "g_application_send_notification")]
    fn send_notification(&self, id: Option<&str>, notification: &Notification);

    /// Sets the unique identifier for `self`.
    ///
    /// The application id can only be modified if `self` has not yet
    /// been registered.
    ///
    /// If non-[`None`], the application id must be valid. See
    /// [`Application::id_is_valid()`][crate::Application::id_is_valid()].
    /// ## `application_id`
    /// the identifier for `self`
    #[doc(alias = "g_application_set_application_id")]
    fn set_application_id(&self, application_id: Option<&str>);

    /// Sets or unsets the default application for the process, as returned
    /// by [`Application::default()`][crate::Application::default()].
    ///
    /// This function does not take its own reference on `self`. If
    /// `self` is destroyed then the default application will revert
    /// back to [`None`].
    #[doc(alias = "g_application_set_default")]
    fn set_default(&self);

    /// Sets the flags for `self`.
    ///
    /// The flags can only be modified if `self` has not yet been
    /// registered.
    ///
    /// See [`ApplicationFlags`][crate::ApplicationFlags].
    /// ## `flags`
    /// the flags for `self`
    #[doc(alias = "g_application_set_flags")]
    fn set_flags(&self, flags: ApplicationFlags);

    /// Sets the current inactivity timeout for the application.
    ///
    /// This is the amount of time (in milliseconds) after the last call to
    /// [`ApplicationExtManual::release()`][crate::prelude::ApplicationExtManual::release()] before the application stops running.
    ///
    /// This call has no side effects of its own. The value set here is only
    /// used for next time [`ApplicationExtManual::release()`][crate::prelude::ApplicationExtManual::release()] drops the use count to
    /// zero. Any timeouts currently in progress are not impacted.
    /// ## `inactivity_timeout`
    /// the timeout, in milliseconds
    #[doc(alias = "g_application_set_inactivity_timeout")]
    fn set_inactivity_timeout(&self, inactivity_timeout: u32);

    /// Adds a description to the `self` option context.
    ///
    /// See `g_option_context_set_description()` for more information.
    /// ## `description`
    /// a string to be shown in `--help` output
    ///  after the list of options, or [`None`]
    #[doc(alias = "g_application_set_option_context_description")]
    fn set_option_context_description(&self, description: Option<&str>);

    /// Sets the parameter string to be used by the commandline handling of `self`.
    ///
    /// This function registers the argument to be passed to `g_option_context_new()`
    /// when the internal `GOptionContext` of `self` is created.
    ///
    /// See `g_option_context_new()` for more information about `parameter_string`.
    /// ## `parameter_string`
    /// a string which is displayed
    ///  in the first line of `--help` output, after the usage summary `programname [OPTION...]`.
    #[doc(alias = "g_application_set_option_context_parameter_string")]
    fn set_option_context_parameter_string(&self, parameter_string: Option<&str>);

    /// Adds a summary to the `self` option context.
    ///
    /// See `g_option_context_set_summary()` for more information.
    /// ## `summary`
    /// a string to be shown in `--help` output
    ///  before the list of options, or [`None`]
    #[doc(alias = "g_application_set_option_context_summary")]
    fn set_option_context_summary(&self, summary: Option<&str>);

    /// Sets (or unsets) the base resource path of `self`.
    ///
    /// The path is used to automatically load various [application
    /// resources][gresource] such as menu layouts and action descriptions.
    /// The various types of resources will be found at fixed names relative
    /// to the given base path.
    ///
    /// By default, the resource base path is determined from the application
    /// ID by prefixing '/' and replacing each '.' with '/'. This is done at
    /// the time that the [`Application`][crate::Application] object is constructed. Changes to
    /// the application ID after that point will not have an impact on the
    /// resource base path.
    ///
    /// As an example, if the application has an ID of "org.example.app" then
    /// the default resource base path will be "/org/example/app". If this
    /// is a `GtkApplication` (and you have not manually changed the path)
    /// then Gtk will then search for the menus of the application at
    /// "/org/example/app/gtk/menus.ui".
    ///
    /// See [`Resource`][crate::Resource] for more information about adding resources to your
    /// application.
    ///
    /// You can disable automatic resource loading functionality by setting
    /// the path to [`None`].
    ///
    /// Changing the resource base path once the application is running is
    /// not recommended. The point at which the resource path is consulted
    /// for forming paths for various purposes is unspecified. When writing
    /// a sub-class of [`Application`][crate::Application] you should either set the
    /// `property::Application::resource-base-path` property at construction time, or call
    /// this function during the instance initialization. Alternatively, you
    /// can call this function in the `GApplicationClass.startup` virtual function,
    /// before chaining up to the parent implementation.
    /// ## `resource_path`
    /// the resource path to use
    #[doc(alias = "g_application_set_resource_base_path")]
    fn set_resource_base_path(&self, resource_path: Option<&str>);

    /// Destroys a binding between `property` and the busy state of
    /// `self` that was previously created with
    /// [`bind_busy_property()`][Self::bind_busy_property()].
    /// ## `object`
    /// a [`glib::Object`][crate::glib::Object]
    /// ## `property`
    /// the name of a boolean property of `object`
    #[doc(alias = "g_application_unbind_busy_property")]
    fn unbind_busy_property(&self, object: &impl IsA<glib::Object>, property: &str);

    /// Withdraws a notification that was sent with
    /// [`send_notification()`][Self::send_notification()].
    ///
    /// This call does nothing if a notification with `id` doesn't exist or
    /// the notification was never sent.
    ///
    /// This function works even for notifications sent in previous
    /// executions of this application, as long `id` is the same as it was for
    /// the sent notification.
    ///
    /// Note that notifications are dismissed when the user clicks on one
    /// of the buttons in a notification or triggers its default action, so
    /// there is no need to explicitly withdraw the notification in that case.
    /// ## `id`
    /// id of a previously sent notification
    #[doc(alias = "g_application_withdraw_notification")]
    fn withdraw_notification(&self, id: &str);

    #[doc(alias = "action-group")]
    fn set_action_group<P: IsA<ActionGroup>>(&self, action_group: Option<&P>);

    /// The ::activate signal is emitted on the primary instance when an
    /// activation occurs. See [`activate()`][Self::activate()].
    #[doc(alias = "activate")]
    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::command-line signal is emitted on the primary instance when
    /// a commandline is not handled locally. See [`ApplicationExtManual::run()`][crate::prelude::ApplicationExtManual::run()] and
    /// the [`ApplicationCommandLine`][crate::ApplicationCommandLine] documentation for more information.
    /// ## `command_line`
    /// a [`ApplicationCommandLine`][crate::ApplicationCommandLine] representing the
    ///  passed commandline
    ///
    /// # Returns
    ///
    /// An integer that is set as the exit status for the calling
    ///  process. See [`ApplicationCommandLineExt::set_exit_status()`][crate::prelude::ApplicationCommandLineExt::set_exit_status()].
    #[doc(alias = "command-line")]
    fn connect_command_line<F: Fn(&Self, &ApplicationCommandLine) -> i32 + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    /// The ::handle-local-options signal is emitted on the local instance
    /// after the parsing of the commandline options has occurred.
    ///
    /// You can add options to be recognised during commandline option
    /// parsing using `g_application_add_main_option_entries()` and
    /// `g_application_add_option_group()`.
    ///
    /// Signal handlers can inspect `options` (along with values pointed to
    /// from the `arg_data` of an installed `GOptionEntrys`) in order to
    /// decide to perform certain actions, including direct local handling
    /// (which may be useful for options like --version).
    ///
    /// In the event that the application is marked
    /// [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] the "normal processing" will
    /// send the `options` dictionary to the primary instance where it can be
    /// read with [`ApplicationCommandLineExt::options_dict()`][crate::prelude::ApplicationCommandLineExt::options_dict()]. The signal
    /// handler can modify the dictionary before returning, and the
    /// modified dictionary will be sent.
    ///
    /// In the event that [`ApplicationFlags::HANDLES_COMMAND_LINE`][crate::ApplicationFlags::HANDLES_COMMAND_LINE] is not set,
    /// "normal processing" will treat the remaining uncollected command
    /// line arguments as filenames or URIs. If there are no arguments,
    /// the application is activated by [`activate()`][Self::activate()]. One or
    /// more arguments results in a call to [`open()`][Self::open()].
    ///
    /// If you want to handle the local commandline arguments for yourself
    /// by converting them to calls to [`open()`][Self::open()] or
    /// [`ActionGroupExt::activate_action()`][crate::prelude::ActionGroupExt::activate_action()] then you must be sure to register
    /// the application first. You should probably not call
    /// [`activate()`][Self::activate()] for yourself, however: just return -1 and
    /// allow the default handler to do it for you. This will ensure that
    /// the `--gapplication-service` switch works properly (i.e. no activation
    /// in that case).
    ///
    /// Note that this signal is emitted from the default implementation of
    /// `local_command_line()`. If you override that function and don't
    /// chain up then this signal will never be emitted.
    ///
    /// You can override `local_command_line()` if you need more powerful
    /// capabilities than what is provided here, but this should not
    /// normally be required.
    /// ## `options`
    /// the options dictionary
    ///
    /// # Returns
    ///
    /// an exit code. If you have handled your options and want
    /// to exit the process, return a non-negative option, 0 for success,
    /// and a positive value for failure. To continue, return -1 to let
    /// the default option processing continue.
    #[doc(alias = "handle-local-options")]
    fn connect_handle_local_options<F: Fn(&Self, &glib::VariantDict) -> i32 + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    /// The ::name-lost signal is emitted only on the registered primary instance
    /// when a new instance has taken over. This can only happen if the application
    /// is using the [`ApplicationFlags::ALLOW_REPLACEMENT`][crate::ApplicationFlags::ALLOW_REPLACEMENT] flag.
    ///
    /// The default handler for this signal calls [`quit()`][Self::quit()].
    ///
    /// # Returns
    ///
    /// [`true`] if the signal has been handled
    #[cfg(any(feature = "v2_60", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
    #[doc(alias = "name-lost")]
    fn connect_name_lost<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::shutdown signal is emitted only on the registered primary instance
    /// immediately after the main loop terminates.
    #[doc(alias = "shutdown")]
    fn connect_shutdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::startup signal is emitted on the primary instance immediately
    /// after registration. See [`register()`][Self::register()].
    #[doc(alias = "startup")]
    fn connect_startup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "action-group")]
    fn connect_action_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "application-id")]
    fn connect_application_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "flags")]
    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "inactivity-timeout")]
    fn connect_inactivity_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "is-busy")]
    fn connect_is_busy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "is-registered")]
    fn connect_is_registered_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "is-remote")]
    fn connect_is_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "resource-base-path")]
    fn connect_resource_base_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<Application>> ApplicationExt for O {
    fn activate(&self) {
        unsafe {
            ffi::g_application_activate(self.as_ref().to_glib_none().0);
        }
    }

    fn add_main_option(
        &self,
        long_name: &str,
        short_name: glib::Char,
        flags: glib::OptionFlags,
        arg: glib::OptionArg,
        description: &str,
        arg_description: Option<&str>,
    ) {
        unsafe {
            ffi::g_application_add_main_option(
                self.as_ref().to_glib_none().0,
                long_name.to_glib_none().0,
                short_name.into_glib(),
                flags.into_glib(),
                arg.into_glib(),
                description.to_glib_none().0,
                arg_description.to_glib_none().0,
            );
        }
    }

    //fn add_main_option_entries(&self, entries: /*Ignored*/&[glib::OptionEntry]) {
    //    unsafe { TODO: call ffi:g_application_add_main_option_entries() }
    //}

    //fn add_option_group(&self, group: /*Ignored*/&glib::OptionGroup) {
    //    unsafe { TODO: call ffi:g_application_add_option_group() }
    //}

    fn bind_busy_property(&self, object: &impl IsA<glib::Object>, property: &str) {
        unsafe {
            ffi::g_application_bind_busy_property(
                self.as_ref().to_glib_none().0,
                object.as_ref().to_glib_none().0,
                property.to_glib_none().0,
            );
        }
    }

    fn application_id(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::g_application_get_application_id(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn dbus_connection(&self) -> Option<DBusConnection> {
        unsafe {
            from_glib_none(ffi::g_application_get_dbus_connection(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn dbus_object_path(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::g_application_get_dbus_object_path(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn flags(&self) -> ApplicationFlags {
        unsafe { from_glib(ffi::g_application_get_flags(self.as_ref().to_glib_none().0)) }
    }

    fn inactivity_timeout(&self) -> u32 {
        unsafe { ffi::g_application_get_inactivity_timeout(self.as_ref().to_glib_none().0) }
    }

    fn is_busy(&self) -> bool {
        unsafe {
            from_glib(ffi::g_application_get_is_busy(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_registered(&self) -> bool {
        unsafe {
            from_glib(ffi::g_application_get_is_registered(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_remote(&self) -> bool {
        unsafe {
            from_glib(ffi::g_application_get_is_remote(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn resource_base_path(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::g_application_get_resource_base_path(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn open(&self, files: &[File], hint: &str) {
        let n_files = files.len() as _;
        unsafe {
            ffi::g_application_open(
                self.as_ref().to_glib_none().0,
                files.to_glib_none().0,
                n_files,
                hint.to_glib_none().0,
            );
        }
    }

    fn quit(&self) {
        unsafe {
            ffi::g_application_quit(self.as_ref().to_glib_none().0);
        }
    }

    fn register(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let is_ok = ffi::g_application_register(
                self.as_ref().to_glib_none().0,
                cancellable.map(|p| p.as_ref()).to_glib_none().0,
                &mut error,
            );
            assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn send_notification(&self, id: Option<&str>, notification: &Notification) {
        unsafe {
            ffi::g_application_send_notification(
                self.as_ref().to_glib_none().0,
                id.to_glib_none().0,
                notification.to_glib_none().0,
            );
        }
    }

    fn set_application_id(&self, application_id: Option<&str>) {
        unsafe {
            ffi::g_application_set_application_id(
                self.as_ref().to_glib_none().0,
                application_id.to_glib_none().0,
            );
        }
    }

    fn set_default(&self) {
        unsafe {
            ffi::g_application_set_default(self.as_ref().to_glib_none().0);
        }
    }

    fn set_flags(&self, flags: ApplicationFlags) {
        unsafe {
            ffi::g_application_set_flags(self.as_ref().to_glib_none().0, flags.into_glib());
        }
    }

    fn set_inactivity_timeout(&self, inactivity_timeout: u32) {
        unsafe {
            ffi::g_application_set_inactivity_timeout(
                self.as_ref().to_glib_none().0,
                inactivity_timeout,
            );
        }
    }

    fn set_option_context_description(&self, description: Option<&str>) {
        unsafe {
            ffi::g_application_set_option_context_description(
                self.as_ref().to_glib_none().0,
                description.to_glib_none().0,
            );
        }
    }

    fn set_option_context_parameter_string(&self, parameter_string: Option<&str>) {
        unsafe {
            ffi::g_application_set_option_context_parameter_string(
                self.as_ref().to_glib_none().0,
                parameter_string.to_glib_none().0,
            );
        }
    }

    fn set_option_context_summary(&self, summary: Option<&str>) {
        unsafe {
            ffi::g_application_set_option_context_summary(
                self.as_ref().to_glib_none().0,
                summary.to_glib_none().0,
            );
        }
    }

    fn set_resource_base_path(&self, resource_path: Option<&str>) {
        unsafe {
            ffi::g_application_set_resource_base_path(
                self.as_ref().to_glib_none().0,
                resource_path.to_glib_none().0,
            );
        }
    }

    fn unbind_busy_property(&self, object: &impl IsA<glib::Object>, property: &str) {
        unsafe {
            ffi::g_application_unbind_busy_property(
                self.as_ref().to_glib_none().0,
                object.as_ref().to_glib_none().0,
                property.to_glib_none().0,
            );
        }
    }

    fn withdraw_notification(&self, id: &str) {
        unsafe {
            ffi::g_application_withdraw_notification(
                self.as_ref().to_glib_none().0,
                id.to_glib_none().0,
            );
        }
    }

    fn set_action_group<P: IsA<ActionGroup>>(&self, action_group: Option<&P>) {
        glib::ObjectExt::set_property(self.as_ref(), "action-group", &action_group)
    }

    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn activate_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
            this: *mut ffi::GApplication,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"activate\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    activate_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_command_line<F: Fn(&Self, &ApplicationCommandLine) -> i32 + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn command_line_trampoline<
            P: IsA<Application>,
            F: Fn(&P, &ApplicationCommandLine) -> i32 + 'static,
        >(
            this: *mut ffi::GApplication,
            command_line: *mut ffi::GApplicationCommandLine,
            f: glib::ffi::gpointer,
        ) -> libc::c_int {
            let f: &F = &*(f as *const F);
            f(
                Application::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(command_line),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"command-line\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    command_line_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_handle_local_options<F: Fn(&Self, &glib::VariantDict) -> i32 + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn handle_local_options_trampoline<
            P: IsA<Application>,
            F: Fn(&P, &glib::VariantDict) -> i32 + 'static,
        >(
            this: *mut ffi::GApplication,
            options: *mut glib::ffi::GVariantDict,
            f: glib::ffi::gpointer,
        ) -> libc::c_int {
            let f: &F = &*(f as *const F);
            f(
                Application::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(options),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"handle-local-options\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    handle_local_options_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v2_60", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
    fn connect_name_lost<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn name_lost_trampoline<
            P: IsA<Application>,
            F: Fn(&P) -> bool + 'static,
        >(
            this: *mut ffi::GApplication,
            f: glib::ffi::gpointer,
        ) -> glib::ffi::gboolean {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"name-lost\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    name_lost_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_shutdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn shutdown_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
            this: *mut ffi::GApplication,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"shutdown\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    shutdown_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_startup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn startup_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
            this: *mut ffi::GApplication,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"startup\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    startup_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_action_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_action_group_trampoline<
            P: IsA<Application>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::action-group\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_action_group_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_application_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_application_id_trampoline<
            P: IsA<Application>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::application-id\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_application_id_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_flags_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::flags\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_flags_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_inactivity_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_inactivity_timeout_trampoline<
            P: IsA<Application>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::inactivity-timeout\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_inactivity_timeout_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_is_busy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_is_busy_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::is-busy\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_is_busy_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_is_registered_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_is_registered_trampoline<
            P: IsA<Application>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::is-registered\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_is_registered_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_is_remote_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_is_remote_trampoline<
            P: IsA<Application>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::is-remote\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_is_remote_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_resource_base_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_resource_base_path_trampoline<
            P: IsA<Application>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GApplication,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Application::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::resource-base-path\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_resource_base_path_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for Application {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Application")
    }
}