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 gtk.WindowGroup; 26 27 private import gdk.Device; 28 private import glib.ConstructionException; 29 private import glib.ListG; 30 private import gobject.ObjectG; 31 private import gtk.Widget; 32 private import gtk.Window; 33 private import gtk.c.functions; 34 public import gtk.c.types; 35 public import gtkc.gtktypes; 36 37 38 /** 39 * A #GtkWindowGroup restricts the effect of grabs to windows 40 * in the same group, thereby making window groups almost behave 41 * like separate applications. 42 * 43 * A window can be a member in at most one window group at a time. 44 * Windows that have not been explicitly assigned to a group are 45 * implicitly treated like windows of the default window group. 46 * 47 * GtkWindowGroup objects are referenced by each window in the group, 48 * so once you have added all windows to a GtkWindowGroup, you can drop 49 * the initial reference to the window group with g_object_unref(). If the 50 * windows in the window group are subsequently destroyed, then they will 51 * be removed from the window group and drop their references on the window 52 * group; when all window have been removed, the window group will be 53 * freed. 54 */ 55 public class WindowGroup : ObjectG 56 { 57 /** the main Gtk struct */ 58 protected GtkWindowGroup* gtkWindowGroup; 59 60 /** Get the main Gtk struct */ 61 public GtkWindowGroup* getWindowGroupStruct(bool transferOwnership = false) 62 { 63 if (transferOwnership) 64 ownedRef = false; 65 return gtkWindowGroup; 66 } 67 68 /** the main Gtk struct as a void* */ 69 protected override void* getStruct() 70 { 71 return cast(void*)gtkWindowGroup; 72 } 73 74 protected override void setStruct(GObject* obj) 75 { 76 gtkWindowGroup = cast(GtkWindowGroup*)obj; 77 super.setStruct(obj); 78 } 79 80 /** 81 * Sets our main struct and passes it to the parent class. 82 */ 83 public this (GtkWindowGroup* gtkWindowGroup, bool ownedRef = false) 84 { 85 this.gtkWindowGroup = gtkWindowGroup; 86 super(cast(GObject*)gtkWindowGroup, ownedRef); 87 } 88 89 90 /** */ 91 public static GType getType() 92 { 93 return gtk_window_group_get_type(); 94 } 95 96 /** 97 * Creates a new #GtkWindowGroup object. Grabs added with 98 * gtk_grab_add() only affect windows within the same #GtkWindowGroup. 99 * 100 * Returns: a new #GtkWindowGroup. 101 * 102 * Throws: ConstructionException GTK+ fails to create the object. 103 */ 104 public this() 105 { 106 auto p = gtk_window_group_new(); 107 108 if(p is null) 109 { 110 throw new ConstructionException("null returned by new"); 111 } 112 113 this(cast(GtkWindowGroup*) p, true); 114 } 115 116 /** 117 * Adds a window to a #GtkWindowGroup. 118 * 119 * Params: 120 * window = the #GtkWindow to add 121 */ 122 public void addWindow(Window window) 123 { 124 gtk_window_group_add_window(gtkWindowGroup, (window is null) ? null : window.getWindowStruct()); 125 } 126 127 /** 128 * Returns the current grab widget for @device, or %NULL if none. 129 * 130 * Params: 131 * device = a #GdkDevice 132 * 133 * Returns: The grab widget, or %NULL 134 * 135 * Since: 3.0 136 */ 137 public Widget getCurrentDeviceGrab(Device device) 138 { 139 auto p = gtk_window_group_get_current_device_grab(gtkWindowGroup, (device is null) ? null : device.getDeviceStruct()); 140 141 if(p is null) 142 { 143 return null; 144 } 145 146 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 147 } 148 149 /** 150 * Gets the current grab widget of the given group, 151 * see gtk_grab_add(). 152 * 153 * Returns: the current grab widget of the group 154 * 155 * Since: 2.22 156 */ 157 public Widget getCurrentGrab() 158 { 159 auto p = gtk_window_group_get_current_grab(gtkWindowGroup); 160 161 if(p is null) 162 { 163 return null; 164 } 165 166 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 167 } 168 169 /** 170 * Returns a list of the #GtkWindows that belong to @window_group. 171 * 172 * Returns: A 173 * newly-allocated list of windows inside the group. 174 * 175 * Since: 2.14 176 */ 177 public ListG listWindows() 178 { 179 auto p = gtk_window_group_list_windows(gtkWindowGroup); 180 181 if(p is null) 182 { 183 return null; 184 } 185 186 return new ListG(cast(GList*) p); 187 } 188 189 /** 190 * Removes a window from a #GtkWindowGroup. 191 * 192 * Params: 193 * window = the #GtkWindow to remove 194 */ 195 public void removeWindow(Window window) 196 { 197 gtk_window_group_remove_window(gtkWindowGroup, (window is null) ? null : window.getWindowStruct()); 198 } 199 }