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.Box; 24 private import gtk.BuildableIF; 25 private import gtk.BuildableT; 26 private import gtk.OrientableIF; 27 private import gtk.OrientableT; 28 private import gtk.Stack; 29 private import handy.c.functions; 30 public import handy.c.types; 31 32 33 /** */ 34 public class ViewSwitcher : Box 35 { 36 /** the main Gtk struct */ 37 protected HdyViewSwitcher* hdyViewSwitcher; 38 39 /** Get the main Gtk struct */ 40 public HdyViewSwitcher* getViewSwitcherStruct(bool transferOwnership = false) 41 { 42 if (transferOwnership) 43 ownedRef = false; 44 return hdyViewSwitcher; 45 } 46 47 /** the main Gtk struct as a void* */ 48 protected override void* getStruct() 49 { 50 return cast(void*)hdyViewSwitcher; 51 } 52 53 /** 54 * Sets our main struct and passes it to the parent class. 55 */ 56 public this (HdyViewSwitcher* hdyViewSwitcher, bool ownedRef = false) 57 { 58 this.hdyViewSwitcher = hdyViewSwitcher; 59 super(cast(GtkBox*)hdyViewSwitcher, ownedRef); 60 } 61 62 63 /** */ 64 public static GType getType() 65 { 66 return hdy_view_switcher_get_type(); 67 } 68 69 /** 70 * Creates a new #HdyViewSwitcher widget. 71 * 72 * Returns: a new #HdyViewSwitcher 73 * 74 * Since: 0.0.10 75 * 76 * Throws: ConstructionException GTK+ fails to create the object. 77 */ 78 public this() 79 { 80 auto p = hdy_view_switcher_new(); 81 82 if(p is null) 83 { 84 throw new ConstructionException("null returned by new"); 85 } 86 87 this(cast(HdyViewSwitcher*) p); 88 } 89 90 /** 91 * Get the icon size of the images used in the #HdyViewSwitcher. 92 * 93 * See: hdy_view_switcher_set_icon_size() 94 * 95 * Returns: the icon size of the images 96 * 97 * Since: 0.0.10 98 */ 99 public GtkIconSize getIconSize() 100 { 101 return hdy_view_switcher_get_icon_size(hdyViewSwitcher); 102 } 103 104 /** 105 * Get the ellipsizing position of the narrow mode label. See 106 * hdy_view_switcher_set_narrow_ellipsize(). 107 * 108 * Returns: #PangoEllipsizeMode 109 * 110 * Since: 0.0.10 111 */ 112 public PangoEllipsizeMode getNarrowEllipsize() 113 { 114 return hdy_view_switcher_get_narrow_ellipsize(hdyViewSwitcher); 115 } 116 117 /** 118 * Gets the policy of @self. 119 * 120 * Returns: the policy of @self 121 * 122 * Since: 0.0.10 123 */ 124 public HdyViewSwitcherPolicy getPolicy() 125 { 126 return hdy_view_switcher_get_policy(hdyViewSwitcher); 127 } 128 129 /** 130 * Get the #GtkStack being controlled by the #HdyViewSwitcher. 131 * 132 * See: hdy_view_switcher_set_stack() 133 * 134 * Returns: the #GtkStack, or %NULL if none has been set 135 * 136 * Since: 0.0.10 137 */ 138 public Stack getStack() 139 { 140 auto p = hdy_view_switcher_get_stack(hdyViewSwitcher); 141 142 if(p is null) 143 { 144 return null; 145 } 146 147 return ObjectG.getDObject!(Stack)(cast(GtkStack*) p); 148 } 149 150 /** 151 * Change the icon size hint for the icons in a #HdyViewSwitcher. 152 * 153 * Params: 154 * iconSize = the new icon size 155 * 156 * Since: 0.0.10 157 */ 158 public void setIconSize(GtkIconSize iconSize) 159 { 160 hdy_view_switcher_set_icon_size(hdyViewSwitcher, iconSize); 161 } 162 163 /** 164 * Set the mode used to ellipsize the text in narrow mode if there is not 165 * enough space to render the entire string. 166 * 167 * Params: 168 * mode = a #PangoEllipsizeMode 169 * 170 * Since: 0.0.10 171 */ 172 public void setNarrowEllipsize(PangoEllipsizeMode mode) 173 { 174 hdy_view_switcher_set_narrow_ellipsize(hdyViewSwitcher, mode); 175 } 176 177 /** 178 * Sets the policy of @self. 179 * 180 * Params: 181 * policy = the new policy 182 * 183 * Since: 0.0.10 184 */ 185 public void setPolicy(HdyViewSwitcherPolicy policy) 186 { 187 hdy_view_switcher_set_policy(hdyViewSwitcher, policy); 188 } 189 190 /** 191 * Sets the #GtkStack to control. 192 * 193 * Params: 194 * stack = a #GtkStack 195 * 196 * Since: 0.0.10 197 */ 198 public void setStack(Stack stack) 199 { 200 hdy_view_switcher_set_stack(hdyViewSwitcher, (stack is null) ? null : stack.getStackStruct()); 201 } 202 }