1 /*
2  * This file is part of d-handy.
3  *
4  * d-handy 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  * d-handy 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 d-handy; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 module handy.ViewSwitcher;
20 
21 private import glib.ConstructionException;
22 private import gobject.ObjectG;
23 private import gtk.Bin;
24 private import gtk.BuildableIF;
25 private import gtk.BuildableT;
26 private import gtk.Stack;
27 private import gtk.Widget;
28 private import handy.c.functions;
29 public  import handy.c.types;
30 
31 
32 /** */
33 public class ViewSwitcher : Bin
34 {
35 	/** the main Gtk struct */
36 	protected HdyViewSwitcher* hdyViewSwitcher;
37 
38 	/** Get the main Gtk struct */
39 	public HdyViewSwitcher* getViewSwitcherStruct(bool transferOwnership = false)
40 	{
41 		if (transferOwnership)
42 			ownedRef = false;
43 		return hdyViewSwitcher;
44 	}
45 
46 	/** the main Gtk struct as a void* */
47 	protected override void* getStruct()
48 	{
49 		return cast(void*)hdyViewSwitcher;
50 	}
51 
52 	/**
53 	 * Sets our main struct and passes it to the parent class.
54 	 */
55 	public this (HdyViewSwitcher* hdyViewSwitcher, bool ownedRef = false)
56 	{
57 		this.hdyViewSwitcher = hdyViewSwitcher;
58 		super(cast(GtkBin*)hdyViewSwitcher, ownedRef);
59 	}
60 
61 
62 	/** */
63 	public static GType getType()
64 	{
65 		return hdy_view_switcher_get_type();
66 	}
67 
68 	/**
69 	 * Creates a new #HdyViewSwitcher widget.
70 	 *
71 	 * Returns: a new #HdyViewSwitcher
72 	 *
73 	 * Since: 0.0.10
74 	 *
75 	 * Throws: ConstructionException GTK+ fails to create the object.
76 	 */
77 	public this()
78 	{
79 		auto __p = hdy_view_switcher_new();
80 
81 		if(__p is null)
82 		{
83 			throw new ConstructionException("null returned by new");
84 		}
85 
86 		this(cast(HdyViewSwitcher*) __p);
87 	}
88 
89 	/**
90 	 * Get the ellipsizing position of the narrow mode label. See
91 	 * hdy_view_switcher_set_narrow_ellipsize().
92 	 *
93 	 * Returns: #PangoEllipsizeMode
94 	 *
95 	 * Since: 0.0.10
96 	 */
97 	public PangoEllipsizeMode getNarrowEllipsize()
98 	{
99 		return hdy_view_switcher_get_narrow_ellipsize(hdyViewSwitcher);
100 	}
101 
102 	/**
103 	 * Gets the policy of @self.
104 	 *
105 	 * Returns: the policy of @self
106 	 *
107 	 * Since: 0.0.10
108 	 */
109 	public HdyViewSwitcherPolicy getPolicy()
110 	{
111 		return hdy_view_switcher_get_policy(hdyViewSwitcher);
112 	}
113 
114 	/**
115 	 * Get the #GtkStack being controlled by the #HdyViewSwitcher.
116 	 *
117 	 * See: hdy_view_switcher_set_stack()
118 	 *
119 	 * Returns: the #GtkStack, or %NULL if none has been set
120 	 *
121 	 * Since: 0.0.10
122 	 */
123 	public Stack getStack()
124 	{
125 		auto __p = hdy_view_switcher_get_stack(hdyViewSwitcher);
126 
127 		if(__p is null)
128 		{
129 			return null;
130 		}
131 
132 		return ObjectG.getDObject!(Stack)(cast(GtkStack*) __p);
133 	}
134 
135 	/**
136 	 * Set the mode used to ellipsize the text in narrow mode if there is not
137 	 * enough space to render the entire string.
138 	 *
139 	 * Params:
140 	 *     mode = a #PangoEllipsizeMode
141 	 *
142 	 * Since: 0.0.10
143 	 */
144 	public void setNarrowEllipsize(PangoEllipsizeMode mode)
145 	{
146 		hdy_view_switcher_set_narrow_ellipsize(hdyViewSwitcher, mode);
147 	}
148 
149 	/**
150 	 * Sets the policy of @self.
151 	 *
152 	 * Params:
153 	 *     policy = the new policy
154 	 *
155 	 * Since: 0.0.10
156 	 */
157 	public void setPolicy(HdyViewSwitcherPolicy policy)
158 	{
159 		hdy_view_switcher_set_policy(hdyViewSwitcher, policy);
160 	}
161 
162 	/**
163 	 * Sets the #GtkStack to control.
164 	 *
165 	 * Params:
166 	 *     stack = a #GtkStack
167 	 *
168 	 * Since: 0.0.10
169 	 */
170 	public void setStack(Stack stack)
171 	{
172 		hdy_view_switcher_set_stack(hdyViewSwitcher, (stack is null) ? null : stack.getStackStruct());
173 	}
174 }