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