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 glib.ConstructionException;
28 private import glib.ListG;
29 private import gobject.ObjectG;
30 private import gtk.Window;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 
34 
35 /**
36  * `GtkWindowGroup` makes group of windows behave like separate applications.
37  * 
38  * It achieves this by limiting the effect of GTK grabs and modality
39  * to windows in the same group.
40  * 
41  * A window can be a member in at most one window group at a time.
42  * Windows that have not been explicitly assigned to a group are
43  * implicitly treated like windows of the default window group.
44  * 
45  * `GtkWindowGroup` objects are referenced by each window in the group,
46  * so once you have added all windows to a `GtkWindowGroup`, you can drop
47  * the initial reference to the window group with g_object_unref(). If the
48  * windows in the window group are subsequently destroyed, then they will
49  * be removed from the window group and drop their references on the window
50  * group; when all window have been removed, the window group will be
51  * freed.
52  */
53 public class WindowGroup : ObjectG
54 {
55 	/** the main Gtk struct */
56 	protected GtkWindowGroup* gtkWindowGroup;
57 
58 	/** Get the main Gtk struct */
59 	public GtkWindowGroup* getWindowGroupStruct(bool transferOwnership = false)
60 	{
61 		if (transferOwnership)
62 			ownedRef = false;
63 		return gtkWindowGroup;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)gtkWindowGroup;
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GtkWindowGroup* gtkWindowGroup, bool ownedRef = false)
76 	{
77 		this.gtkWindowGroup = gtkWindowGroup;
78 		super(cast(GObject*)gtkWindowGroup, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return gtk_window_group_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new `GtkWindowGroup` object.
90 	 *
91 	 * Modality of windows only affects windows
92 	 * 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 a list of the `GtkWindows` that belong to @window_group.
123 	 *
124 	 * Returns: A
125 	 *     newly-allocated list of windows inside the group.
126 	 */
127 	public ListG listWindows()
128 	{
129 		auto __p = gtk_window_group_list_windows(gtkWindowGroup);
130 
131 		if(__p is null)
132 		{
133 			return null;
134 		}
135 
136 		return new ListG(cast(GList*) __p);
137 	}
138 
139 	/**
140 	 * Removes a window from a `GtkWindowGroup`.
141 	 *
142 	 * Params:
143 	 *     window = the `GtkWindow` to remove
144 	 */
145 	public void removeWindow(Window window)
146 	{
147 		gtk_window_group_remove_window(gtkWindowGroup, (window is null) ? null : window.getWindowStruct());
148 	}
149 }