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