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