source: appstream-generator/build/girepo/gio/Notification.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 7.7 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.Notification;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.IconIF;
26private import glib.ConstructionException;
27private import glib.Str;
28private import glib.Variant;
29private import gobject.ObjectG;
30
31
32/**
33 * #GNotification is a mechanism for creating a notification to be shown
34 * to the user -- typically as a pop-up notification presented by the
35 * desktop environment shell.
36 *
37 * The key difference between #GNotification and other similar APIs is
38 * that, if supported by the desktop environment, notifications sent
39 * with #GNotification will persist after the application has exited,
40 * and even across system reboots.
41 *
42 * Since the user may click on a notification while the application is
43 * not running, applications using #GNotification should be able to be
44 * started as a D-Bus service, using #GApplication.
45 *
46 * User interaction with a notification (either the default action, or
47 * buttons) must be associated with actions on the application (ie:
48 * "app." actions).  It is not possible to route user interaction
49 * through the notification itself, because the object will not exist if
50 * the application is autostarted as a result of a notification being
51 * clicked.
52 *
53 * A notification can be sent with g_application_send_notification().
54 *
55 * Since: 2.40
56 */
57public class Notification : ObjectG
58{
59        /** the main Gtk struct */
60        protected GNotification* gNotification;
61
62        /** Get the main Gtk struct */
63        public GNotification* getNotificationStruct()
64        {
65                return gNotification;
66        }
67
68        /** the main Gtk struct as a void* */
69        protected override void* getStruct()
70        {
71                return cast(void*)gNotification;
72        }
73
74        protected override void setStruct(GObject* obj)
75        {
76                gNotification = cast(GNotification*)obj;
77                super.setStruct(obj);
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         *     bod = the new body for @notification, or %NULL
170         *
171         * Since: 2.40
172         */
173        public void setBody(string bod)
174        {
175                g_notification_set_body(gNotification, Str.toStringz(bod));
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         * Params:
265         *     urgent = %TRUE if @notification is urgent
266         *
267         * Since: 2.40
268         */
269        public void setUrgent(bool urgent)
270        {
271                g_notification_set_urgent(gNotification, urgent);
272        }
273}
Note: See TracBrowser for help on using the repository browser.