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(bool transferOwnership = false)
68 	{
69 		if (transferOwnership)
70 			ownedRef = false;
71 		return gNotification;
72 	}
73 
74 	/** the main Gtk struct as a void* */
75 	protected override void* getStruct()
76 	{
77 		return cast(void*)gNotification;
78 	}
79 
80 	protected override void setStruct(GObject* obj)
81 	{
82 		gNotification = cast(GNotification*)obj;
83 		super.setStruct(obj);
84 	}
85 
86 	/**
87 	 * Sets our main struct and passes it to the parent class.
88 	 */
89 	public this (GNotification* gNotification, bool ownedRef = false)
90 	{
91 		this.gNotification = gNotification;
92 		super(cast(GObject*)gNotification, ownedRef);
93 	}
94 
95 
96 	/** */
97 	public static GType getType()
98 	{
99 		return g_notification_get_type();
100 	}
101 
102 	/**
103 	 * Creates a new #GNotification with @title as its title.
104 	 *
105 	 * After populating @notification with more details, it can be sent to
106 	 * the desktop shell with g_application_send_notification(). Changing
107 	 * any properties after this call will not have any effect until
108 	 * resending @notification.
109 	 *
110 	 * Params:
111 	 *     title = the title of the notification
112 	 *
113 	 * Returns: a new #GNotification instance
114 	 *
115 	 * Since: 2.40
116 	 *
117 	 * Throws: ConstructionException GTK+ fails to create the object.
118 	 */
119 	public this(string title)
120 	{
121 		auto p = g_notification_new(Str.toStringz(title));
122 		
123 		if(p is null)
124 		{
125 			throw new ConstructionException("null returned by new");
126 		}
127 		
128 		this(cast(GNotification*) p, true);
129 	}
130 
131 	/**
132 	 * Adds a button to @notification that activates the action in
133 	 * @detailed_action when clicked. That action must be an
134 	 * application-wide action (starting with "app."). If @detailed_action
135 	 * contains a target, the action will be activated with that target as
136 	 * its parameter.
137 	 *
138 	 * See g_action_parse_detailed_name() for a description of the format
139 	 * for @detailed_action.
140 	 *
141 	 * Params:
142 	 *     label = label of the button
143 	 *     detailedAction = a detailed action name
144 	 *
145 	 * Since: 2.40
146 	 */
147 	public void addButton(string label, string detailedAction)
148 	{
149 		g_notification_add_button(gNotification, Str.toStringz(label), Str.toStringz(detailedAction));
150 	}
151 
152 	/**
153 	 * Adds a button to @notification that activates @action when clicked.
154 	 * @action must be an application-wide action (it must start with "app.").
155 	 *
156 	 * If @target is non-%NULL, @action will be activated with @target as
157 	 * its parameter.
158 	 *
159 	 * Params:
160 	 *     label = label of the button
161 	 *     action = an action name
162 	 *     target = a #GVariant to use as @action's parameter, or %NULL
163 	 *
164 	 * Since: 2.40
165 	 */
166 	public void addButtonWithTargetValue(string label, string action, Variant target)
167 	{
168 		g_notification_add_button_with_target_value(gNotification, Str.toStringz(label), Str.toStringz(action), (target is null) ? null : target.getVariantStruct());
169 	}
170 
171 	/**
172 	 * Sets the body of @notification to @body.
173 	 *
174 	 * Params:
175 	 *     bod = the new body for @notification, or %NULL
176 	 *
177 	 * Since: 2.40
178 	 */
179 	public void setBody(string bod)
180 	{
181 		g_notification_set_body(gNotification, Str.toStringz(bod));
182 	}
183 
184 	/**
185 	 * Sets the default action of @notification to @detailed_action. This
186 	 * action is activated when the notification is clicked on.
187 	 *
188 	 * The action in @detailed_action must be an application-wide action (it
189 	 * must start with "app."). If @detailed_action contains a target, the
190 	 * given action will be activated with that target as its parameter.
191 	 * See g_action_parse_detailed_name() for a description of the format
192 	 * for @detailed_action.
193 	 *
194 	 * When no default action is set, the application that the notification
195 	 * was sent on is activated.
196 	 *
197 	 * Params:
198 	 *     detailedAction = a detailed action name
199 	 *
200 	 * Since: 2.40
201 	 */
202 	public void setDefaultAction(string detailedAction)
203 	{
204 		g_notification_set_default_action(gNotification, Str.toStringz(detailedAction));
205 	}
206 
207 	/**
208 	 * Sets the default action of @notification to @action. This action is
209 	 * activated when the notification is clicked on. It must be an
210 	 * application-wide action (start with "app.").
211 	 *
212 	 * If @target is non-%NULL, @action will be activated with @target as
213 	 * its parameter.
214 	 *
215 	 * When no default action is set, the application that the notification
216 	 * was sent on is activated.
217 	 *
218 	 * Params:
219 	 *     action = an action name
220 	 *     target = a #GVariant to use as @action's parameter, or %NULL
221 	 *
222 	 * Since: 2.40
223 	 */
224 	public void setDefaultActionAndTargetValue(string action, Variant target)
225 	{
226 		g_notification_set_default_action_and_target_value(gNotification, Str.toStringz(action), (target is null) ? null : target.getVariantStruct());
227 	}
228 
229 	/**
230 	 * Sets the icon of @notification to @icon.
231 	 *
232 	 * Params:
233 	 *     icon = the icon to be shown in @notification, as a #GIcon
234 	 *
235 	 * Since: 2.40
236 	 */
237 	public void setIcon(IconIF icon)
238 	{
239 		g_notification_set_icon(gNotification, (icon is null) ? null : icon.getIconStruct());
240 	}
241 
242 	/**
243 	 * Sets the priority of @notification to @priority. See
244 	 * #GNotificationPriority for possible values.
245 	 *
246 	 * Params:
247 	 *     priority = a #GNotificationPriority
248 	 */
249 	public void setPriority(GNotificationPriority priority)
250 	{
251 		g_notification_set_priority(gNotification, priority);
252 	}
253 
254 	/**
255 	 * Sets the title of @notification to @title.
256 	 *
257 	 * Params:
258 	 *     title = the new title for @notification
259 	 *
260 	 * Since: 2.40
261 	 */
262 	public void setTitle(string title)
263 	{
264 		g_notification_set_title(gNotification, Str.toStringz(title));
265 	}
266 
267 	/**
268 	 * Deprecated in favor of g_notification_set_priority().
269 	 *
270 	 * Params:
271 	 *     urgent = %TRUE if @notification is urgent
272 	 *
273 	 * Since: 2.40
274 	 */
275 	public void setUrgent(bool urgent)
276 	{
277 		g_notification_set_urgent(gNotification, urgent);
278 	}
279 }