Use Net::DBus instead of Gtk2::Notify due to less dependencies; recommended by @beanz.

This commit is contained in:
Henrik Brix Andersen 2012-07-16 23:43:09 +02:00
parent 095607a166
commit 3690b0798e
2 changed files with 11 additions and 12 deletions

View file

@ -23,9 +23,9 @@ my $build = Module::Build->new(
'Test::More' => '0.10',
},
recommends => {
'Growl::GNTP' => '0.15',
'Gtk2::Notify' => '0.05',
'Wx' => '0.9901',
'Growl::GNTP' => '0.15',
'Net::DBus' => '0',
'Wx' => '0.9901',
},
script_files => ['slic3r.pl'],
);

View file

@ -334,13 +334,6 @@ sub new {
$self->{growler}->register([{Name => 'SKEIN_DONE', DisplayName => 'Slicing Done'}]);
};
}
if (eval 'use Gtk2::Notify; 1') {
# register with libnotify
eval {
Gtk2::Notify->init('Slic3r');
$self->{libnotify} = 1;
}
}
bless $self, $class;
@ -355,8 +348,14 @@ sub notify {
$self->{growler}->notify(Event => 'SKEIN_DONE', Title => $title, Message => $message)
if $self->{growler};
};
eval {
Gtk2::Notify->new($title, $message, $self->{icon})->show if $self->{libnotify};
if (eval 'use Net::DBus; 1') {
eval {
my $session = Net::DBus->session;
my $serv = $session->get_service('org.freedesktop.Notifications');
my $notifier = $serv->get_object('/org/freedesktop/Notifications',
'org.freedesktop.Notifications');
$notifier->Notify('Slic3r', 0, $self->{icon}, $title, $message, [], {}, 5);
}
};
}