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 gio.Notification;
26 
27 private import gio.IconIF;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import glib.Variant;
31 private import gobject.ObjectG;
32 private import gtkc.gio;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * #GNotification is a mechanism for creating a notification to be shown
38  * to the user -- typically as a pop-up notification presented by the
39  * desktop environment shell.
40  * 
41  * The key difference between #GNotification and other similar APIs is
42  * that, if supported by the desktop environment, notifications sent
43  * with #GNotification will persist after the application has exited,
44  * and even across system reboots.
45  * 
46  * Since the user may click on a notification while the application is
47  * not running, applications using #GNotification should be able to be
48  * started as a D-Bus service, using #GApplication.
49  * 
50  * User interaction with a notification (either the default action, or
51  * buttons) must be associated with actions on the application (ie:
52  * "app." actions).  It is not possible to route user interaction
53  * through the notification itself, because the object will not exist if
54  * the application is autostarted as a result of a notification being
55  * clicked.
56  * 
57  * A notification can be sent with g_application_send_notification().
58  *
59  * Since: 2.40
60  */
61 public class Notification : ObjectG
62 {
63 	/** the main Gtk struct */
64 	protected GNotification* gNotification;
65 
66 	/** Get the main Gtk struct */
67 	public GNotification* getNotificationStruct()
68 	{
69 		return gNotification;
70 	}
71 
72 	/** the main Gtk struct as a void* */
73 	protected override void* getStruct()
74 	{
75 		return cast(void*)gNotification;
76 	}
77 
78 	protected override void setStruct(GObject* obj)
79 	{
80 		gNotification = cast(GNotification*)obj;
81 		super.setStruct(obj);
82 	}
83 
84 	/**
85 	 * Sets our main struct and passes it to the parent class.
86 	 */
87 	public this (GNotification* gNotification, bool ownedRef = false)
88 	{
89 		this.gNotification = gNotification;
90 		super(cast(GObject*)gNotification, ownedRef);
91 	}
92 
93 	/**
94 	 */
95 
96 	public static GType getType()
97 	{
98 		return g_notification_get_type();
99 	}
100 
101 	/**
102 	 * Creates a new #GNotification with @title as its title.
103 	 *
104 	 * After populating @notification with more details, it can be sent to
105 	 * the desktop shell with g_application_send_notification(). Changing
106 	 * any properties after this call will not have any effect until
107 	 * resending @notification.
108 	 *
109 	 * Params:
110 	 *     title = the title of the notification
111 	 *
112 	 * Return: a new #GNotification instance
113 	 *
114 	 * Since: 2.40
115 	 *
116 	 * Throws: ConstructionException GTK+ fails to create the object.
117 	 */
118 	public this(string title)
119 	{
120 		auto p = g_notification_new(Str.toStringz(title));
121 		
122 		if(p is null)
123 		{
124 			throw new ConstructionException("null returned by new");
125 		}
126 		
127 		this(cast(GNotification*) p, true);
128 	}
129 
130 	/**
131 	 * Adds a button to @notification that activates the action in
132 	 * @detailed_action when clicked. That action must be an
133 	 * application-wide action (starting with "app."). If @detailed_action
134 	 * contains a target, the action will be activated with that target as
135 	 * its parameter.
136 	 *
137 	 * See g_action_parse_detailed_name() for a description of the format
138 	 * for @detailed_action.
139 	 *
140 	 * Params:
141 	 *     label = label of the button
142 	 *     detailedAction = a detailed action name
143 	 *
144 	 * Since: 2.40
145 	 */
146 	public void addButton(string label, string detailedAction)
147 	{
148 		g_notification_add_button(gNotification, Str.toStringz(label), Str.toStringz(detailedAction));
149 	}
150 
151 	/**
152 	 * Adds a button to @notification that activates @action when clicked.
153 	 * @action must be an application-wide action (it must start with "app.").
154 	 *
155 	 * If @target is non-%NULL, @action will be activated with @target as
156 	 * its parameter.
157 	 *
158 	 * Params:
159 	 *     label = label of the button
160 	 *     action = an action name
161 	 *     target = a #GVariant to use as @action's parameter, or %NULL
162 	 *
163 	 * Since: 2.40
164 	 */
165 	public void addButtonWithTargetValue(string label, string action, Variant target)
166 	{
167 		g_notification_add_button_with_target_value(gNotification, Str.toStringz(label), Str.toStringz(action), (target is null) ? null : target.getVariantStruct());
168 	}
169 
170 	/**
171 	 * Sets the body of @notification to @body.
172 	 *
173 	 * Params:
174 	 *     bod = the new body for @notification, or %NULL
175 	 *
176 	 * Since: 2.40
177 	 */
178 	public void setBody(string bod)
179 	{
180 		g_notification_set_body(gNotification, Str.toStringz(bod));
181 	}
182 
183 	/**
184 	 * Sets the default action of @notification to @detailed_action. This
185 	 * action is activated when the notification is clicked on.
186 	 *
187 	 * The action in @detailed_action must be an application-wide action (it
188 	 * must start with "app."). If @detailed_action contains a target, the
189 	 * given action will be activated with that target as its parameter.
190 	 * See g_action_parse_detailed_name() for a description of the format
191 	 * for @detailed_action.
192 	 *
193 	 * When no default action is set, the application that the notification
194 	 * was sent on is activated.
195 	 *
196 	 * Params:
197 	 *     detailedAction = a detailed action name
198 	 *
199 	 * Since: 2.40
200 	 */
201 	public void setDefaultAction(string detailedAction)
202 	{
203 		g_notification_set_default_action(gNotification, Str.toStringz(detailedAction));
204 	}
205 
206 	/**
207 	 * Sets the default action of @notification to @action. This action is
208 	 * activated when the notification is clicked on. It must be an
209 	 * application-wide action (start with "app.").
210 	 *
211 	 * If @target is non-%NULL, @action will be activated with @target as
212 	 * its parameter.
213 	 *
214 	 * When no default action is set, the application that the notification
215 	 * was sent on is activated.
216 	 *
217 	 * Params:
218 	 *     action = an action name
219 	 *     target = a #GVariant to use as @action's parameter, or %NULL
220 	 *
221 	 * Since: 2.40
222 	 */
223 	public void setDefaultActionAndTargetValue(string action, Variant target)
224 	{
225 		g_notification_set_default_action_and_target_value(gNotification, Str.toStringz(action), (target is null) ? null : target.getVariantStruct());
226 	}
227 
228 	/**
229 	 * Sets the icon of @notification to @icon.
230 	 *
231 	 * Params:
232 	 *     icon = the icon to be shown in @notification, as a #GIcon
233 	 *
234 	 * Since: 2.40
235 	 */
236 	public void setIcon(IconIF icon)
237 	{
238 		g_notification_set_icon(gNotification, (icon is null) ? null : icon.getIconStruct());
239 	}
240 
241 	/**
242 	 * Sets the priority of @notification to @priority. See
243 	 * #GNotificationPriority for possible values.
244 	 *
245 	 * Params:
246 	 *     priority = a #GNotificationPriority
247 	 */
248 	public void setPriority(GNotificationPriority priority)
249 	{
250 		g_notification_set_priority(gNotification, priority);
251 	}
252 
253 	/**
254 	 * Sets the title of @notification to @title.
255 	 *
256 	 * Params:
257 	 *     title = the new title for @notification
258 	 *
259 	 * Since: 2.40
260 	 */
261 	public void setTitle(string title)
262 	{
263 		g_notification_set_title(gNotification, Str.toStringz(title));
264 	}
265 
266 	/**
267 	 * Deprecated in favor of g_notification_set_priority().
268 	 *
269 	 * Params:
270 	 *     urgent = %TRUE if @notification is urgent
271 	 *
272 	 * Since: 2.40
273 	 */
274 	public void setUrgent(bool urgent)
275 	{
276 		g_notification_set_urgent(gNotification, urgent);
277 	}
278 }