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.ViewSwitcherTitle; 20 21 private import glib.ConstructionException; 22 private import glib.Str; 23 private import gobject.ObjectG; 24 private import gtk.Bin; 25 private import gtk.BuildableIF; 26 private import gtk.BuildableT; 27 private import gtk.Stack; 28 private import handy.c.functions; 29 public import handy.c.types; 30 31 32 /** */ 33 public class ViewSwitcherTitle : Bin 34 { 35 /** the main Gtk struct */ 36 protected HdyViewSwitcherTitle* hdyViewSwitcherTitle; 37 38 /** Get the main Gtk struct */ 39 public HdyViewSwitcherTitle* getViewSwitcherTitleStruct(bool transferOwnership = false) 40 { 41 if (transferOwnership) 42 ownedRef = false; 43 return hdyViewSwitcherTitle; 44 } 45 46 /** the main Gtk struct as a void* */ 47 protected override void* getStruct() 48 { 49 return cast(void*)hdyViewSwitcherTitle; 50 } 51 52 /** 53 * Sets our main struct and passes it to the parent class. 54 */ 55 public this (HdyViewSwitcherTitle* hdyViewSwitcherTitle, bool ownedRef = false) 56 { 57 this.hdyViewSwitcherTitle = hdyViewSwitcherTitle; 58 super(cast(GtkBin*)hdyViewSwitcherTitle, ownedRef); 59 } 60 61 62 /** */ 63 public static GType getType() 64 { 65 return hdy_view_switcher_title_get_type(); 66 } 67 68 /** 69 * Creates a new #HdyViewSwitcherTitle widget. 70 * 71 * Returns: a new #HdyViewSwitcherTitle 72 * 73 * Since: 1.0 74 * 75 * Throws: ConstructionException GTK+ fails to create the object. 76 */ 77 public this() 78 { 79 auto __p = hdy_view_switcher_title_new(); 80 81 if(__p is null) 82 { 83 throw new ConstructionException("null returned by new"); 84 } 85 86 this(cast(HdyViewSwitcherTitle*) __p); 87 } 88 89 /** 90 * Gets the policy of @self. 91 * 92 * Returns: the policy of @self 93 * 94 * Since: 1.0 95 */ 96 public HdyViewSwitcherPolicy getPolicy() 97 { 98 return hdy_view_switcher_title_get_policy(hdyViewSwitcherTitle); 99 } 100 101 /** 102 * Get the #GtkStack being controlled by the #HdyViewSwitcher. 103 * 104 * Returns: the #GtkStack, or %NULL if none has been set 105 * 106 * Since: 1.0 107 */ 108 public Stack getStack() 109 { 110 auto __p = hdy_view_switcher_title_get_stack(hdyViewSwitcherTitle); 111 112 if(__p is null) 113 { 114 return null; 115 } 116 117 return ObjectG.getDObject!(Stack)(cast(GtkStack*) __p); 118 } 119 120 /** 121 * Gets the subtitle of @self. See hdy_view_switcher_title_set_subtitle(). 122 * 123 * Returns: the subtitle of @self, or %NULL. 124 * 125 * Since: 1.0 126 */ 127 public string getSubtitle() 128 { 129 return Str.toString(hdy_view_switcher_title_get_subtitle(hdyViewSwitcherTitle)); 130 } 131 132 /** 133 * Gets the title of @self. See hdy_view_switcher_title_set_title(). 134 * 135 * Returns: the title of @self, or %NULL. 136 * 137 * Since: 1.0 138 */ 139 public string getTitle() 140 { 141 return Str.toString(hdy_view_switcher_title_get_title(hdyViewSwitcherTitle)); 142 } 143 144 /** 145 * Get whether the title label of @self is visible. 146 * 147 * Returns: %TRUE if the title label of @self is visible, %FALSE if not. 148 * 149 * Since: 1.0 150 */ 151 public bool getTitleVisible() 152 { 153 return hdy_view_switcher_title_get_title_visible(hdyViewSwitcherTitle) != 0; 154 } 155 156 /** 157 * Gets whether @self's view switcher is enabled. 158 * 159 * See hdy_view_switcher_title_set_view_switcher_enabled(). 160 * 161 * Returns: %TRUE if the view switcher is enabled, %FALSE otherwise. 162 * 163 * Since: 1.0 164 */ 165 public bool getViewSwitcherEnabled() 166 { 167 return hdy_view_switcher_title_get_view_switcher_enabled(hdyViewSwitcherTitle) != 0; 168 } 169 170 /** 171 * Sets the policy of @self. 172 * 173 * Params: 174 * policy = the new policy 175 * 176 * Since: 1.0 177 */ 178 public void setPolicy(HdyViewSwitcherPolicy policy) 179 { 180 hdy_view_switcher_title_set_policy(hdyViewSwitcherTitle, policy); 181 } 182 183 /** 184 * Sets the #GtkStack to control. 185 * 186 * Params: 187 * stack = a #GtkStack 188 * 189 * Since: 1.0 190 */ 191 public void setStack(Stack stack) 192 { 193 hdy_view_switcher_title_set_stack(hdyViewSwitcherTitle, (stack is null) ? null : stack.getStackStruct()); 194 } 195 196 /** 197 * Sets the subtitle of @self. The subtitle should give a user additional 198 * details. 199 * 200 * Params: 201 * subtitle = a subtitle, or %NULL 202 * 203 * Since: 1.0 204 */ 205 public void setSubtitle(string subtitle) 206 { 207 hdy_view_switcher_title_set_subtitle(hdyViewSwitcherTitle, Str.toStringz(subtitle)); 208 } 209 210 /** 211 * Sets the title of @self. The title should give a user additional details. A 212 * good title should not include the application name. 213 * 214 * Params: 215 * title = a title, or %NULL 216 * 217 * Since: 1.0 218 */ 219 public void setTitle(string title) 220 { 221 hdy_view_switcher_title_set_title(hdyViewSwitcherTitle, Str.toStringz(title)); 222 } 223 224 /** 225 * Make @self enable or disable its view switcher. If it is disabled, the title 226 * will be displayed instead. This allows to programmatically and prematurely 227 * hide the view switcher of @self even if it fits in the available space. 228 * 229 * This can be used e.g. to ensure the view switcher is hidden below a certain 230 * window width, or any other constraint you find suitable. 231 * 232 * Params: 233 * enabled = %TRUE to enable the view switcher, %FALSE to disable it 234 * 235 * Since: 1.0 236 */ 237 public void setViewSwitcherEnabled(bool enabled) 238 { 239 hdy_view_switcher_title_set_view_switcher_enabled(hdyViewSwitcherTitle, enabled); 240 } 241 }