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