This file is indexed.

/usr/include/d/gtkd-3/gio/Application.d is in libgtkd-3-dev 3.7.5-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
/*
 * This file is part of gtkD.
 *
 * gtkD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version, with
 * some exceptions, please read the COPYING file.
 *
 * gtkD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with gtkD; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage


module gio.Application;

private import gio.ActionGroupIF;
private import gio.ActionGroupT;
private import gio.ActionMapIF;
private import gio.ActionMapT;
private import gio.ApplicationCommandLine;
private import gio.Cancellable;
private import gio.DBusConnection;
private import gio.FileIF;
private import gio.Notification;
private import gio.c.functions;
public  import gio.c.types;
private import glib.ConstructionException;
private import glib.ErrorG;
private import glib.GException;
private import glib.OptionGroup;
private import glib.Str;
private import glib.VariantDict;
private import gobject.ObjectG;
private import gobject.Signals;
public  import gtkc.giotypes;
private import std.algorithm;


/**
 * A #GApplication 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 g_application_hold() and g_application_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
 * the always the current instance. On Linux, the D-Bus session bus
 * is used for communication.
 * 
 * The use of #GApplication 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
 * #GApplication should do very little more than instantiating the
 * application instance, possibly connecting signal handlers, then
 * calling g_application_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 g_application_run() promptly returns. See the code
 * examples below.
 * 
 * If used, the expected form of an application identifier is very close
 * to that of of a
 * [D-Bus bus name](http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface).
 * Examples include: "com.example.MyApp", "org.example.internal-apps.Calculator".
 * For details on valid application identifiers, see g_application_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 #GApplication
 * attempts to acquire the bus name of your application (which happens in
 * g_application_register()).  Unfortunately, this means that you cannot use
 * g_application_get_is_remote() to decide if you want to register object paths.
 * 
 * GApplication also implements the #GActionGroup and #GActionMap
 * interfaces and lets you easily export actions by adding them with
 * g_action_map_add_action(). When invoking an action by calling
 * g_action_group_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 #GDBusActionGroup wrapper to
 * conveniently access them remotely. GIO provides a #GDBusMenuModel 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 #GApplication::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
 * #GVariant dictionary mapping strings to variants. To use platform
 * data, override the @before_emit or @after_emit virtual functions
 * in your #GApplication subclass. When dealing with
 * #GApplicationCommandLine objects, the platform data is
 * directly available via g_application_command_line_get_cwd(),
 * g_application_command_line_get_environ() and
 * g_application_command_line_get_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
 * %G_APPLICATION_SEND_ENVIRONMENT flag is set. #GApplication 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
 * #GApplication::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://git.gnome.org/browse/glib/tree/gio/tests/gapplication-example-open.c).
 * 
 * For an example of using actions with GApplication, see
 * [gapplication-example-actions.c](https://git.gnome.org/browse/glib/tree/gio/tests/gapplication-example-actions.c).
 * 
 * For an example of using extra D-Bus hooks with GApplication, see
 * [gapplication-example-dbushooks.c](https://git.gnome.org/browse/glib/tree/gio/tests/gapplication-example-dbushooks.c).
 *
 * Since: 2.28
 */
public class Application : ObjectG, ActionGroupIF, ActionMapIF
{
	/** the main Gtk struct */
	protected GApplication* gApplication;

	/** Get the main Gtk struct */
	public GApplication* getApplicationStruct(bool transferOwnership = false)
	{
		if (transferOwnership)
			ownedRef = false;
		return gApplication;
	}

	/** the main Gtk struct as a void* */
	protected override void* getStruct()
	{
		return cast(void*)gApplication;
	}

	protected override void setStruct(GObject* obj)
	{
		gApplication = cast(GApplication*)obj;
		super.setStruct(obj);
	}

	/**
	 * Sets our main struct and passes it to the parent class.
	 */
	public this (GApplication* gApplication, bool ownedRef = false)
	{
		this.gApplication = gApplication;
		super(cast(GObject*)gApplication, ownedRef);
	}

	// add the ActionGroup capabilities
	mixin ActionGroupT!(GApplication);

	// add the ActionMap capabilities
	mixin ActionMapT!(GApplication);

	protected class ScopedOnCommandLineDelegateWrapper
	{
		int delegate(Scoped!ApplicationCommandLine, Application) dlg;
		gulong handlerId;

		this(int delegate(Scoped!ApplicationCommandLine, Application) dlg)
		{
			this.dlg = dlg;
			scopedOnCommandLineListeners ~= this;
		}

