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  = GdkDisplayManager.html
27  * outPack = gdk
28  * outFile = DisplayManager
29  * strct   = GdkDisplayManager
30  * realStrct=
31  * ctorStrct=
32  * clss    = DisplayManager
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_display_manager_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ListSG
48  * 	- gdk.Display
49  * structWrap:
50  * 	- GSList* -> ListSG
51  * 	- GdkDisplay* -> Display
52  * 	- GdkDisplayManager* -> DisplayManager
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gdk.DisplayManager;
59 
60 public  import gtkc.gdktypes;
61 
62 private import gtkc.gdk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 private import gobject.Signals;
67 public  import gtkc.gdktypes;
68 private import glib.Str;
69 private import glib.ListSG;
70 private import gdk.Display;
71 
72 
73 private import gobject.ObjectG;
74 
75 /**
76  * The purpose of the GdkDisplayManager singleton object is to offer
77  * notification when displays appear or disappear or the default display
78  * changes.
79  *
80  * You can use gdk_display_manager_get() to obtain the GdkDisplayManager
81  * singleton, but that should be rarely necessary. Typically, initializing
82  * GTK+ opens a display that you can work with without ever accessing the
83  * GdkDisplayManager.
84  *
85  * The GDK library can be built with support for multiple backends.
86  * The GdkDisplayManager object determines which backend is used
87  * at runtime.
88  *
89  * When writing backend-specific code that is supposed to work with
90  * multiple GDK backends, you have to consider both compile time and
91  * runtime. At compile time, use the GDK_WINDOWING_X11, GDK_WINDOWING_WIN32
92  * macros, etc. to find out which backends are present in the GDK library
93  * you are building your application against. At runtime, use type-check
94  * macros like GDK_IS_X11_DISPLAY() to find out which backend is in use:
95  *
96  * $(DDOC_COMMENT example)
97  */
98 public class DisplayManager : ObjectG
99 {
100 	
101 	/** the main Gtk struct */
102 	protected GdkDisplayManager* gdkDisplayManager;
103 	
104 	
105 	/** Get the main Gtk struct */
106 	public GdkDisplayManager* getDisplayManagerStruct()
107 	{
108 		return gdkDisplayManager;
109 	}
110 	
111 	
112 	/** the main Gtk struct as a void* */
113 	protected override void* getStruct()
114 	{
115 		return cast(void*)gdkDisplayManager;
116 	}
117 	
118 	/**
119 	 * Sets our main struct and passes it to the parent class
120 	 */
121 	public this (GdkDisplayManager* gdkDisplayManager)
122 	{
123 		super(cast(GObject*)gdkDisplayManager);
124 		this.gdkDisplayManager = gdkDisplayManager;
125 	}
126 	
127 	protected override void setStruct(GObject* obj)
128 	{
129 		super.setStruct(obj);
130 		gdkDisplayManager = cast(GdkDisplayManager*)obj;
131 	}
132 	
133 	/**
134 	 */
135 	int[string] connectedSignals;
136 	
137 	void delegate(Display, DisplayManager)[] onDisplayOpenedListeners;
138 	/**
139 	 * The ::display-opened signal is emitted when a display is opened.
140 	 * Since 2.2
141 	 */
142 	void addOnDisplayOpened(void delegate(Display, DisplayManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
143 	{
144 		if ( !("display-opened" in connectedSignals) )
145 		{
146 			Signals.connectData(
147 			getStruct(),
148 			"display-opened",
149 			cast(GCallback)&callBackDisplayOpened,
150 			cast(void*)this,
151 			null,
152 			connectFlags);
153 			connectedSignals["display-opened"] = 1;
154 		}
155 		onDisplayOpenedListeners ~= dlg;
156 	}
157 	extern(C) static void callBackDisplayOpened(GdkDisplayManager* managerStruct, GdkDisplay* display, DisplayManager _displayManager)
158 	{
159 		foreach ( void delegate(Display, DisplayManager) dlg ; _displayManager.onDisplayOpenedListeners )
160 		{
161 			dlg(ObjectG.getDObject!(Display)(display), _displayManager);
162 		}
163 	}
164 	
165 	
166 	/**
167 	 * Gets the singleton GdkDisplayManager object.
168 	 * When called for the first time, this function consults the
169 	 * GDK_BACKEND environment variable to find out which
170 	 * of the supported GDK backends to use (in case GDK has been compiled
171 	 * with multiple backends). Applications can use gdk_set_allowed_backends()
172 	 * to limit what backends can be used.
173 	 * Since 2.2
174 	 * Returns: The global GdkDisplayManager singleton; gdk_parse_args(), gdk_init(), or gdk_init_check() must have been called first. [transfer none]
175 	 */
176 	public static DisplayManager get()
177 	{
178 		// GdkDisplayManager * gdk_display_manager_get (void);
179 		auto p = gdk_display_manager_get();
180 		
181 		if(p is null)
182 		{
183 			return null;
184 		}
185 		
186 		return ObjectG.getDObject!(DisplayManager)(cast(GdkDisplayManager*) p);
187 	}
188 	
189 	/**
190 	 * Gets the default GdkDisplay.
191 	 * Since 2.2
192 	 * Returns: a GdkDisplay, or NULL if there is no default display. [transfer none]
193 	 */
194 	public Display getDefaultDisplay()
195 	{
196 		// GdkDisplay * gdk_display_manager_get_default_display  (GdkDisplayManager *manager);
197 		auto p = gdk_display_manager_get_default_display(gdkDisplayManager);
198 		
199 		if(p is null)
200 		{
201 			return null;
202 		}
203 		
204 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p);
205 	}
206 	
207 	/**
208 	 * Sets display as the default display.
209 	 * Since 2.2
210 	 * Params:
211 	 * display = a GdkDisplay
212 	 */
213 	public void setDefaultDisplay(Display display)
214 	{
215 		// void gdk_display_manager_set_default_display  (GdkDisplayManager *manager,  GdkDisplay *display);
216 		gdk_display_manager_set_default_display(gdkDisplayManager, (display is null) ? null : display.getDisplayStruct());
217 	}
218 	
219 	/**
220 	 * List all currently open displays.
221 	 * Since 2.2
222 	 * Returns: a newly allocated GSList of GdkDisplay objects. Free with g_slist_free() when you are done with it. [transfer container][element-type GdkDisplay]
223 	 */
224 	public ListSG listDisplays()
225 	{
226 		// GSList * gdk_display_manager_list_displays (GdkDisplayManager *manager);
227 		auto p = gdk_display_manager_list_displays(gdkDisplayManager);
228 		
229 		if(p is null)
230 		{
231 			return null;
232 		}
233 		
234 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
235 	}
236 	
237 	/**
238 	 * Opens a display.
239 	 * Params:
240 	 * name = the name of the display to open
241 	 * Returns: a GdkDisplay, or NULL if the display could not be opened. [transfer none] Since 3.0
242 	 */
243 	public Display openDisplay(string name)
244 	{
245 		// GdkDisplay * gdk_display_manager_open_display (GdkDisplayManager *manager,  const gchar *name);
246 		auto p = gdk_display_manager_open_display(gdkDisplayManager, Str.toStringz(name));
247 		
248 		if(p is null)
249 		{
250 			return null;
251 		}
252 		
253 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p);
254 	}
255 }