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