		void remove(ScopedOnCommandLineDelegateWrapper source)
		{
			foreach(index, wrapper; scopedOnCommandLineListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					scopedOnCommandLineListeners[index] = null;
					scopedOnCommandLineListeners = std.algorithm.remove(scopedOnCommandLineListeners, index);
					break;
				}
			}
		}
	}
	ScopedOnCommandLineDelegateWrapper[] scopedOnCommandLineListeners;

	/**
	 * The ::command-line signal is emitted on the primary instance when
	 * a commandline is not handled locally. See g_application_run() and
	 * the #GApplicationCommandLine documentation for more information.
	 *
	 * Params:
	 *     commandLine = a #GApplicationCommandLine representing the
	 *         passed commandline
	 *
	 * Return: An integer that is set as the exit status for the calling
	 *     process. See g_application_command_line_set_exit_status().
	 */
	gulong addOnCommandLine(int delegate(Scoped!ApplicationCommandLine, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new ScopedOnCommandLineDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"command-line",
			cast(GCallback)&callBackScopedCommandLine,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackScopedCommandLineDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static int callBackScopedCommandLine(GApplication* applicationStruct, GApplicationCommandLine* commandLine, ScopedOnCommandLineDelegateWrapper wrapper)
	{
		return wrapper.dlg(getScopedGobject!ApplicationCommandLine(commandLine), wrapper.outer);
	}

	extern(C) static void callBackScopedCommandLineDestroy(ScopedOnCommandLineDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}

	/**
	 */

	/** */
	public static GType getType()
	{
		return g_application_get_type();
	}

	/**
	 * Creates a new #GApplication instance.
	 *
	 * If non-%NULL, the application id must be valid.  See
	 * g_application_id_is_valid().
	 *
	 * If no application ID is given then some features of #GApplication
	 * (most notably application uniqueness) will be disabled.
	 *
	 * Params:
	 *     applicationId = the application id
	 *     flags = the application flags
	 *
	 * Returns: a new #GApplication instance
	 *
	 * Throws: ConstructionException GTK+ fails to create the object.
	 */
	public this(string applicationId, GApplicationFlags flags)
	{
		auto p = g_application_new(Str.toStringz(applicationId), flags);

		if(p is null)
		{
			throw new ConstructionException("null returned by new");
		}

		this(cast(GApplication*) p, true);
	}

	/**
	 * Returns the default #GApplication instance for this process.
	 *
	 * Normally there is only one #GApplication per process and it becomes
	 * the default when it is created.  You can exercise more control over
	 * this by using g_application_set_default().
	 *
	 * If there is no default application then %NULL is returned.
	 *
	 * Returns: the default application for this process, or %NULL
	 *
	 * Since: 2.32
	 */
	public static Application getDefault()
	{
		auto p = g_application_get_default();

		if(p is null)
		{
			return null;
		}

		return ObjectG.getDObject!(Application)(cast(GApplication*) p);
	}

	/**
	 * Checks if @application_id is a valid application identifier.
	 *
	 * A valid ID is required for calls to g_application_new() and
	 * g_application_set_application_id().
	 *
	 * For convenience, the restrictions on application identifiers are
	 * reproduced here:
	 *
	 * - Application identifiers must contain only the ASCII characters
	 * "[A-Z][a-z][0-9]_-." and 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 or end with a '.' (period)
	 * character.
	 *
	 * - Application identifiers must not contain consecutive '.' (period)
	 * characters.
	 *
	 * - Application identifiers must not exceed 255 characters.
	 *
	 * Params:
	 *     applicationId = a potential application identifier
	 *
	 * Returns: %TRUE if @application_id is valid
	 */
	public static bool idIsValid(string applicationId)
	{
		return g_application_id_is_valid(Str.toStringz(applicationId)) != 0;
	}

	/**
	 * Activates the application.
	 *
	 * In essence, this results in the #GApplication::activate signal being
	 * emitted in the primary instance.
	 *
	 * The application must be registered before calling this function.
	 *
	 * Since: 2.28
	 */
	public void activate()
	{
		g_application_activate(gApplication);
	}

	/**
	 * Add an option to be handled by @application.
	 *
	 * 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 %NULL.
	 *
	 * The parsed arguments will be packed into a #GVariantDict which
	 * is passed to #GApplication::handle-local-options. If
	 * %G_APPLICATION_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.
	 *
	 * Params:
	 *     longName = the long name of an option used to specify it in a commandline
	 *     shortName = the short name of an option
	 *     flags = flags from #GOptionFlags
	 *     arg = the type of the option, as a #GOptionArg
	 *     description = the description for the option in `--help` output
	 *     argDescription = the placeholder to use for the extra argument
	 *         parsed by the option in `--help` output
	 *
	 * Since: 2.42
	 */
	public void addMainOption(string longName, char shortName, GOptionFlags flags, GOptionArg arg, string description, string argDescription)
	{
		g_application_add_main_option(gApplication, Str.toStringz(longName), shortName, flags, arg, Str.toStringz(description), Str.toStringz(argDescription));
	}

	/**
	 * Adds main option entries to be handled by @application.
	 *
	 * This function is comparable to g_option_context_add_main_entries().
	 *
	 * After the commandline arguments are parsed, the
	 * #GApplication::handle-local-options signal will be emitted.  At this
	 * point, the application can inspect the values pointed to by @arg_data
	 * in the given #GOptionEntrys.
	 *
	 * Unlike #GOptionContext, #GApplication supports giving a %NULL
	 * @arg_data for a non-callback #GOptionEntry.  This results in the
	 * argument in question being packed into a #GVariantDict which is also
	 * passed to #GApplication::handle-local-options, where it can be
	 * inspected and modified.  If %G_APPLICATION_HANDLES_COMMAND_LINE is
	 * set, then the resulting dictionary is sent to the primary instance,
	 * where g_application_command_line_get_options_dict() will return it.
	 * This "packing" is done according to the type of the argument --
	 * booleans for normal flags, strings for strings, bytestrings for
	 * filenames, etc.  The packing only occurs if the flag is given (ie: we
	 * do not pack a "false" #GVariant in the case that a flag is missing).
	 *
	 * In general, it is recommended that all commandline arguments are
	 * parsed locally.  The options dictionary should then be used to
	 * transmit the result of the parsing to the primary instance, where
	 * g_variant_dict_lookup() can be used.  For local options, it is
	 * possible to either use @arg_data in the usual way, or to consult (and
	 * potentially remove) the option from the options dictionary.
	 *
	 * This function is new in GLib 2.40.  Before then, the only real choice
	 * was to send all of the commandline arguments (options and all) to the
	 * primary instance for handling.  #GApplication ignored them completely
	 * on the local side.  Calling this function "opts in" to the new
	 * behaviour, and in particular, means that unrecognised options will be
	 * treated as errors.  Unrecognised options have never been ignored when
	 * %G_APPLICATION_HANDLES_COMMAND_LINE is unset.
	 *
	 * If #GApplication::handle-local-options needs to see the list of
	 * filenames, then the use of %G_OPTION_REMAINING is recommended.  If
	 * @arg_data is %NULL then %G_OPTION_REMAINING can be used as a key into
	 * the options dictionary.  If you do use %G_OPTION_REMAINING then you
	 * need to handle these arguments for yourself because once they are
	 * consumed, they will no longer be visible to the default handling
	 * (which treats them as filenames to be opened).
	 *
	 * It is important to use the proper GVariant format when retrieving
	 * the options with g_variant_dict_lookup():
	 * - for %G_OPTION_ARG_NONE, use b
	 * - for %G_OPTION_ARG_STRING, use &s
	 * - for %G_OPTION_ARG_INT, use i
	 * - for %G_OPTION_ARG_INT64, use x
	 * - for %G_OPTION_ARG_DOUBLE, use d
	 * - for %G_OPTION_ARG_FILENAME, use ^ay
	 * - for %G_OPTION_ARG_STRING_ARRAY, use &as
	 * - for %G_OPTION_ARG_FILENAME_ARRAY, use ^aay
	 *
	 * Params:
	 *     entries = a
	 *         %NULL-terminated list of #GOptionEntrys
	 *
	 * Since: 2.40
	 */
	public void addMainOptionEntries(GOptionEntry[] entries)
	{
		g_application_add_main_option_entries(gApplication, entries.ptr);
	}

	/**
	 * Adds a #GOptionGroup to the commandline handling of @application.
	 *
	 * This function is comparable to g_option_context_add_group().
	 *
	 * Unlike g_application_add_main_option_entries(), this function does
	 * not deal with %NULL @arg_data and never transmits options to the
	 * primary instance.
	 *
	 * The reason for that is because, by the time the options arrive at the
	 * primary instance, it is typically too late to do anything with them.
	 * Taking the GTK option group as an example: GTK will already have been
	 * initialised by the time the #GApplication::command-line handler runs.
	 * In the case that this is not the first-running instance of the
	 * application, the existing instance may already have been running for
	 * a very long time.
	 *
	 * This means that the options from #GOptionGroup are only really usable
	 * in the case that the instance of the application being run is the
	 * first instance.  Passing options like `--display=` or `--gdk-debug=`
	 * on future runs will have no effect on the existing primary instance.
	 *
	 * Calling this function will cause the options in the supplied option
	 * group to be parsed, but it does not cause you to be "opted in" to the
	 * new functionality whereby unrecognised options are rejected even if
	 * %G_APPLICATION_HANDLES_COMMAND_LINE was given.
	 *
	 * Params:
	 *     group = a #GOptionGroup
	 *
	 * Since: 2.40
	 */
	public void addOptionGroup(OptionGroup group)
	{
		g_application_add_option_group(gApplication, (group is null) ? null : group.getOptionGroupStruct(true));
	}

	/**
	 * Marks @application as busy (see g_application_mark_busy()) while
	 * @property on @object is %TRUE.
	 *
	 * The binding holds a reference to @application while it is active, but
	 * not to @object. Instead, the binding is destroyed when @object is
	 * finalized.
	 *
	 * Params:
	 *     object = a #GObject
	 *     property = the name of a boolean property of @object
	 *
	 * Since: 2.44
	 */
	public void bindBusyProperty(ObjectG object, string property)
	{
		g_application_bind_busy_property(gApplication, (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property));
	}

	/**
	 * Gets the unique identifier for @application.
	 *
	 * Returns: the identifier for @application, owned by @application
	 *
	 * Since: 2.28
	 */
	public string getApplicationId()
	{
		return Str.toString(g_application_get_application_id(gApplication));
	}

	/**
	 * Gets the #GDBusConnection being used by the application, or %NULL.
	 *
	 * If #GApplication is using its D-Bus backend then this function will
	 * return the #GDBusConnection being used for uniqueness and
	 * communication with the desktop environment and other instances of the
	 * application.
	 *
	 * If #GApplication is not using D-Bus then this function will return
	 * %NULL.  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 g_application_get_is_registered().
	 *
	 * Returns: a #GDBusConnection, or %NULL
	 *
	 * Since: 2.34
	 */
	public DBusConnection getDbusConnection()
	{
		auto p = g_application_get_dbus_connection(gApplication);

		if(p is null)
		{
			return null;
		}

		return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p);
	}

	/**
	 * Gets the D-Bus object path being used by the application, or %NULL.
	 *
	 * If #GApplication is using its D-Bus backend then this function will
	 * return the D-Bus object path that #GApplication 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 #GApplication is not using D-Bus then this function will return
	 * %NULL.  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 g_application_get_is_registered().
	 *
	 * Returns: the object path, or %NULL
	 *
	 * Since: 2.34
	 */
	public string getDbusObjectPath()
	{
		return Str.toString(g_application_get_dbus_object_path(gApplication));
	}

	/**
	 * Gets the flags for @application.
	 *
	 * See #GApplicationFlags.
	 *
	 * Returns: the flags for @application
	 *
	 * Since: 2.28
	 */
	public GApplicationFlags getFlags()
	{
		return g_application_get_flags(gApplication);
	}

	/**
	 * Gets the current inactivity timeout for the application.
	 *
	 * This is the amount of time (in milliseconds) after the last call to
	 * g_application_release() before the application stops running.
	 *
	 * Returns: the timeout, in milliseconds
	 *
	 * Since: 2.28
	 */
	public uint getInactivityTimeout()
	{
		return g_application_get_inactivity_timeout(gApplication);
	}

	/**
	 * Gets the application's current busy state, as set through
	 * g_application_mark_busy() or g_application_bind_busy_property().
	 *
	 * Returns: %TRUE if @application is currenty marked as busy
	 *
	 * Since: 2.44
	 */
	public bool getIsBusy()
	{
		return g_application_get_is_busy(gApplication) != 0;
	}

	/**
	 * Checks if @application is registered.
	 *
	 * An application is registered if g_application_register() has been
	 * successfully called.
	 *
	 * Returns: %TRUE if @application is registered
	 *
	 * Since: 2.28
	 */
	public bool getIsRegistered()
	{
		return g_application_get_is_registered(gApplication) != 0;
	}

	/**
	 * Checks if @application is remote.
	 *
	 * If @application is remote then it means that another instance of
	 * application already exists (the 'primary' instance).  Calls to
	 * perform actions on @application will result in the actions being
	 * performed by the primary instance.
	 *
	 * The value of this property cannot be accessed before
	 * g_application_register() has been called.  See
	 * g_application_get_is_registered().
	 *
	 * Returns: %TRUE if @application is remote
	 *
	 * Since: 2.28
	 */
	public bool getIsRemote()
	{
		return g_application_get_is_remote(gApplication) != 0;
	}

	/**
	 * Gets the resource base path of @application.
	 *
	 * See g_application_set_resource_base_path() for more information.
	 *
	 * Returns: the base resource path, if one is set
	 *
	 * Since: 2.42
	 */
	public string getResourceBasePath()
	{
		return Str.toString(g_application_get_resource_base_path(gApplication));
	}

	/**
	 * Increases the use count of @application.
	 *
	 * Use this function to indicate that the application has a reason to
	 * continue to run.  For example, g_application_hold() is called by GTK+
	 * when a toplevel window is on the screen.
	 *
	 * To cancel the hold, call g_application_release().
	 */
	public void hold()
	{
		g_application_hold(gApplication);
	}

	/**
	 * Increases the busy count of @application.
	 *
	 * Use this function to indicate that the application is busy, for instance
	 * while a long running operation is pending.
	 *
	 * The busy state will be exposed to other processes, so a session shell will
	 * use that information to indicate the state to the user (e.g. with a
	 * spinner).
	 *
	 * To cancel the busy indication, use g_application_unmark_busy().
	 *
	 * Since: 2.38
	 */
	public void markBusy()
	{
		g_application_mark_busy(gApplication);
	}

	/**
	 * Opens the given files.
	 *
	 * In essence, this results in the #GApplication::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 %G_APPLICATION_HANDLES_OPEN flag set.
	 *
	 * Params:
	 *     files = an array of #GFiles to open
	 *     hint = a hint (or ""), but never %NULL
	 *
	 * Since: 2.28
	 */
	public void open(FileIF[] files, string hint)
	{
		GFile*[] filesArray = new GFile*[files.length];
		for ( int i = 0; i < files.length; i++ )
		{
			filesArray[i] = files[i].getFileStruct();
		}

		g_application_open(gApplication, filesArray.ptr, cast(int)files.length, Str.toStringz(hint));
	}

	/**
	 * Immediately quits the application.
	 *
	 * Upon return to the mainloop, g_application_run() will return,
	 * calling only the 'shutdown' function before doing so.
	 *
	 * The hold count is ignored.
	 *
	 * The result of calling g_application_run() again after it returns is
	 * unspecified.
	 *
	 * Since: 2.32
	 */
	public void quit()
	{
		g_application_quit(gApplication);
	}

	/**
	 * 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 %G_APPLICATION_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 #GApplication::startup signal is emitted if registration succeeds
	 * and @application 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
	 * g_application_get_is_remote() for that.
	 *
	 * Params:
	 *     cancellable = a #GCancellable, or %NULL
	 *
	 * Returns: %TRUE if registration succeeded
	 *
	 * Since: 2.28
	 *
	 * Throws: GException on failure.
	 */
	public bool register(Cancellable cancellable)
	{
		GError* err = null;

		auto p = g_application_register(gApplication, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;

		if (err !is null)
		{
			throw new GException( new ErrorG(err) );
		}

		return p;
	}

	/**
	 * Decrease the use count of @application.
	 *
	 * When the use count reaches zero, the application will stop running.
	 *
	 * Never call this function except to cancel the effect of a previous
	 * call to g_application_hold().
	 */
	public void release()
	{
		g_application_release(gApplication);
	}

	/**
	 * Runs the application.
	 *
	 * This function is intended to be run from main() and its return value
	 * is intended to be returned by main(). Although you are expected to pass
	 * the @argc, @argv parameters from main() to this function, it is possible
	 * to pass %NULL if @argv is not available or commandline handling is not
	 * required.  Note that on Windows, @argc and @argv are ignored, and
	 * g_win32_get_command_line() is called internally (for proper support
	 * of Unicode commandline arguments).
	 *
	 * #GApplication will attempt to parse the commandline arguments.  You
	 * can add commandline flags to the list of recognised options by way of
	 * g_application_add_main_option_entries().  After this, the
	 * #GApplication::handle-local-options signal is emitted, from which the
	 * application can inspect the values of its #GOptionEntrys.
	 *
	 * #GApplication::handle-local-options is a good place to handle options
	 * such as `--version`, where an immediate reply from the local process is
	 * desired (instead of communicating with an already-running instance).
	 * A #GApplication::handle-local-options handler can stop further processing
	 * by returning a non-negative value, which then becomes the exit status of
	 * the process.
	 *
	 * What happens next depends on the flags: if
	 * %G_APPLICATION_HANDLES_COMMAND_LINE was specified then the remaining
	 * commandline arguments are sent to the primary instance, where a
	 * #GApplication::command-line signal is emitted.  Otherwise, the
	 * remaining commandline arguments are assumed to be a list of files.
	 * If there are no files listed, the application is activated via the
	 * #GApplication::activate signal.  If there are one or more files, and
	 * %G_APPLICATION_HANDLES_OPEN was specified then the files are opened
	 * via the #GApplication::open signal.
	 *
	 * If you are interested in doing more complicated local handling of the
	 * commandline then you should implement your own #GApplication subclass
	 * and override local_command_line(). In this case, you most likely want
	 * to return %TRUE from your local_command_line() implementation to
	 * suppress the default handling. See
	 * [gapplication-example-cmdline2.c][gapplication-example-cmdline2]
	 * for an example.
	 *
	 * If, after the above is done, the use count of the application is zero
	 * then the exit status is returned immediately.  If the use count is
	 * non-zero then the default main context is iterated until the use count
	 * falls to zero, at which point 0 is returned.
	 *
	 * If the %G_APPLICATION_IS_SERVICE flag is set, then the service will
	 * run for as much as 10 seconds with a use count of zero while waiting
	 * for the message that caused the activation to arrive.  After that,
	 * if the use count falls to zero the application will exit immediately,
	 * except in the case that g_application_set_inactivity_timeout() is in
	 * use.
	 *
	 * This function sets the prgname (g_set_prgname()), if not already set,
	 * to the basename of argv[0].
	 *
	 * Much like g_main_loop_run(), this function will acquire the main context
	 * for the duration that the application is running.
	 *
	 * Since 2.40, applications that are not explicitly flagged as services
	 * or launchers (ie: neither %G_APPLICATION_IS_SERVICE or
	 * %G_APPLICATION_IS_LAUNCHER are given as flags) will check (from the
	 * default handler for local_command_line) if "--gapplication-service"
	 * was given in the command line.  If this flag is present then normal
	 * commandline processing is interrupted and the
	 * %G_APPLICATION_IS_SERVICE flag is set.  This provides a "compromise"
	 * solution whereby running an application directly from the commandline
	 * will invoke it in the normal way (which can be useful for debugging)
	 * while still allowing applications to be D-Bus activated in service
	 * mode.  The D-Bus service file should invoke the executable with
	 * "--gapplication-service" as the sole commandline argument.  This
	 * approach is suitable for use by most graphical applications but
	 * should not be used from applications like editors that need precise
	 * control over when processes invoked via the commandline will exit and
	 * what their exit status will be.
	 *
	 * Params:
	 *     argv = the argv from main(), or %NULL
	 *
	 * Returns: the exit status
	 *
	 * Since: 2.28
	 */
	public int run(string[] argv)
	{
		return g_application_run(gApplication, cast(int)argv.length, Str.toStringzArray(argv));
	}

	/**
	 * Sends a notification on behalf of @application 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 %NULL, but it is impossible to replace or withdraw
	 * notifications without an id.
	 *
	 * If @notification is no longer relevant, it can be withdrawn with
	 * g_application_withdraw_notification().
	 *
	 * Params:
	 *     id = id of the notification, or %NULL
	 *     notification = the #GNotification to send
	 *
	 * Since: 2.40
	 */
	public void sendNotification(string id, Notification notification)
	{
		g_application_send_notification(gApplication, Str.toStringz(id), (notification is null) ? null : notification.getNotificationStruct());
	}

	/**
	 * This used to be how actions were associated with a #GApplication.
	 * Now there is #GActionMap for that.
	 *
	 * Deprecated: Use the #GActionMap interface instead.  Never ever
	 * mix use of this API with use of #GActionMap on the same @application
	 * or things will go very badly wrong.  This function is known to
	 * introduce buggy behaviour (ie: signals not emitted on changes to the
	 * action group), so you should really use #GActionMap instead.
	 *
	 * Params:
	 *     actionGroup = a #GActionGroup, or %NULL
	 *
	 * Since: 2.28
	 */
	public void setActionGroup(ActionGroupIF actionGroup)
	{
		g_application_set_action_group(gApplication, (actionGroup is null) ? null : actionGroup.getActionGroupStruct());
	}

	/**
	 * Sets the unique identifier for @application.
	 *
	 * The application id can only be modified if @application has not yet
	 * been registered.
	 *
	 * If non-%NULL, the application id must be valid.  See
	 * g_application_id_is_valid().
	 *
	 * Params:
	 *     applicationId = the identifier for @application
	 *
	 * Since: 2.28
	 */
	public void setApplicationId(string applicationId)
	{
		g_application_set_application_id(gApplication, Str.toStringz(applicationId));
	}

	/**
	 * Sets or unsets the default application for the process, as returned
	 * by g_application_get_default().
	 *
	 * This function does not take its own reference on @application.  If
	 * @application is destroyed then the default application will revert
	 * back to %NULL.
	 *
	 * Since: 2.32
	 */
	public void setDefault()
	{
		g_application_set_default(gApplication);
	}

	/**
	 * Sets the flags for @application.
	 *
	 * The flags can only be modified if @application has not yet been
	 * registered.
	 *
	 * See #GApplicationFlags.
	 *
	 * Params:
	 *     flags = the flags for @application
	 *
	 * Since: 2.28
	 */
	public void setFlags(GApplicationFlags flags)
	{
		g_application_set_flags(gApplication, flags);
	}

	/**
	 * Sets the current inactivity timeout for the application.
	 *
	 * This is the amount of time (in milliseconds) after the last call to
	 * g_application_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 g_application_release() drops the use count to
	 * zero.  Any timeouts currently in progress are not impacted.
	 *
	 * Params:
	 *     inactivityTimeout = the timeout, in milliseconds
	 *
	 * Since: 2.28
	 */
	public void setInactivityTimeout(uint inactivityTimeout)
	{
		g_application_set_inactivity_timeout(gApplication, inactivityTimeout);
	}

	/**
	 * Sets (or unsets) the base resource path of @application.
	 *
	 * 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 #GApplication 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 #GResource for more information about adding resources to your
	 * application.
	 *
	 * You can disable automatic resource loading functionality by setting
	 * the path to %NULL.
	 *
	 * 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 #GApplication you should either set the
	 * #GApplication: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.
	 *
	 * Params:
	 *     resourcePath = the resource path to use
	 *
	 * Since: 2.42
	 */
	public void setResourceBasePath(string resourcePath)
	{
		g_application_set_resource_base_path(gApplication, Str.toStringz(resourcePath));
	}

	/**
	 * Destroys a binding between @property and the busy state of
	 * @application that was previously created with
	 * g_application_bind_busy_property().
	 *
	 * Params:
	 *     object = a #GObject
	 *     property = the name of a boolean property of @object
	 *
	 * Since: 2.44
	 */
	public void unbindBusyProperty(ObjectG object, string property)
	{
		g_application_unbind_busy_property(gApplication, (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property));
	}

	/**
	 * Decreases the busy count of @application.
	 *
	 * When the busy count reaches zero, the new state will be propagated
	 * to other processes.
	 *
	 * This function must only be called to cancel the effect of a previous
	 * call to g_application_mark_busy().
	 *
	 * Since: 2.38
	 */
	public void unmarkBusy()
	{
		g_application_unmark_busy(gApplication);
	}

	/**
	 * Withdraws a notification that was sent with
	 * g_application_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.
	 *
	 * Params:
	 *     id = id of a previously sent notification
	 *
	 * Since: 2.40
	 */
	public void withdrawNotification(string id)
	{
		g_application_withdraw_notification(gApplication, Str.toStringz(id));
	}

	protected class OnActivateDelegateWrapper
	{
		void delegate(Application) dlg;
		gulong handlerId;

		this(void delegate(Application) dlg)
		{
			this.dlg = dlg;
			onActivateListeners ~= this;
		}

		void remove(OnActivateDelegateWrapper source)
		{
			foreach(index, wrapper; onActivateListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					onActivateListeners[index] = null;
					onActivateListeners = std.algorithm.remove(onActivateListeners, index);
					break;
				}
			}
		}
	}
	OnActivateDelegateWrapper[] onActivateListeners;

	/**
	 * The ::activate signal is emitted on the primary instance when an
	 * activation occurs. See g_application_activate().
	 */
	gulong addOnActivate(void delegate(Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new OnActivateDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"activate",
			cast(GCallback)&callBackActivate,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackActivateDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static void callBackActivate(GApplication* applicationStruct, OnActivateDelegateWrapper wrapper)
	{
		wrapper.dlg(wrapper.outer);
	}

	extern(C) static void callBackActivateDestroy(OnActivateDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}

	protected class OnCommandLineDelegateWrapper
	{
		int delegate(ApplicationCommandLine, Application) dlg;
		gulong handlerId;

		this(int delegate(ApplicationCommandLine, Application) dlg)
		{
			this.dlg = dlg;
			onCommandLineListeners ~= this;
		}

		void remove(OnCommandLineDelegateWrapper source)
		{
			foreach(index, wrapper; onCommandLineListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					onCommandLineListeners[index] = null;
					onCommandLineListeners = std.algorithm.remove(onCommandLineListeners, index);
					break;
				}
			}
		}
	}
	OnCommandLineDelegateWrapper[] onCommandLineListeners;

	/**
	 * The ::command-line signal is emitted on the primary instance when
	 * a commandline is not handled locally. See g_application_run() and
	 * the #GApplicationCommandLine documentation for more information.
	 *
	 * Params:
	 *     commandLine = a #GApplicationCommandLine representing the
	 *         passed commandline
	 *
	 * Returns: An integer that is set as the exit status for the calling
	 *     process. See g_application_command_line_set_exit_status().
	 */
	gulong addOnCommandLine(int delegate(ApplicationCommandLine, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new OnCommandLineDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"command-line",
			cast(GCallback)&callBackCommandLine,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackCommandLineDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static int callBackCommandLine(GApplication* applicationStruct, GApplicationCommandLine* commandLine, OnCommandLineDelegateWrapper wrapper)
	{
		return wrapper.dlg(ObjectG.getDObject!(ApplicationCommandLine)(commandLine), wrapper.outer);
	}

	extern(C) static void callBackCommandLineDestroy(OnCommandLineDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}

	protected class OnHandleLocalOptionsDelegateWrapper
	{
		int delegate(VariantDict, Application) dlg;
		gulong handlerId;

		this(int delegate(VariantDict, Application) dlg)
		{
			this.dlg = dlg;
			onHandleLocalOptionsListeners ~= this;
		}

		void remove(OnHandleLocalOptionsDelegateWrapper source)
		{
			foreach(index, wrapper; onHandleLocalOptionsListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					onHandleLocalOptionsListeners[index] = null;
					onHandleLocalOptionsListeners = std.algorithm.remove(onHandleLocalOptionsListeners, index);
					break;
				}
			}
		}
	}
	OnHandleLocalOptionsDelegateWrapper[] onHandleLocalOptionsListeners;

	/**
	 * 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
	 * %G_APPLICATION_HANDLES_COMMAND_LINE the "normal processing" will
	 * send the @options dictionary to the primary instance where it can be
	 * read with g_application_command_line_get_options_dict().  The signal
	 * handler can modify the dictionary before returning, and the
	 * modified dictionary will be sent.
	 *
	 * In the event that %G_APPLICATION_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 g_application_activate().  One or
	 * more arguments results in a call to g_application_open().
	 *
	 * If you want to handle the local commandline arguments for yourself
	 * by converting them to calls to g_application_open() or
	 * g_action_group_activate_action() then you must be sure to register
	 * the application first.  You should probably not call
	 * g_application_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.
	 *
	 * Params:
	 *     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.
	 *
	 * Since: 2.40
	 */
	gulong addOnHandleLocalOptions(int delegate(VariantDict, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new OnHandleLocalOptionsDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"handle-local-options",
			cast(GCallback)&callBackHandleLocalOptions,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackHandleLocalOptionsDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static int callBackHandleLocalOptions(GApplication* applicationStruct, GVariantDict* options, OnHandleLocalOptionsDelegateWrapper wrapper)
	{
		return wrapper.dlg(new VariantDict(options), wrapper.outer);
	}

	extern(C) static void callBackHandleLocalOptionsDestroy(OnHandleLocalOptionsDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}

	protected class OnOpenDelegateWrapper
	{
		void delegate(void*, int, string, Application) dlg;
		gulong handlerId;

		this(void delegate(void*, int, string, Application) dlg)
		{
			this.dlg = dlg;
			onOpenListeners ~= this;
		}

		void remove(OnOpenDelegateWrapper source)
		{
			foreach(index, wrapper; onOpenListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					onOpenListeners[index] = null;
					onOpenListeners = std.algorithm.remove(onOpenListeners, index);
					break;
				}
			}
		}
	}
	OnOpenDelegateWrapper[] onOpenListeners;

	/**
	 * The ::open signal is emitted on the primary instance when there are
	 * files to open. See g_application_open() for more information.
	 *
	 * Params:
	 *     files = an array of #GFiles
	 *     nFiles = the length of @files
	 *     hint = a hint provided by the calling instance
	 */
	gulong addOnOpen(void delegate(void*, int, string, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new OnOpenDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"open",
			cast(GCallback)&callBackOpen,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackOpenDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static void callBackOpen(GApplication* applicationStruct, void* files, int nFiles, char* hint, OnOpenDelegateWrapper wrapper)
	{
		wrapper.dlg(files, nFiles, Str.toString(hint), wrapper.outer);
	}

	extern(C) static void callBackOpenDestroy(OnOpenDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}

	protected class OnShutdownDelegateWrapper
	{
		void delegate(Application) dlg;
		gulong handlerId;

		this(void delegate(Application) dlg)
		{
			this.dlg = dlg;
			onShutdownListeners ~= this;
		}

		void remove(OnShutdownDelegateWrapper source)
		{
			foreach(index, wrapper; onShutdownListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					onShutdownListeners[index] = null;
					onShutdownListeners = std.algorithm.remove(onShutdownListeners, index);
					break;
				}
			}
		}
	}
	OnShutdownDelegateWrapper[] onShutdownListeners;

	/**
	 * The ::shutdown signal is emitted only on the registered primary instance
	 * immediately after the main loop terminates.
	 */
	gulong addOnShutdown(void delegate(Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new OnShutdownDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"shutdown",
			cast(GCallback)&callBackShutdown,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackShutdownDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static void callBackShutdown(GApplication* applicationStruct, OnShutdownDelegateWrapper wrapper)
	{
		wrapper.dlg(wrapper.outer);
	}

	extern(C) static void callBackShutdownDestroy(OnShutdownDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}

	protected class OnStartupDelegateWrapper
	{
		void delegate(Application) dlg;
		gulong handlerId;

		this(void delegate(Application) dlg)
		{
			this.dlg = dlg;
			onStartupListeners ~= this;
		}

		void remove(OnStartupDelegateWrapper source)
		{
			foreach(index, wrapper; onStartupListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					onStartupListeners[index] = null;
					onStartupListeners = std.algorithm.remove(onStartupListeners, index);
					break;
				}
			}
		}
	}
	OnStartupDelegateWrapper[] onStartupListeners;

	/**
	 * The ::startup signal is emitted on the primary instance immediately
	 * after registration. See g_application_register().
	 */
	gulong addOnStartup(void delegate(Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new OnStartupDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"startup",
			cast(GCallback)&callBackStartup,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackStartupDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static void callBackStartup(GApplication* applicationStruct, OnStartupDelegateWrapper wrapper)
	{
		wrapper.dlg(wrapper.outer);
	}

	extern(C) static void callBackStartupDestroy(OnStartupDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}
}