summaryrefslogtreecommitdiffstats
path: root/mgaapplet
diff options
context:
space:
mode:
Diffstat (limited to 'mgaapplet')
-rwxr-xr-xmgaapplet44
1 files changed, 32 insertions, 12 deletions
diff --git a/mgaapplet b/mgaapplet
index 02b66b26..f979b61d 100755
--- a/mgaapplet
+++ b/mgaapplet
@@ -40,6 +40,14 @@ use mgaapplet_gui;
use Gtk3::Notify '-init', 'mgaapplet';
use Net::DBus qw(:typing);
use Rpmdrake::open_db;
+use Glib::Object::Introspection;
+
+use constant IMAGE_FOLDER => '/usr/share/mgaonline/pixmaps/';
+
+Glib::Object::Introspection->setup(
+ basename => 'StatusNotifier',
+ version => '0.1',
+ package => 'StatusNotifier');
POSIX::sigprocmask(SIG_BLOCK, POSIX::SigSet->new(SIGCHLD));
@@ -169,11 +177,12 @@ my %actions = (
'upgrade_distro' => { name => N("Upgrade the system"), launch => \&upgrade },
);
-my $icon = Gtk3::StatusIcon->new;
-#$icon->shape_combine_mask($img, 0, 0);
-$icon->signal_connect(popup_menu => sub {
- my ($_icon, $button, $time) = @_;
- $menu and $menu->popup(undef, undef, undef, undef, $button, $time);
+my $icon = StatusNotifier::Notifier->new_from_icon_name('mgaapplet', 'STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS', '/usr/share/icons/mgaonline.png');
+$icon->set_title('mgaapplet');
+$icon->set_status('STATUS_NOTIFIER_STATUS_ACTIVE');
+$icon->register;
+$icon->signal_connect(context_menu => sub {
+ $menu->popup(undef, undef, undef, undef, 0, Gtk3::get_current_event_time()) if $menu;
});
$icon->signal_connect(activate => sub {
my %click_actions = (
@@ -231,6 +240,12 @@ Gtk3->main;
ugtk3::exit(0);
+sub img {
+ my $file = IMAGE_FOLDER . $_[0] . '.png';
+ warn "File $file not found.\n" unless -f $file;
+ return $file;
+}
+
sub gnome_shell_exit_overview() {
eval { Net::DBus->session->get_service('org.gnome.Shell')->get_object('/org/gnome/Shell', 'org.freedesktop.DBus.Properties')->Set('org.gnome.Shell', 'OverviewActive', dbus_boolean(0)) };
eval { Net::DBus->session->get_service('org.gnome.Shell')->get_object('/org/gnome/Shell', 'org.gnome.Shell')->Eval('Main.messageTray._trayState==2 && Main.messageTray.toggle();') };
@@ -484,7 +499,7 @@ sub no_more_supported() {
if ($choice eq 'upgrade') {
really_confirm_upgrade() and real_upgrade();
} elsif ($choice eq 'nothing') {
- $icon->set_visible(0);
+ $icon->set_status('STATUS_NOTIFIER_STATUS_PASSIVE');
}
undef $no_more_supported_wip;
}
@@ -656,20 +671,25 @@ sub setState {
my $checkme;
state $previous_state;
my @arr = @{$state{$state}{menu}};
- my $tmp = eval { gtkcreate_pixbuf($state{$state}{colour}[0]) };
- $icon->set_from_pixbuf($tmp) if $tmp;
- $icon->set_tooltip_text(formatAlaTeX(translate($state{$state}{tt}[0])));
+ my $icon_name = img($state{$state}{colour}[0]);
+ $icon->set_from_icon_name('STATUS_NOTIFIER_ICON', $icon_name) if $icon_name;
+ $icon->set_tooltip($icon_name, 'mgaapplet', formatAlaTeX(translate($state{$state}{tt}[0])));
my @invisible_states = qw(delayed okay disconnected locked);
- $icon->set_visible(!member($state, @invisible_states));
# do not show icon while checking if previously hidden:
- $icon->set_visible(0) if $state eq 'busy' && member($previous_state, @invisible_states);
+ if (member($state, @invisible_states)
+ or $state eq 'busy' && member($previous_state, @invisible_states)) {
+ $icon->set_status('STATUS_NOTIFIER_STATUS_PASSIVE');
+ }
+ else {
+ $icon->set_status('STATUS_NOTIFIER_STATUS_ACTIVE');
+ }
$previous_state = $state;
gtkflush(); # so that bubbles are displayed on right icon
- if ($state{$state}{tt}[0] && $icon->isa('Gtk3::StatusIcon') && !$state{$state}{do_not_use_bubble}) {
+ if ($state{$state}{tt}[0] && !$state{$state}{do_not_use_bubble}) {
$bubble->clear_actions;
$bubble->update(N("Warning"), formatAlaTeX(translate($state{$state}{tt}[0])) . "\n",
'/usr/share/icons/mgaonline.png');