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 /** 75 * Sets our main struct and passes it to the parent class. 76 */ 77 public this (GtkWindowGroup* gtkWindowGroup, bool ownedRef = false) 78 { 79 this.gtkWindowGroup = gtkWindowGroup; 80 super(cast(GObject*)gtkWindowGroup, ownedRef); 81 } 82 83 84 /** */ 85 public static GType getType() 86 { 87 return gtk_window_group_get_type(); 88 } 89 90 /** 91 * Creates a new #GtkWindowGroup object. Grabs added with 92 * gtk_grab_add() only affect windows within the same #GtkWindowGroup. 93 * 94 * Returns: a new #GtkWindowGroup. 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this() 99 { 100 auto p = gtk_window_group_new(); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GtkWindowGroup*) p, true); 108 } 109 110 /** 111 * Adds a window to a #GtkWindowGroup. 112 * 113 * Params: 114 * window = the #GtkWindow to add 115 */ 116 public void addWindow(Window window) 117 { 118 gtk_window_group_add_window(gtkWindowGroup, (window is null) ? null : window.getWindowStruct()); 119 } 120 121 /** 122 * Returns the current grab widget for @device, or %NULL if none. 123 * 124 * Params: 125 * device = a #GdkDevice 126 * 127 * Returns: The grab widget, or %NULL 128 * 129 * Since: 3.0 130 */ 131 public Widget getCurrentDeviceGrab(Device device) 132 { 133 auto p = gtk_window_group_get_current_device_grab(gtkWindowGroup, (device is null) ? null : device.getDeviceStruct()); 134 135 if(p is null) 136 { 137 return null; 138 } 139 140 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 141 } 142 143 /** 144 * Gets the current grab widget of the given group, 145 * see gtk_grab_add(). 146 * 147 * Returns: the current grab widget of the group 148 * 149 * Since: 2.22 150 */ 151 public Widget getCurrentGrab() 152 { 153 auto p = gtk_window_group_get_current_grab(gtkWindowGroup); 154 155 if(p is null) 156 { 157 return null; 158 } 159 160 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 161 } 162 163 /** 164 * Returns a list of the #GtkWindows that belong to @window_group. 165 * 166 * Returns: A 167 * newly-allocated list of windows inside the group. 168 * 169 * Since: 2.14 170 */ 171 public ListG listWindows() 172 { 173 auto p = gtk_window_group_list_windows(gtkWindowGroup); 174 175 if(p is null) 176 { 177 return null; 178 } 179 180 return new ListG(cast(GList*) p); 181 } 182 183 /** 184 * Removes a window from a #GtkWindowGroup. 185 * 186 * Params: 187 * window = the #GtkWindow to remove 188 */ 189 public void removeWindow(Window window) 190 { 191 gtk_window_group_remove_window(gtkWindowGroup, (window is null) ? null : window.getWindowStruct()); 192 } 193 }