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.RecentAction; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.Action; 31 private import gtk.RecentChooserIF; 32 private import gtk.RecentChooserT; 33 private import gtk.RecentManager; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 public import gtkc.gtktypes; 37 38 39 /** 40 * A #GtkRecentAction represents a list of recently used files, which 41 * can be shown by widgets such as #GtkRecentChooserDialog or 42 * #GtkRecentChooserMenu. 43 * 44 * To construct a submenu showing recently used files, use a #GtkRecentAction 45 * as the action for a <menuitem>. To construct a menu toolbutton showing 46 * the recently used files in the popup menu, use a #GtkRecentAction as the 47 * action for a <toolitem> element. 48 */ 49 public class RecentAction : Action, RecentChooserIF 50 { 51 /** the main Gtk struct */ 52 protected GtkRecentAction* gtkRecentAction; 53 54 /** Get the main Gtk struct */ 55 public GtkRecentAction* getRecentActionStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return gtkRecentAction; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected override void* getStruct() 64 { 65 return cast(void*)gtkRecentAction; 66 } 67 68 protected override void setStruct(GObject* obj) 69 { 70 gtkRecentAction = cast(GtkRecentAction*)obj; 71 super.setStruct(obj); 72 } 73 74 /** 75 * Sets our main struct and passes it to the parent class. 76 */ 77 public this (GtkRecentAction* gtkRecentAction, bool ownedRef = false) 78 { 79 this.gtkRecentAction = gtkRecentAction; 80 super(cast(GtkAction*)gtkRecentAction, ownedRef); 81 } 82 83 // add the RecentChooser capabilities 84 mixin RecentChooserT!(GtkRecentAction); 85 86 /** 87 * Creates a new RecentAction object. To add the action to 88 * a ActionGroup and set the accelerator for the action, 89 * call gtk.ActionGroup.ActionGroup.addActionwWithAccel(). 90 * 91 * Since: 2.12 92 * 93 * Params: 94 * name = a unique name for the action 95 * label = the label displayed in menu items and on buttons, or null 96 * tooltip = a tooltip for the action, or null 97 * stockID = the stock icon to display in widgets representing the 98 * action, or null 99 * Throws: ConstructionException GTK+ fails to create the object. 100 */ 101 public this (string name, string label, string tooltip, StockID stockID) 102 { 103 this(name, label, tooltip, cast(string)stockID); 104 } 105 106 /** 107 * Creates a new RecentAction object. To add the action to 108 * a ActionGroup and set the accelerator for the action, 109 * call gtk.ActionGroup.ActionGroup.addActionwWithAccel(). 110 * 111 * Since: 2.12 112 * 113 * Params: 114 * name = a unique name for the action 115 * label = the label displayed in menu items and on buttons, or null 116 * tooltip = a tooltip for the action, or null 117 * stockID = the stock icon to display in widgets representing the 118 * action, or null 119 * manager = a GtkRecentManager, or null for using the default 120 * RecentManager 121 * Throws: ConstructionException GTK+ fails to create the object. 122 */ 123 public this (string name, string label, string tooltip, StockID stockID, RecentManager manager) 124 { 125 this(name, label, tooltip, cast(string)stockID, manager); 126 } 127 128 /** 129 */ 130 131 /** */ 132 public static GType getType() 133 { 134 return gtk_recent_action_get_type(); 135 } 136 137 /** 138 * Creates a new #GtkRecentAction object. To add the action to 139 * a #GtkActionGroup and set the accelerator for the action, 140 * call gtk_action_group_add_action_with_accel(). 141 * 142 * Params: 143 * name = a unique name for the action 144 * label = the label displayed in menu items and on buttons, 145 * or %NULL 146 * tooltip = a tooltip for the action, or %NULL 147 * stockId = the stock icon to display in widgets representing 148 * the action, or %NULL 149 * 150 * Returns: the newly created #GtkRecentAction. 151 * 152 * Since: 2.12 153 * 154 * Throws: ConstructionException GTK+ fails to create the object. 155 */ 156 public this(string name, string label, string tooltip, string stockId) 157 { 158 auto p = gtk_recent_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId)); 159 160 if(p is null) 161 { 162 throw new ConstructionException("null returned by new"); 163 } 164 165 this(cast(GtkRecentAction*) p, true); 166 } 167 168 /** 169 * Creates a new #GtkRecentAction object. To add the action to 170 * a #GtkActionGroup and set the accelerator for the action, 171 * call gtk_action_group_add_action_with_accel(). 172 * 173 * Params: 174 * name = a unique name for the action 175 * label = the label displayed in menu items and on buttons, 176 * or %NULL 177 * tooltip = a tooltip for the action, or %NULL 178 * stockId = the stock icon to display in widgets representing 179 * the action, or %NULL 180 * manager = a #GtkRecentManager, or %NULL for using the default 181 * #GtkRecentManager 182 * 183 * Returns: the newly created #GtkRecentAction 184 * 185 * Since: 2.12 186 * 187 * Throws: ConstructionException GTK+ fails to create the object. 188 */ 189 public this(string name, string label, string tooltip, string stockId, RecentManager manager) 190 { 191 auto p = gtk_recent_action_new_for_manager(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), (manager is null) ? null : manager.getRecentManagerStruct()); 192 193 if(p is null) 194 { 195 throw new ConstructionException("null returned by new_for_manager"); 196 } 197 198 this(cast(GtkRecentAction*) p, true); 199 } 200 201 /** 202 * Returns the value set by gtk_recent_chooser_menu_set_show_numbers(). 203 * 204 * Returns: %TRUE if numbers should be shown. 205 * 206 * Since: 2.12 207 */ 208 public bool getShowNumbers() 209 { 210 return gtk_recent_action_get_show_numbers(gtkRecentAction) != 0; 211 } 212 213 /** 214 * Sets whether a number should be added to the items shown by the 215 * widgets representing @action. The numbers are shown to provide 216 * a unique character for a mnemonic to be used inside the menu item's 217 * label. Only the first ten items get a number to avoid clashes. 218 * 219 * Params: 220 * showNumbers = %TRUE if the shown items should be numbered 221 * 222 * Since: 2.12 223 */ 224 public void setShowNumbers(bool showNumbers) 225 { 226 gtk_recent_action_set_show_numbers(gtkRecentAction, showNumbers); 227 } 228 }