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