summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-patches
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2015-03-08 23:40:27 +0000
committerintrigeri <intrigeri@boum.org>2015-03-09 01:13:12 +0000
commit74eb681706213d888c2443284fa92aeacce0ba7b (patch)
tree4d4e63585e31f9956646507417f4b3237115143f /config/chroot_local-patches
parent20d781579aebb97c5532b4834b38a34423c0eb35 (diff)
Make Desktop::Notify support notification actions.
I've submitted this patch upstream: https://rt.cpan.org/Ticket/Display.html?id=102643 Upstream seems to be inactive since 2009, but the entire library has 104 SLOC (including my additions, excluding the test suite) that I understand easily, so worst case I'll take it over there, or we'll carry the patch in Debian or in Tails. Will-fix: #7989 (just a first step)
Diffstat (limited to 'config/chroot_local-patches')
-rw-r--r--config/chroot_local-patches/Desktop-Notify:_0001-support_notification_actions.patch122
1 files changed, 122 insertions, 0 deletions
diff --git a/config/chroot_local-patches/Desktop-Notify:_0001-support_notification_actions.patch b/config/chroot_local-patches/Desktop-Notify:_0001-support_notification_actions.patch
new file mode 100644
index 0000000..7d41d92
--- /dev/null
+++ b/config/chroot_local-patches/Desktop-Notify:_0001-support_notification_actions.patch
@@ -0,0 +1,122 @@
+From e84e1f23168ebfb51fc73c272061c295ed9952d8 Mon Sep 17 00:00:00 2001
+From: intrigeri <intrigeri@boum.org>
+Date: Sun, 8 Mar 2015 23:22:02 +0000
+Subject: [PATCH] Add support for a user-defined function to be called whenever
+ an action is invoked.
+
+---
+ lib/Desktop/Notify.pm | 30 +++++++++++++++++++++++++++++-
+ lib/Desktop/Notify/Notification.pm | 18 +++++++++++-------
+ 2 files changed, 40 insertions(+), 8 deletions(-)
+
+diff --git a/lib/Desktop/Notify.pm b/lib/Desktop/Notify.pm
+index b8bb248..78f31d4 100644
+--- a/usr/share/perl5/Desktop/Notify.pm
++++ b/usr/share/perl5/Desktop/Notify.pm
+@@ -106,6 +106,8 @@ sub new {
+ $self->{app_name} = $opts{app_name} || basename($0);
+ $self->{notify}->connect_to_signal('NotificationClosed',
+ sub {$self->_close_cb(@_)});
++ $self->{notify}->connect_to_signal('ActionInvoked',
++ sub {$self->_action_cb(@_)});
+
+ bless $self, $class;
+ }
+@@ -140,6 +142,17 @@ sub _close_cb {
+ delete $self->{notes}->{$nid};
+ }
+
++sub _action_cb {
++ my ($self, $nid, $action_key) = @_;
++ print __PACKAGE__, ": action invoked\n";
++ if ($self->{action_callback})
++ {
++ print "invoking callback\n";
++ $self->{action_callback}->($self->{notes}->{$nid}, $action_key);
++ }
++ # delete $self->{notes}->{$nid};
++}
++
+ =head2 close_callback $coderef
+
+ Sets a user-specified function to be called whenever a notification is closed.
+@@ -151,10 +164,25 @@ just closed.
+ sub close_callback {
+ my ($self, $cb) = @_;
+
+- print "callback is $cb\n";
++ print "close callback is $cb\n";
+ $self->{close_callback} = $cb;
+ }
+
++=head2 action_callback $coderef
++
++Sets a user-specified function to be called whenever an action is invoked.
++It will be called with two arguments, which are the Notification object on which
++an action was invoked, and the key of the action invoked.
++
++=cut
++
++sub action_callback {
++ my ($self, $cb) = @_;
++
++ print "action callback is $cb\n";
++ $self->{action_callback} = $cb;
++}
++
+ =head1 AUTHOR
+
+ Stephen Cavilia, C<< <sac at atomicradi.us> >>
+diff --git a/lib/Desktop/Notify/Notification.pm b/lib/Desktop/Notify/Notification.pm
+index ee3fe4a..e7710e8 100644
+--- a/usr/share/perl5/Desktop/Notify/Notification.pm
++++ b/usr/share/perl5/Desktop/Notify/Notification.pm
+@@ -59,6 +59,7 @@ sub new {
+ my $self = \%params;
+ $self->{server} = $server;
+ $self->{id} = undef;
++ $self->{actions} ||= {};
+ bless $self, $class;
+ }
+
+@@ -81,7 +82,7 @@ sub show {
+ '',
+ $self->{summary},
+ $self->{body},
+- [],
++ [%{$self->{actions}}],
+ {},
+ $self->{timeout} || 0,
+ );
+@@ -125,6 +126,15 @@ The summary text briefly describing the notification.
+
+ The optional detailed body text. Can be empty.
+
++=item actions
++
++Actions are sent over as a list of pairs. Each even element in the list
++(starting at index 0) represents the identifier for the action. Each odd
++element in the list is the localized string that will be displayed to the user.
++
++A user-specified function to be called whenever an action is invoked can be
++specified with L<Desktop::Notify>'s L<action_callback> method.
++
+ =item timeout
+
+ The timeout time in milliseconds since the display of the notification at which
+@@ -145,12 +155,6 @@ supported by L<Desktop::Notify> at this time
+
+ The optional program icon of the calling application.
+
+-=item actions
+-
+-Actions are sent over as a list of pairs. Each even element in the list
+-(starting at index 0) represents the identifier for the action. Each odd
+-element in the list is the localized string that will be displayed to the user.
+-
+ =item hints
+
+ Optional hints that can be passed to the server from the client program.
+--
+2.1.4
+