1 module webkit2.Notification; 2 3 private import glib.Str; 4 private import gobject.ObjectG; 5 private import gobject.Signals; 6 private import std.algorithm; 7 private import webkit2.c.functions; 8 public import webkit2.c.types; 9 10 11 /** */ 12 public class Notification : ObjectG 13 { 14 /** the main Gtk struct */ 15 protected WebKitNotification* webKitNotification; 16 17 /** Get the main Gtk struct */ 18 public WebKitNotification* getNotificationStruct(bool transferOwnership = false) 19 { 20 if (transferOwnership) 21 ownedRef = false; 22 return webKitNotification; 23 } 24 25 /** the main Gtk struct as a void* */ 26 protected override void* getStruct() 27 { 28 return cast(void*)webKitNotification; 29 } 30 31 /** 32 * Sets our main struct and passes it to the parent class. 33 */ 34 public this (WebKitNotification* webKitNotification, bool ownedRef = false) 35 { 36 this.webKitNotification = webKitNotification; 37 super(cast(GObject*)webKitNotification, ownedRef); 38 } 39 40 41 /** */ 42 public static GType getType() 43 { 44 return webkit_notification_get_type(); 45 } 46 47 /** 48 * Tells WebKit the notification has been clicked. This will emit the 49 * #WebKitNotification::clicked signal. 50 * 51 * Since: 2.12 52 */ 53 public void clicked() 54 { 55 webkit_notification_clicked(webKitNotification); 56 } 57 58 /** 59 * Closes the notification. 60 * 61 * Since: 2.8 62 */ 63 public void close() 64 { 65 webkit_notification_close(webKitNotification); 66 } 67 68 /** 69 * Obtains the body for the notification. 70 * 71 * Returns: the body for the notification 72 * 73 * Since: 2.8 74 */ 75 public string getBody() 76 { 77 return Str.toString(webkit_notification_get_body(webKitNotification)); 78 } 79 80 /** 81 * Obtains the unique id for the notification. 82 * 83 * Returns: the unique id for the notification 84 * 85 * Since: 2.8 86 */ 87 public ulong getId() 88 { 89 return webkit_notification_get_id(webKitNotification); 90 } 91 92 /** 93 * Obtains the tag identifier for the notification. 94 * 95 * Returns: the tag for the notification 96 * 97 * Since: 2.16 98 */ 99 public string getTag() 100 { 101 return Str.toString(webkit_notification_get_tag(webKitNotification)); 102 } 103 104 /** 105 * Obtains the title for the notification. 106 * 107 * Returns: the title for the notification 108 * 109 * Since: 2.8 110 */ 111 public string getTitle() 112 { 113 return Str.toString(webkit_notification_get_title(webKitNotification)); 114 } 115 116 /** 117 * Emitted when a notification has been clicked. See webkit_notification_clicked(). 118 * 119 * Since: 2.12 120 */ 121 gulong addOnClicked(void delegate(Notification) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 122 { 123 return Signals.connect(this, "clicked", dlg, connectFlags ^ ConnectFlags.SWAPPED); 124 } 125 126 /** 127 * Emitted when a notification has been withdrawn. 128 * 129 * The default handler will close the notification using libnotify, if built with 130 * support for it. 131 * 132 * Since: 2.8 133 */ 134 gulong addOnClosed(void delegate(Notification) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 135 { 136 return Signals.connect(this, "closed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 137 } 138 }