1 /*
2  * This file is part of d-dazzle.
3  *
4  * d-dazzle 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  * d-dazzle 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 d-dazzle; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 module dazzle.DockManager;
20 
21 private import dazzle.DockIF;
22 private import dazzle.c.functions;
23 public  import dazzle.c.types;
24 private import glib.ConstructionException;
25 private import gobject.ObjectG;
26 private import gobject.Signals;
27 private import std.algorithm;
28 
29 
30 /** */
31 public class DockManager : ObjectG
32 {
33 	/** the main Gtk struct */
34 	protected DzlDockManager* dzlDockManager;
35 
36 	/** Get the main Gtk struct */
37 	public DzlDockManager* getDockManagerStruct(bool transferOwnership = false)
38 	{
39 		if (transferOwnership)
40 			ownedRef = false;
41 		return dzlDockManager;
42 	}
43 
44 	/** the main Gtk struct as a void* */
45 	protected override void* getStruct()
46 	{
47 		return cast(void*)dzlDockManager;
48 	}
49 
50 	/**
51 	 * Sets our main struct and passes it to the parent class.
52 	 */
53 	public this (DzlDockManager* dzlDockManager, bool ownedRef = false)
54 	{
55 		this.dzlDockManager = dzlDockManager;
56 		super(cast(GObject*)dzlDockManager, ownedRef);
57 	}
58 
59 
60 	/** */
61 	public static GType getType()
62 	{
63 		return dzl_dock_manager_get_type();
64 	}
65 
66 	/** */
67 	public this()
68 	{
69 		auto p = dzl_dock_manager_new();
70 
71 		if(p is null)
72 		{
73 			throw new ConstructionException("null returned by new");
74 		}
75 
76 		this(cast(DzlDockManager*) p, true);
77 	}
78 
79 	/**
80 	 * Requests that the transient grab monitoring stop until
81 	 * dzl_dock_manager_unpause_grabs() is called.
82 	 *
83 	 * This might be useful while setting up UI so that you don't focus
84 	 * something unexpectedly.
85 	 *
86 	 * This function may be called multiple times and after an equivalent
87 	 * number of calls to dzl_dock_manager_unpause_grabs(), transient
88 	 * grab monitoring will continue.
89 	 *
90 	 * Since: 3.26
91 	 */
92 	public void pauseGrabs()
93 	{
94 		dzl_dock_manager_pause_grabs(dzlDockManager);
95 	}
96 
97 	/** */
98 	public void registerDock(DockIF dock)
99 	{
100 		dzl_dock_manager_register_dock(dzlDockManager, (dock is null) ? null : dock.getDockStruct());
101 	}
102 
103 	/** */
104 	public void releaseTransientGrab()
105 	{
106 		dzl_dock_manager_release_transient_grab(dzlDockManager);
107 	}
108 
109 	/**
110 	 * Unpauses a previous call to dzl_dock_manager_pause_grabs().
111 	 *
112 	 * Once the pause count returns to zero, transient grab monitoring
113 	 * will be restored.
114 	 *
115 	 * Since: 3.26
116 	 */
117 	public void unpauseGrabs()
118 	{
119 		dzl_dock_manager_unpause_grabs(dzlDockManager);
120 	}
121 
122 	/** */
123 	public void unregisterDock(DockIF dock)
124 	{
125 		dzl_dock_manager_unregister_dock(dzlDockManager, (dock is null) ? null : dock.getDockStruct());
126 	}
127 
128 	/** */
129 	gulong addOnRegisterDock(void delegate(DockIF, DockManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
130 	{
131 		return Signals.connect(this, "register-dock", dlg, connectFlags ^ ConnectFlags.SWAPPED);
132 	}
133 
134 	/** */
135 	gulong addOnUnregisterDock(void delegate(DockIF, DockManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
136 	{
137 		return Signals.connect(this, "unregister-dock", dlg, connectFlags ^ ConnectFlags.SWAPPED);
138 	}
139 }