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.PreferencesWindow;
20 
21 private import glib.ConstructionException;
22 private import gobject.ObjectG;
23 private import gtk.Widget;
24 private import handy.Window;
25 private import handy.c.functions;
26 public  import handy.c.types;
27 
28 
29 /** */
30 public class PreferencesWindow : Window
31 {
32 	/** the main Gtk struct */
33 	protected HdyPreferencesWindow* hdyPreferencesWindow;
34 
35 	/** Get the main Gtk struct */
36 	public HdyPreferencesWindow* getPreferencesWindowStruct(bool transferOwnership = false)
37 	{
38 		if (transferOwnership)
39 			ownedRef = false;
40 		return hdyPreferencesWindow;
41 	}
42 
43 	/** the main Gtk struct as a void* */
44 	protected override void* getStruct()
45 	{
46 		return cast(void*)hdyPreferencesWindow;
47 	}
48 
49 	/**
50 	 * Sets our main struct and passes it to the parent class.
51 	 */
52 	public this (HdyPreferencesWindow* hdyPreferencesWindow, bool ownedRef = false)
53 	{
54 		this.hdyPreferencesWindow = hdyPreferencesWindow;
55 		super(cast(HdyWindow*)hdyPreferencesWindow, ownedRef);
56 	}
57 
58 
59 	/** */
60 	public static GType getType()
61 	{
62 		return hdy_preferences_window_get_type();
63 	}
64 
65 	/**
66 	 * Creates a new #HdyPreferencesWindow.
67 	 *
68 	 * Returns: a new #HdyPreferencesWindow
69 	 *
70 	 * Since: 0.0.10
71 	 *
72 	 * Throws: ConstructionException GTK+ fails to create the object.
73 	 */
74 	public this()
75 	{
76 		auto __p = hdy_preferences_window_new();
77 
78 		if(__p is null)
79 		{
80 			throw new ConstructionException("null returned by new");
81 		}
82 
83 		this(cast(HdyPreferencesWindow*) __p);
84 	}
85 
86 	/**
87 	 * Closes the current subpage to return back to the preferences, if there is no
88 	 * presented subpage, this does nothing.
89 	 *
90 	 * Since: 1.0
91 	 */
92 	public void closeSubpage()
93 	{
94 		hdy_preferences_window_close_subpage(hdyPreferencesWindow);
95 	}
96 
97 	/**
98 	 * Returns whether or not @self allows switching from a subpage to the
99 	 * preferences via a swipe gesture.
100 	 *
101 	 * Returns: %TRUE if back swipe is enabled.
102 	 *
103 	 * Since: 1.0
104 	 */
105 	public bool getCanSwipeBack()
106 	{
107 		return hdy_preferences_window_get_can_swipe_back(hdyPreferencesWindow) != 0;
108 	}
109 
110 	/**
111 	 * Gets whether search is enabled for @self.
112 	 *
113 	 * Returns: whether search is enabled for @self.
114 	 *
115 	 * Since: 1.0
116 	 */
117 	public bool getSearchEnabled()
118 	{
119 		return hdy_preferences_window_get_search_enabled(hdyPreferencesWindow) != 0;
120 	}
121 
122 	/**
123 	 * Sets @subpage as the window's subpage and present it.
124 	 * The transition can be cancelled by the user, in which case visible child will
125 	 * change back to the previously visible child.
126 	 *
127 	 * Params:
128 	 *     subpage = the subpage
129 	 *
130 	 * Since: 1.0
131 	 */
132 	public void presentSubpage(Widget subpage)
133 	{
134 		hdy_preferences_window_present_subpage(hdyPreferencesWindow, (subpage is null) ? null : subpage.getWidgetStruct());
135 	}
136 
137 	/**
138 	 * Sets whether or not @self allows switching from a subpage to the preferences
139 	 * via a swipe gesture.
140 	 *
141 	 * Params:
142 	 *     canSwipeBack = the new value
143 	 *
144 	 * Since: 1.0
145 	 */
146 	public void setCanSwipeBack(bool canSwipeBack)
147 	{
148 		hdy_preferences_window_set_can_swipe_back(hdyPreferencesWindow, canSwipeBack);
149 	}
150 
151 	/**
152 	 * Sets whether search is enabled for @self.
153 	 *
154 	 * Params:
155 	 *     searchEnabled = %TRUE to enable search, %FALSE to disable it
156 	 *
157 	 * Since: 1.0
158 	 */
159 	public void setSearchEnabled(bool searchEnabled)
160 	{
161 		hdy_preferences_window_set_search_enabled(hdyPreferencesWindow, searchEnabled);
162 	}
163 }