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