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