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