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