1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
{ libnotify binding for Free Pascal
Copyright (C) 2011 Ido Kanner idokan at@at gmail dot.dot com
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit libnotify;
{$mode fpc}{$PACKRECORDS C}
interface
uses ctypes, glib2, gdk2pixbuf;
const
NOTIFY_LIBRARY = 'libnotify';
// Should be part of GTK but it is not binded to FPC :(
type
GVariant = record end;
GfreeFunc = procedure(data : gpointer); cdecl;
{ notification.h }
const
(**
* NOTIFY_EXPIRES_DEFAULT:
*
* The default expiration time on a notification.
*)
NOTIFY_EXPIRES_DEFAULT = -1;
(**
* NOTIFY_EXPIRES_NEVER:
*
* The notification never expires. It stays open until closed by the calling API
* or the user.
*)
NOTIFY_EXPIRES_NEVER = 0;
type
P_NotifyNotificationPrivate = ^T_NotifyNotificationPrivate;
T_NotifyNotificationPrivate = record end;
PNotifyNotificationPrivate = P_NotifyNotificationPrivate;
NotifyNotificationPrivate = T_NotifyNotificationPrivate;
P_NotifyNotification = ^T_NotifyNotification;
T_NotifyNotification = record
parent_object : TGObject;
priv : PNotifyNotificationPrivate;
end;
PNotifyNotification = P_NotifyNotification;
TNotifyNotification = T_NotifyNotification;
TNotificationProc = procedure (Notification : PNotifyNotification); cdecl;
P_NotifyNotificationClass = ^T_NotifyNotificationClass;
T_NotifyNotificationClass = record
parent_class : TGObjectClass;
// Signals
Notification : TNotificationProc;
end;
PNotifyNotificationClass = P_NotifyNotificationClass;
TNotifyNotificationClass = T_NotifyNotificationClass;
function notify_notification_get_type : GType; cdecl; external NOTIFY_LIBRARY;
function m_notify_type_notification : GType; cdecl; inline;
function M_NOTIFY_NOTIFICATION(o : pointer) : PGTypeInstance; cdecl; inline;
function M_NOTIFY_NOTIFICATION_CLASS(k : Pointer) : Pointer; cdecl; inline;
function M_NOTIFY_IS_NOTIFICATION(o : Pointer) : Boolean; cdecl; inline;
function M_NOTIFY_IS_NOTIFICATION_CLASS(k : pointer) : Boolean; cdecl; inline;
function M_NOTIFY_NOTIFICATION_GET_CLASS(o : Pointer) : PGTypeClass; cdecl; inline;
const
(**
* NotifyUrgency:
* @NOTIFY_URGENCY_LOW: Low urgency. Used for unimportant notifications.
* @NOTIFY_URGENCY_NORMAL: Normal urgency. Used for most standard notifications.
* @NOTIFY_URGENCY_CRITICAL: Critical urgency. Used for very important notifications.
*
* The urgency level of the notification.
*)
NOTIFY_URGENCY_LOW = 0;
NOTIFY_URGENCY_NORMAL = 1;
NOTIFY_URGENCY_CRITICAL = 2;
type
NotifyUrgency = cint;
(**
* NotifyActionCallback:
* @notification:
* @action:
* @user_data:
*
* An action callback function.
*)
NotifyActionCallback = procedure(notification : PNotifyNotification;
action : PChar;
user_data : gpointer); cdecl;
(*
/**
* NOTIFY_ACTION_CALLBACK:
* @func: The function to cast.
*
* A convenience macro for casting a function to a #NotifyActionCallback. This
* is much like G_CALLBACK().
*/
#define NOTIFY_ACTION_CALLBACK(func) ((NotifyActionCallback)(func))
*)
function notify_notification_new(summary, body, icon : PChar) : PNotifyNotification;
cdecl; external NOTIFY_LIBRARY;
function notify_notification_update(notification : PNotifyNotification;
summary, body, icon : PChar) : gboolean;
cdecl; external NOTIFY_LIBRARY;
function notify_notification_show(notification : PNotifyNotification;
error : PPGError) : gboolean;
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_timeout(notification : PNotifyNotification;
timeout : gint);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_category(notification : PNotifyNotification;
category : PChar);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_urgency(notification : PNotifyNotification;
urgency : NotifyUrgency);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_icon_from_pixbuf(
notification : PNotifyNotification;
icon : PGdkPixbuf);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_image_from_pixbuf(
notification : PNotifyNotification;
pixbuf : PGdkPixbuf);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_hint_int32(notification : PNotifyNotification;
key : PChar;
value : gint);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_hint_uint32(notification : PNotifyNotification;
key : PChar;
value : guint);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_hint_double(notification : PNotifyNotification;
key : PChar;
value : gdouble);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_hint_string(notification : PNotifyNotification;
key : PChar;
value : PChar);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_hint_byte(notification : PNotifyNotification;
key : PChar;
value : guchar);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_hint_byte_array(
notification : PNotifyNotification;
key : PChar;
value : Pguchar;
len : gsize);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_hint(notification : PNotifyNotification;
key : PChar;
value : GVariant);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_set_app_name(notification : PNotifyNotification;
app_name : PChar);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_clear_hints(notification : PNotifyNotification);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_add_action(notification : PNotifyNotification;
action,
label_ : PChar;
callback : NotifyActionCallback;
user_data : gpointer;
free_funch : GFreeFunc);
cdecl; external NOTIFY_LIBRARY;
procedure notify_notification_clear_actions(notification : PNotifyNotification);
cdecl; external NOTIFY_LIBRARY;
function notify_notification_close(notification : PNotifyNotification;
error : PPGError) : gboolean;
cdecl; external NOTIFY_LIBRARY;
function notify_notification_get_closed_reason(
notification : PNotifyNotification) : gint;
cdecl; external NOTIFY_LIBRARY;
{ notify-enum-types.h }
(* enumerations from "notification.h" *)
function notify_urgency_get_type : GType;
cdecl; external NOTIFY_LIBRARY;
function M_NOTIFY_TYPE_URGENCY : GType; cdecl; inline;
{ notify-features.h }
(* compile time version *)
const
NOTIFY_VERSION_MAJOR = 0;
NOTIFY_VERSION_MINOR = 7;
NOTIFY_VERSION_MICRO = 3;
(* check whether a version equal to or greater than
* major.minor.micro is present.
*)
function M_NOTIFY_CHECK_VERSION(major, minor, micro : cint) : Boolean; cdecl; inline;
{ notify.h }
function notify_init(app_name : PChar) : gboolean;
cdecl; external NOTIFY_LIBRARY;
procedure notify_uninit; cdecl; external NOTIFY_LIBRARY;
function notify_is_initted : gboolean; cdecl; external NOTIFY_LIBRARY;
function notify_get_app_name : PChar; cdecl; external NOTIFY_LIBRARY;
procedure notify_set_app_name(app_name : PChar); cdecl; external NOTIFY_LIBRARY;
function notify_get_server_caps : PGList; cdecl; external NOTIFY_LIBRARY;
function notify_get_server_info(ret_name, ret_vendor, ret_version : PPChar) : gboolean;
cdecl; external NOTIFY_LIBRARY;
implementation
function m_notify_type_notification : GType; cdecl;
begin
m_notify_type_notification := notify_notification_get_type;
end;
function M_NOTIFY_NOTIFICATION(o : pointer): PGTypeInstance; cdecl;
begin
// #define NOTIFY_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotification))
M_NOTIFY_NOTIFICATION := G_TYPE_CHECK_INSTANCE_CAST(o, m_notify_type_notification);
end;
function M_NOTIFY_NOTIFICATION_CLASS(k: Pointer): Pointer; cdecl;
begin
//#define NOTIFY_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass))
M_NOTIFY_NOTIFICATION_CLASS := G_TYPE_CHECK_CLASS_CAST(k, m_notify_type_notification);
end;
function M_NOTIFY_IS_NOTIFICATION(o: Pointer): Boolean; cdecl;
begin
// #define NOTIFY_IS_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION))
M_NOTIFY_IS_NOTIFICATION := G_TYPE_CHECK_INSTANCE_TYPE(o, m_notify_type_notification);
end;
function M_NOTIFY_IS_NOTIFICATION_CLASS(k: pointer): Boolean; cdecl;
begin
// #define NOTIFY_IS_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION))
M_NOTIFY_IS_NOTIFICATION_CLASS := G_TYPE_CHECK_CLASS_TYPE(k, m_notify_type_notification);
end;
function M_NOTIFY_NOTIFICATION_GET_CLASS(o: Pointer): PGTypeClass; cdecl;
begin
// #define NOTIFY_NOTIFICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass))
M_NOTIFY_NOTIFICATION_GET_CLASS := G_TYPE_INSTANCE_GET_CLASS(o, m_notify_type_notification);
end;
function M_NOTIFY_TYPE_URGENCY: GType; cdecl;
begin
M_NOTIFY_TYPE_URGENCY := notify_urgency_get_type;
end;
function M_NOTIFY_CHECK_VERSION(major, minor, micro: cint): Boolean; cdecl;
begin
{
#define NOTIFY_CHECK_VERSION(major,minor,micro) \
(NOTIFY_VERSION_MAJOR > (major) || \
(NOTIFY_VERSION_MAJOR == (major) && NOTIFY_VERSION_MINOR > (minor)) || \
(NOTIFY_VERSION_MAJOR == (major) && NOTIFY_VERSION_MINOR == (minor) && \
NOTIFY_VERSION_MICRO >= (micro)))
}
M_NOTIFY_CHECK_VERSION := ((NOTIFY_VERSION_MAJOR > major) or
((NOTIFY_VERSION_MAJOR = major) and
(NOTIFY_VERSION_MINOR > minor)) or
((NOTIFY_VERSION_MAJOR = major) and
(NOTIFY_VERSION_MINOR = minor) and
(NOTIFY_VERSION_MICRO >= micro)));
end;
end.
|