1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GApplication.html
27  * outPack = gio
28  * outFile = Application
29  * strct   = GApplication
30  * realStrct=
31  * ctorStrct=
32  * clss    = Application
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- ActionGroupIF
40  * 	- ActionMapIF
41  * prefixes:
42  * 	- g_application_
43  * omit structs:
44  * omit prefixes:
45  * omit code:
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- glib.ErrorG
50  * 	- glib.GException
51  * 	- gio.Cancellable
52  * 	- gio.DBusConnection
53  * 	- gio.File
54  * 	- gio.ActionGroupIF
55  * 	- gio.ActionGroupT
56  * 	- gio.ActionMapIF
57  * 	- gio.ActionMapT
58  * structWrap:
59  * 	- GApplication* -> Application
60  * 	- GCancellable* -> Cancellable
61  * 	- GDBusConnection* -> DBusConnection
62  * 	- GFile* -> File
63  * module aliases:
64  * local aliases:
65  * overrides:
66  */
67 
68 module gio.Application;
69 
70 public  import gtkc.giotypes;
71 
72 private import gtkc.gio;
73 private import glib.ConstructionException;
74 private import gobject.ObjectG;
75 
76 private import gobject.Signals;
77 public  import gtkc.gdktypes;
78 
79 private import glib.Str;
80 private import glib.ErrorG;
81 private import glib.GException;
82 private import gio.Cancellable;
83 private import gio.DBusConnection;
84 private import gio.File;
85 private import gio.ActionGroupIF;
86 private import gio.ActionGroupT;
87 private import gio.ActionMapIF;
88 private import gio.ActionMapT;
89 
90 
91 
92 private import gobject.ObjectG;
93 
94 /**
95  * A GApplication is the foundation of an application. It wraps some
96  * low-level platform-specific services and is intended to act as the
97  * foundation for higher-level application classes such as
98  * GtkApplication or MxApplication. In general, you should not use
99  * this class outside of a higher level framework.
100  *
101  * GApplication provides convenient life cycle management by maintaining
102  * a use count for the primary application instance.
103  * The use count can be changed using g_application_hold() and
104  * g_application_release(). If it drops to zero, the application exits.
105  * Higher-level classes such as GtkApplication employ the use count to
106  * ensure that the application stays alive as long as it has any opened
107  * windows.
108  *
109  * Another feature that GApplication (optionally) provides is process
110  * uniqueness. Applications can make use of this functionality by
111  * providing a unique application ID. If given, only one application
112  * with this ID can be running at a time per session. The session
113  * concept is platform-dependent, but corresponds roughly to a graphical
114  * desktop login. When your application is launched again, its
115  * arguments are passed through platform communication to the already
116  * running program. The already running instance of the program is
117  * called the primary instance; for non-unique
118  * applications this is the always the current instance.
119  * On Linux, the D-Bus session bus is used for communication.
120  *
121  * The use of GApplication differs from some other commonly-used
122  * uniqueness libraries (such as libunique) in important ways. The
123  * application is not expected to manually register itself and check if
124  * it is the primary instance. Instead, the main()
125  * function of a GApplication should do very little more than
126  * instantiating the application instance, possibly connecting signal
127  * handlers, then calling g_application_run(). All checks for
128  * uniqueness are done internally. If the application is the primary
129  * instance then the startup signal is emitted and the mainloop runs.
130  * If the application is not the primary instance then a signal is sent
131  * to the primary instance and g_application_run() promptly returns.
132  * See the code examples below.
133  *
134  * If used, the expected form of an application identifier is very close
135  * to that of of a
136  * DBus bus name.
137  * Examples include: "com.example.MyApp", "org.example.internal-apps.Calculator".
138  * For details on valid application identifiers, see g_application_id_is_valid().
139  *
140  * On Linux, the application identifier is claimed as a well-known bus name
141  * on the user's session bus. This means that the uniqueness of your
142  * application is scoped to the current session. It also means that your
143  * application may provide additional services (through registration of other
144  * object paths) at that bus name. The registration of these object paths
145  * should be done with the shared GDBus session bus. Note that due to the
146  * internal architecture of GDBus, method calls can be dispatched at any time
147  * (even if a main loop is not running). For this reason, you must ensure that
148  * any object paths that you wish to register are registered before GApplication
149  * attempts to acquire the bus name of your application (which happens in
150  * g_application_register()). Unfortunately, this means that you cannot use
151  * g_application_get_is_remote() to decide if you want to register object paths.
152  *
153  * GApplication also implements the GActionGroup and GActionMap
154  * interfaces and lets you easily export actions by adding them with
155  * g_action_map_add_action(). When invoking an action by calling
156  * g_action_group_activate_action() on the application, it is always
157  * invoked in the primary instance. The actions are also exported on
158  * the session bus, and GIO provides the GDBusActionGroup wrapper to
159  * conveniently access them remotely. GIO provides a GDBusMenuModel wrapper
160  * for remote access to exported GMenuModels.
161  *
162  * There is a number of different entry points into a GApplication:
163  *
164  * via 'Activate' (i.e. just starting the application)
165  * via 'Open' (i.e. opening some files)
166  * by handling a command-line
167  * via activating an action
168  *
169  * The "startup" signal lets you handle the application
170  * initialization for all of these in a single place.
171  *
172  * Regardless of which of these entry points is used to start the application,
173  * GApplication passes some platform
174  * data from the launching instance to the primary instance,
175  * in the form of a GVariant dictionary mapping strings to variants.
176  * To use platform data, override the before_emit or after_emit virtual
177  * functions in your GApplication subclass. When dealing with
178  * GApplicationCommandLine objects, the platform data is directly
179  * available via g_application_command_line_get_cwd(),
180  * g_application_command_line_get_environ() and
181  * g_application_command_line_get_platform_data().
182  *
183  * As the name indicates, the platform data may vary depending on the
184  * operating system, but it always includes the current directory (key
185  * "cwd"), and optionally the environment (ie the set of environment
186  * variables and their values) of the calling process (key "environ").
187  * The environment is only added to the platform data if the
188  * G_APPLICATION_SEND_ENVIRONMENT flag is set. GApplication subclasses
189  * can add their own platform data by overriding the add_platform_data
190  * virtual function. For instance, GtkApplication adds startup notification
191  * data in this way.
192  *
193  * To parse commandline arguments you may handle the
194  * "command-line" signal or override the local_command_line()
195  * vfunc, to parse them in either the primary instance or the local instance,
196  * respectively.
197  *
198  * $(DDOC_COMMENT example)
199  *
200  * $(DDOC_COMMENT example)
201  *
202  * $(DDOC_COMMENT example)
203  *
204  * $(DDOC_COMMENT example)
205  */
206 public class Application : ObjectG, ActionGroupIF, ActionMapIF
207 {
208 	
209 	/** the main Gtk struct */
210 	protected GApplication* gApplication;
211 	
212 	
213 	public GApplication* getApplicationStruct()
214 	{
215 		return gApplication;
216 	}
217 	
218 	
219 	/** the main Gtk struct as a void* */
220 	protected override void* getStruct()
221 	{
222 		return cast(void*)gApplication;
223 	}
224 	
225 	/**
226 	 * Sets our main struct and passes it to the parent class
227 	 */
228 	public this (GApplication* gApplication)
229 	{
230 		super(cast(GObject*)gApplication);
231 		this.gApplication = gApplication;
232 	}
233 	
234 	protected override void setStruct(GObject* obj)
235 	{
236 		super.setStruct(obj);
237 		gApplication = cast(GApplication*)obj;
238 	}
239 	
240 	// add the ActionGroup capabilities
241 	mixin ActionGroupT!(GApplication);
242 	
243 	// add the ActionMap capabilities
244 	mixin ActionMapT!(GApplication);
245 	
246 	/**
247 	 */
248 	int[string] connectedSignals;
249 	
250 	void delegate(Application)[] onActivateListeners;
251 	/**
252 	 * The ::activate signal is emitted on the primary instance when an
253 	 * activation occurs. See g_application_activate().
254 	 */
255 	void addOnActivate(void delegate(Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
256 	{
257 		if ( !("activate" in connectedSignals) )
258 		{
259 			Signals.connectData(
260 			getStruct(),
261 			"activate",
262 			cast(GCallback)&callBackActivate,
263 			cast(void*)this,
264 			null,
265 			connectFlags);
266 			connectedSignals["activate"] = 1;
267 		}
268 		onActivateListeners ~= dlg;
269 	}
270 	extern(C) static void callBackActivate(GApplication* applicationStruct, Application _application)
271 	{
272 		foreach ( void delegate(Application) dlg ; _application.onActivateListeners )
273 		{
274 			dlg(_application);
275 		}
276 	}
277 	
278 	gint delegate(GApplicationCommandLine*, Application)[] onCommandLineListeners;
279 	/**
280 	 * The ::command-line signal is emitted on the primary instance when
281 	 * a commandline is not handled locally. See g_application_run() and
282 	 * the GApplicationCommandLine documentation for more information.
283 	 */
284 	void addOnCommandLine(gint delegate(GApplicationCommandLine*, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
285 	{
286 		if ( !("command-line" in connectedSignals) )
287 		{
288 			Signals.connectData(
289 			getStruct(),
290 			"command-line",
291 			cast(GCallback)&callBackCommandLine,
292 			cast(void*)this,
293 			null,
294 			connectFlags);
295 			connectedSignals["command-line"] = 1;
296 		}
297 		onCommandLineListeners ~= dlg;
298 	}
299 	extern(C) static void callBackCommandLine(GApplication* applicationStruct, GApplicationCommandLine* commandLine, Application _application)
300 	{
301 		foreach ( gint delegate(GApplicationCommandLine*, Application) dlg ; _application.onCommandLineListeners )
302 		{
303 			dlg(commandLine, _application);
304 		}
305 	}
306 	
307 	void delegate(void*, gint, string, Application)[] onOpenListeners;
308 	/**
309 	 * The ::open signal is emitted on the primary instance when there are
310 	 * files to open. See g_application_open() for more information.
311 	 */
312 	void addOnOpen(void delegate(void*, gint, string, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
313 	{
314 		if ( !("open" in connectedSignals) )
315 		{
316 			Signals.connectData(
317 			getStruct(),
318 			"open",
319 			cast(GCallback)&callBackOpen,
320 			cast(void*)this,
321 			null,
322 			connectFlags);
323 			connectedSignals["open"] = 1;
324 		}
325 		onOpenListeners ~= dlg;
326 	}
327 	extern(C) static void callBackOpen(GApplication* applicationStruct, void* files, gint nFiles, gchar* hint, Application _application)
328 	{
329 		foreach ( void delegate(void*, gint, string, Application) dlg ; _application.onOpenListeners )
330 		{
331 			dlg(files, nFiles, Str.toString(hint), _application);
332 		}
333 	}
334 	
335 	void delegate(Application)[] onShutdownListeners;
336 	/**
337 	 * The ::shutdown signal is emitted only on the registered primary instance
338 	 * immediately after the main loop terminates.
339 	 */
340 	void addOnShutdown(void delegate(Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
341 	{
342 		if ( !("shutdown" in connectedSignals) )
343 		{
344 			Signals.connectData(
345 			getStruct(),
346 			"shutdown",
347 			cast(GCallback)&callBackShutdown,
348 			cast(void*)this,
349 			null,
350 			connectFlags);
351 			connectedSignals["shutdown"] = 1;
352 		}
353 		onShutdownListeners ~= dlg;
354 	}
355 	extern(C) static void callBackShutdown(GApplication* applicationStruct, Application _application)
356 	{
357 		foreach ( void delegate(Application) dlg ; _application.onShutdownListeners )
358 		{
359 			dlg(_application);
360 		}
361 	}
362 	
363 	void delegate(Application)[] onStartupListeners;
364 	/**
365 	 * The ::startup signal is emitted on the primary instance immediately
366 	 * after registration. See g_application_register().
367 	 */
368 	void addOnStartup(void delegate(Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
369 	{
370 		if ( !("startup" in connectedSignals) )
371 		{
372 			Signals.connectData(
373 			getStruct(),
374 			"startup",
375 			cast(GCallback)&callBackStartup,
376 			cast(void*)this,
377 			null,
378 			connectFlags);
379 			connectedSignals["startup"] = 1;
380 		}
381 		onStartupListeners ~= dlg;
382 	}
383 	extern(C) static void callBackStartup(GApplication* applicationStruct, Application _application)
384 	{
385 		foreach ( void delegate(Application) dlg ; _application.onStartupListeners )
386 		{
387 			dlg(_application);
388 		}
389 	}
390 	
391 	
392 	/**
393 	 * Checks if application_id is a valid application identifier.
394 	 * A valid ID is required for calls to g_application_new() and
395 	 * g_application_set_application_id().
396 	 * For convenience, the restrictions on application identifiers are
397 	 * Params:
398 	 * applicationId = a potential application identifier
399 	 * Returns: TRUE if application_id is valid
400 	 */
401 	public static int idIsValid(string applicationId)
402 	{
403 		// gboolean g_application_id_is_valid (const gchar *application_id);
404 		return g_application_id_is_valid(Str.toStringz(applicationId));
405 	}
406 	
407 	/**
408 	 * Creates a new GApplication instance.
409 	 * If non-NULL, the application id must be valid. See
410 	 * g_application_id_is_valid().
411 	 * If no application ID is given then some features of GApplication
412 	 * (most notably application uniqueness) will be disabled.
413 	 * Params:
414 	 * applicationId = the application id. [allow-none]
415 	 * flags = the application flags
416 	 * Throws: ConstructionException GTK+ fails to create the object.
417 	 */
418 	public this (string applicationId, GApplicationFlags flags)
419 	{
420 		// GApplication * g_application_new (const gchar *application_id,  GApplicationFlags flags);
421 		auto p = g_application_new(Str.toStringz(applicationId), flags);
422 		if(p is null)
423 		{
424 			throw new ConstructionException("null returned by g_application_new(Str.toStringz(applicationId), flags)");
425 		}
426 		this(cast(GApplication*) p);
427 	}
428 	
429 	/**
430 	 * Gets the unique identifier for application.
431 	 * Since 2.28
432 	 * Returns: the identifier for application, owned by application
433 	 */
434 	public string getApplicationId()
435 	{
436 		// const gchar * g_application_get_application_id (GApplication *application);
437 		return Str.toString(g_application_get_application_id(gApplication));
438 	}
439 	
440 	/**
441 	 * Sets the unique identifier for application.
442 	 * The application id can only be modified if application has not yet
443 	 * been registered.
444 	 * If non-NULL, the application id must be valid. See
445 	 * g_application_id_is_valid().
446 	 * Since 2.28
447 	 * Params:
448 	 * application = a GApplication
449 	 * applicationId = the identifier for application. [allow-none]
450 	 */
451 	public void setApplicationId(string applicationId)
452 	{
453 		// void g_application_set_application_id (GApplication *application,  const gchar *application_id);
454 		g_application_set_application_id(gApplication, Str.toStringz(applicationId));
455 	}
456 	
457 	/**
458 	 * Gets the current inactivity timeout for the application.
459 	 * This is the amount of time (in milliseconds) after the last call to
460 	 * g_application_release() before the application stops running.
461 	 * Since 2.28
462 	 * Returns: the timeout, in milliseconds
463 	 */
464 	public uint getInactivityTimeout()
465 	{
466 		// guint g_application_get_inactivity_timeout  (GApplication *application);
467 		return g_application_get_inactivity_timeout(gApplication);
468 	}
469 	
470 	/**
471 	 * Sets the current inactivity timeout for the application.
472 	 * This is the amount of time (in milliseconds) after the last call to
473 	 * g_application_release() before the application stops running.
474 	 * This call has no side effects of its own. The value set here is only
475 	 * used for next time g_application_release() drops the use count to
476 	 * zero. Any timeouts currently in progress are not impacted.
477 	 * Since 2.28
478 	 * Params:
479 	 * inactivityTimeout = the timeout, in milliseconds
480 	 */
481 	public void setInactivityTimeout(uint inactivityTimeout)
482 	{
483 		// void g_application_set_inactivity_timeout  (GApplication *application,  guint inactivity_timeout);
484 		g_application_set_inactivity_timeout(gApplication, inactivityTimeout);
485 	}
486 	
487 	/**
488 	 * Gets the flags for application.
489 	 * See GApplicationFlags.
490 	 * Since 2.28
491 	 * Returns: the flags for application
492 	 */
493 	public GApplicationFlags getFlags()
494 	{
495 		// GApplicationFlags g_application_get_flags (GApplication *application);
496 		return g_application_get_flags(gApplication);
497 	}
498 	
499 	/**
500 	 * Sets the flags for application.
501 	 * The flags can only be modified if application has not yet been
502 	 * registered.
503 	 * See GApplicationFlags.
504 	 * Since 2.28
505 	 * Params:
506 	 * flags = the flags for application
507 	 */
508 	public void setFlags(GApplicationFlags flags)
509 	{
510 		// void g_application_set_flags (GApplication *application,  GApplicationFlags flags);
511 		g_application_set_flags(gApplication, flags);
512 	}
513 	
514 	/**
515 	 * Gets the GDBusConnection being used by the application, or NULL.
516 	 * If GApplication is using its D-Bus backend then this function will
517 	 * return the GDBusConnection being used for uniqueness and
518 	 * communication with the desktop environment and other instances of the
519 	 * application.
520 	 * If GApplication is not using D-Bus then this function will return
521 	 * NULL. This includes the situation where the D-Bus backend would
522 	 * normally be in use but we were unable to connect to the bus.
523 	 * This function must not be called before the application has been
524 	 * registered. See g_application_get_is_registered().
525 	 * Since 2.34
526 	 * Returns: a GDBusConnection, or NULL. [transfer none]
527 	 */
528 	public DBusConnection getDbusConnection()
529 	{
530 		// GDBusConnection * g_application_get_dbus_connection (GApplication *application);
531 		auto p = g_application_get_dbus_connection(gApplication);
532 		
533 		if(p is null)
534 		{
535 			return null;
536 		}
537 		
538 		return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p);
539 	}
540 	
541 	/**
542 	 * Gets the D-Bus object path being used by the application, or NULL.
543 	 * If GApplication is using its D-Bus backend then this function will
544 	 * return the D-Bus object path that GApplication is using. If the
545 	 * application is the primary instance then there is an object published
546 	 * at this path. If the application is not the primary instance then
547 	 * the result of this function is undefined.
548 	 * If GApplication is not using D-Bus then this function will return
549 	 * NULL. This includes the situation where the D-Bus backend would
550 	 * normally be in use but we were unable to connect to the bus.
551 	 * This function must not be called before the application has been
552 	 * registered. See g_application_get_is_registered().
553 	 * Since 2.34
554 	 * Returns: the object path, or NULL
555 	 */
556 	public string getDbusObjectPath()
557 	{
558 		// const gchar * g_application_get_dbus_object_path (GApplication *application);
559 		return Str.toString(g_application_get_dbus_object_path(gApplication));
560 	}
561 	
562 	/**
563 	 * Warning
564 	 * g_application_set_action_group has been deprecated since version 2.32 and should not be used in newly-written code. Use the GActionMap interface instead. Never ever
565 	 * mix use of this API with use of GActionMap on the same application
566 	 * or things will go very badly wrong. This function is known to
567 	 * introduce buggy behaviour (ie: signals not emitted on changes to the
568 	 * action group), so you should really use GActionMap instead.
569 	 * This used to be how actions were associated with a GApplication.
570 	 * Now there is GActionMap for that.
571 	 * Since 2.28
572 	 * Params:
573 	 * actionGroup = a GActionGroup, or NULL. [allow-none]
574 	 */
575 	public void setActionGroup(GActionGroup* actionGroup)
576 	{
577 		// void g_application_set_action_group (GApplication *application,  GActionGroup *action_group);
578 		g_application_set_action_group(gApplication, actionGroup);
579 	}
580 	
581 	/**
582 	 * Checks if application is registered.
583 	 * An application is registered if g_application_register() has been
584 	 * successfully called.
585 	 * Since 2.28
586 	 * Returns: TRUE if application is registered
587 	 */
588 	public int getIsRegistered()
589 	{
590 		// gboolean g_application_get_is_registered (GApplication *application);
591 		return g_application_get_is_registered(gApplication);
592 	}
593 	
594 	/**
595 	 * Checks if application is remote.
596 	 * If application is remote then it means that another instance of
597 	 * application already exists (the 'primary' instance). Calls to
598 	 * perform actions on application will result in the actions being
599 	 * performed by the primary instance.
600 	 * The value of this property cannot be accessed before
601 	 * g_application_register() has been called. See
602 	 * g_application_get_is_registered().
603 	 * Since 2.28
604 	 * Returns: TRUE if application is remote
605 	 */
606 	public int getIsRemote()
607 	{
608 		// gboolean g_application_get_is_remote (GApplication *application);
609 		return g_application_get_is_remote(gApplication);
610 	}
611 	
612 	/**
613 	 * Attempts registration of the application.
614 	 * This is the point at which the application discovers if it is the
615 	 * primary instance or merely acting as a remote for an already-existing
616 	 * primary instance. This is implemented by attempting to acquire the
617 	 * application identifier as a unique bus name on the session bus using
618 	 * GDBus.
619 	 * If there is no application ID or if G_APPLICATION_NON_UNIQUE was
620 	 * given, then this process will always become the primary instance.
621 	 * Due to the internal architecture of GDBus, method calls can be
622 	 * dispatched at any time (even if a main loop is not running). For
623 	 * this reason, you must ensure that any object paths that you wish to
624 	 * register are registered before calling this function.
625 	 * If the application has already been registered then TRUE is
626 	 * returned with no work performed.
627 	 * The "startup" signal is emitted if registration succeeds
628 	 * and application is the primary instance (including the non-unique
629 	 * case).
630 	 * In the event of an error (such as cancellable being cancelled, or a
631 	 * failure to connect to the session bus), FALSE is returned and error
632 	 * is set appropriately.
633 	 * Note: the return value of this function is not an indicator that this
634 	 * instance is or is not the primary instance of the application. See
635 	 * g_application_get_is_remote() for that.
636 	 * Since 2.28
637 	 * Params:
638 	 * cancellable = a GCancellable, or NULL. [allow-none]
639 	 * Returns: TRUE if registration succeeded
640 	 * Throws: GException on failure.
641 	 */
642 	public int register(Cancellable cancellable)
643 	{
644 		// gboolean g_application_register (GApplication *application,  GCancellable *cancellable,  GError **error);
645 		GError* err = null;
646 		
647 		auto p = g_application_register(gApplication, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
648 		
649 		if (err !is null)
650 		{
651 			throw new GException( new ErrorG(err) );
652 		}
653 		
654 		return p;
655 	}
656 	
657 	/**
658 	 * Increases the use count of application.
659 	 * Use this function to indicate that the application has a reason to
660 	 * continue to run. For example, g_application_hold() is called by GTK+
661 	 * when a toplevel window is on the screen.
662 	 * To cancel the hold, call g_application_release().
663 	 */
664 	public void hold()
665 	{
666 		// void g_application_hold (GApplication *application);
667 		g_application_hold(gApplication);
668 	}
669 	
670 	/**
671 	 * Decrease the use count of application.
672 	 * When the use count reaches zero, the application will stop running.
673 	 * Never call this function except to cancel the effect of a previous
674 	 * call to g_application_hold().
675 	 */
676 	public void release()
677 	{
678 		// void g_application_release (GApplication *application);
679 		g_application_release(gApplication);
680 	}
681 	
682 	/**
683 	 * Immediately quits the application.
684 	 * Upon return to the mainloop, g_application_run() will return,
685 	 * calling only the 'shutdown' function before doing so.
686 	 * The hold count is ignored.
687 	 * The result of calling g_application_run() again after it returns is
688 	 * unspecified.
689 	 * Since 2.32
690 	 */
691 	public void quit()
692 	{
693 		// void g_application_quit (GApplication *application);
694 		g_application_quit(gApplication);
695 	}
696 	
697 	/**
698 	 * Activates the application.
699 	 * In essence, this results in the "activate" signal being
700 	 * emitted in the primary instance.
701 	 * The application must be registered before calling this function.
702 	 * Since 2.28
703 	 */
704 	public void activate()
705 	{
706 		// void g_application_activate (GApplication *application);
707 		g_application_activate(gApplication);
708 	}
709 	
710 	/**
711 	 * Opens the given files.
712 	 * In essence, this results in the "open" signal being emitted
713 	 * in the primary instance.
714 	 * n_files must be greater than zero.
715 	 * hint is simply passed through to the ::open signal. It is
716 	 * intended to be used by applications that have multiple modes for
717 	 * opening files (eg: "view" vs "edit", etc). Unless you have a need
718 	 * for this functionality, you should use "".
719 	 * The application must be registered before calling this function
720 	 * and it must have the G_APPLICATION_HANDLES_OPEN flag set.
721 	 * Since 2.28
722 	 * Params:
723 	 * files = an array of GFiles to open. [array length=n_files]
724 	 * hint = a hint (or ""), but never NULL
725 	 */
726 	public void open(File[] files, string hint)
727 	{
728 		// void g_application_open (GApplication *application,  GFile **files,  gint n_files,  const gchar *hint);
729 		
730 		GFile*[] filesArray = new GFile*[files.length];
731 		for ( int i = 0; i < files.length ; i++ )
732 		{
733 			filesArray[i] = files[i].getFileStruct();
734 		}
735 		
736 		g_application_open(gApplication, filesArray.ptr, cast(int) files.length, Str.toStringz(hint));
737 	}
738 	
739 	/**
740 	 * Runs the application.
741 	 * This function is intended to be run from main() and its return value
742 	 * is intended to be returned by main(). Although you are expected to pass
743 	 * the argc, argv parameters from main() to this function, it is possible
744 	 * to pass NULL if argv is not available or commandline handling is not
745 	 * required.
746 	 * First, the local_command_line() virtual function is invoked.
747 	 * This function always runs on the local instance. It gets passed a pointer
748 	 * to a NULL-terminated copy of argv and is expected to remove the arguments
749 	 * that it handled (shifting up remaining arguments). See
750 	 *  Example 23, “Split commandline handling” for an example of
751 	 * parsing argv manually. Alternatively, you may use the GOptionContext API,
752 	 * after setting argc = g_strv_length (argv);.
753 	 * The last argument to local_command_line() is a pointer to the status
754 	 * variable which can used to set the exit status that is returned from
755 	 * g_application_run().
756 	 * If local_command_line() returns TRUE, the command line is expected
757 	 * to be completely handled, including possibly registering as the primary
758 	 * instance, calling g_application_activate() or g_application_open(), etc.
759 	 * If local_command_line() returns FALSE then the application is registered
760 	 * and the "command-line" signal is emitted in the primary
761 	 * instance (which may or may not be this instance). The signal handler
762 	 * gets passed a GApplicationCommandLine object that (among other things)
763 	 * contains the remaining commandline arguments that have not been handled
764 	 * by local_command_line().
765 	 * If the application has the G_APPLICATION_HANDLES_COMMAND_LINE
766 	 * flag set then the default implementation of local_command_line()
767 	 * always returns FALSE immediately, resulting in the commandline
768 	 * always being handled in the primary instance.
769 	 * Otherwise, the default implementation of local_command_line() tries
770 	 * to do a couple of things that are probably reasonable for most
771 	 * applications. First, g_application_register() is called to attempt
772 	 * to register the application. If that works, then the command line
773 	 * arguments are inspected. If no commandline arguments are given, then
774 	 * g_application_activate() is called. If commandline arguments are
775 	 * given and the G_APPLICATION_HANDLES_OPEN flag is set then they
776 	 * are assumed to be filenames and g_application_open() is called.
777 	 * If you need to handle commandline arguments that are not filenames,
778 	 * and you don't mind commandline handling to happen in the primary
779 	 * instance, you should set G_APPLICATION_HANDLES_COMMAND_LINE and
780 	 * process the commandline arguments in your "command-line"
781 	 * signal handler, either manually or using the GOptionContext API.
782 	 * If you are interested in doing more complicated local handling of the
783 	 * commandline then you should implement your own GApplication subclass
784 	 * and override local_command_line(). In this case, you most likely want
785 	 * to return TRUE from your local_command_line() implementation to
786 	 * suppress the default handling. See
787 	 *  Example 23, “Split commandline handling” for an example.
788 	 * If, after the above is done, the use count of the application is zero
789 	 * then the exit status is returned immediately. If the use count is
790 	 * non-zero then the default main context is iterated until the use count
791 	 * falls to zero, at which point 0 is returned.
792 	 * If the G_APPLICATION_IS_SERVICE flag is set, then the service will
793 	 * run for as much as 10 seconds with a use count of zero while waiting
794 	 * for the message that caused the activation to arrive. After that,
795 	 * if the use count falls to zero the application will exit immediately,
796 	 * except in the case that g_application_set_inactivity_timeout() is in
797 	 * use.
798 	 * This function sets the prgname (g_set_prgname()), if not already set,
799 	 * to the basename of argv[0]. Since 2.38, if G_APPLICATION_IS_SERVICE
800 	 * is specified, the prgname is set to the application ID. The main
801 	 * impact of this is is that the wmclass of windows created by Gtk+ will
802 	 * be set accordingly, which helps the window manager determine which
803 	 * application is showing the window.
804 	 * Since 2.28
805 	 * Params:
806 	 * argv = the argv from main(), or NULL. [array length=argc][allow-none]
807 	 * Returns: the exit status
808 	 */
809 	public int run(string[] argv)
810 	{
811 		// int g_application_run (GApplication *application,  int argc,  char **argv);
812 		return g_application_run(gApplication, cast(int) argv.length, Str.toStringzArray(argv));
813 	}
814 	
815 	/**
816 	 * Sets or unsets the default application for the process, as returned
817 	 * by g_application_get_default().
818 	 * This function does not take its own reference on application. If
819 	 * application is destroyed then the default application will revert
820 	 * back to NULL.
821 	 * Since 2.32
822 	 */
823 	public void setDefault()
824 	{
825 		// void g_application_set_default (GApplication *application);
826 		g_application_set_default(gApplication);
827 	}
828 	
829 	/**
830 	 * Returns the default GApplication instance for this process.
831 	 * Normally there is only one GApplication per process and it becomes
832 	 * the default when it is created. You can exercise more control over
833 	 * this by using g_application_set_default().
834 	 * If there is no default application then NULL is returned.
835 	 * Since 2.32
836 	 * Returns: the default application for this process, or NULL. [transfer none]
837 	 */
838 	public static Application getDefault()
839 	{
840 		// GApplication * g_application_get_default (void);
841 		auto p = g_application_get_default();
842 		
843 		if(p is null)
844 		{
845 			return null;
846 		}
847 		
848 		return ObjectG.getDObject!(Application)(cast(GApplication*) p);
849 	}
850 	
851 	/**
852 	 * Increases the busy count of application.
853 	 * Use this function to indicate that the application is busy, for instance
854 	 * while a long running operation is pending.
855 	 * The busy state will be exposed to other processes, so a session shell will
856 	 * use that information to indicate the state to the user (e.g. with a
857 	 * spinner).
858 	 * To cancel the busy indication, use g_application_unmark_busy().
859 	 * Since 2.38
860 	 */
861 	public void markBusy()
862 	{
863 		// void g_application_mark_busy (GApplication *application);
864 		g_application_mark_busy(gApplication);
865 	}
866 	
867 	/**
868 	 * Decreases the busy count of application.
869 	 * When the busy count reaches zero, the new state will be propagated
870 	 * to other processes.
871 	 * This function must only be called to cancel the effect of a previous
872 	 * call to g_application_mark_busy().
873 	 * Since 2.38
874 	 */
875 	public void unmarkBusy()
876 	{
877 		// void g_application_unmark_busy (GApplication *application);
878 		g_application_unmark_busy(gApplication);
879 	}
880 }