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