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