Skip to content

Commit

Permalink
eg: add libnotify example
Browse files Browse the repository at this point in the history
  • Loading branch information
ghedo committed Apr 18, 2012
1 parent 82f23c0 commit 4c785c6
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions eg/notify.pl
@@ -0,0 +1,43 @@
use v5.10;

use strict;
use warnings;

use FFI::Raw;

my $libnotify = 'libnotify.so.4';

my $notify_init = FFI::Raw -> new(
$libnotify, 'notify_init',
FFI::Raw::void, FFI::Raw::str
);

my $notify_uninit = FFI::Raw -> new(
$libnotify, 'notify_uninit',
FFI::Raw::void
);

my $notify_new = FFI::Raw -> new(
$libnotify, 'notify_notification_new',
FFI::Raw::ptr, FFI::Raw::str, FFI::Raw::str, FFI::Raw::str
);

my $notify_update = FFI::Raw -> new(
$libnotify, 'notify_notification_update',
FFI::Raw::void,
FFI::Raw::ptr, FFI::Raw::str, FFI::Raw::str, FFI::Raw::str
);

my $notify_show = FFI::Raw -> new(
$libnotify, 'notify_notification_show',
FFI::Raw::void, FFI::Raw::ptr, FFI::Raw::ptr
);

$notify_init -> call('FFI::Raw');

my $n = $notify_new -> call('', '', '');

$notify_update -> call($n, 'FFI::Raw', 'It works!!!', 'media-playback-start');
$notify_show -> call($n, 0);

$notify_uninit -> call();

0 comments on commit 4c785c6

Please sign in to comment.