summaryrefslogtreecommitdiffstats
path: root/mgaapplet
diff options
context:
space:
mode:
Diffstat (limited to 'mgaapplet')
-rwxr-xr-xmgaapplet68
1 files changed, 50 insertions, 18 deletions
diff --git a/mgaapplet b/mgaapplet
index 02b66b26..b4e9cec3 100755
--- a/mgaapplet
+++ b/mgaapplet
@@ -40,6 +40,12 @@ use mgaapplet_gui;
use Gtk3::Notify '-init', 'mgaapplet';
use Net::DBus qw(:typing);
use Rpmdrake::open_db;
+use Glib::Object::Introspection;
+
+Glib::Object::Introspection->setup(
+ basename => 'StatusNotifier',
+ version => '0.1',
+ package => 'StatusNotifier');
POSIX::sigprocmask(SIG_BLOCK, POSIX::SigSet->new(SIGCHLD));
@@ -169,12 +175,27 @@ 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, $is_plasma);
+# Plasma supports SNI natively. Other DE do not. In that case, we fall back to
+# the deprecated GtkStatusIcon.
+if ($ENV{DESKTOP_SESSION} =~ /plasma$/i) {
+ $is_plasma = 1;
+ $icon = StatusNotifier::Notifier->new_from_icon_name('mgaapplet', 'STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS', 'mgaonline');
+ $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;
+ });
+}
+else {
+ $icon = Gtk3::StatusIcon->new;
+ $icon->signal_connect(popup_menu => sub {
+ my ($_icon, $button, $time) = @_;
+ $menu->popup(undef, undef, undef, undef, $button, $time) if $menu;
+ });
+}
+
$icon->signal_connect(activate => sub {
my %click_actions = (
no_update_medium => \&add_media,
@@ -190,7 +211,7 @@ $icon->signal_connect(activate => sub {
}
$click_actions{$action}->() if ref $click_actions{$action};
- });
+ });
foreach my $opt (@ARGV) {
if (member($opt, qw(--force -f))) { setAutoStart('TRUE') }
if ($opt =~ /--(rpm-root|urpmi-root)=(.*)/) {
@@ -484,7 +505,7 @@ sub no_more_supported() {
if ($choice eq 'upgrade') {
really_confirm_upgrade() and real_upgrade();
} elsif ($choice eq 'nothing') {
- $icon->set_visible(0);
+ $is_plasma ? $icon->set_status('STATUS_NOTIFIER_STATUS_PASSIVE') : $icon->set_visible(0);
}
undef $no_more_supported_wip;
}
@@ -633,9 +654,9 @@ sub about_dialog() {
$url =~ s/^https:/http:/;
my $w = gtknew('AboutDialog', name => N("Mageia Online %s", $ver),
copyright => N("Copyright (C) %s by %s", 'Mandriva', '2001-2010') . "\n" .
- N("Copyright (C) %s by %s", 'Mageia', '2010-2016'),
+ N("Copyright (C) %s by %s", 'Mageia', '2010-2017'),
license => join('', cat_('/usr/share/common-licenses/GPL')),
- icon => '/usr/share/icons/mini/mgaonline.png',
+ icon => '/usr/share/icons/hicolor/48x48/apps/mgaonline.png',
comments => N("Mageia Online gives access to Mageia web services."),
website => $url,
website_label => N("Online WebSite"),
@@ -656,23 +677,34 @@ 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 @invisible_states = qw(delayed okay disconnected locked);
- $icon->set_visible(!member($state, @invisible_states));
+ my $icon_name = 'mgaonline-' . $state{$state}{colour}[0];
+ if ($is_plasma) {
+ $icon->set_from_icon_name('STATUS_NOTIFIER_ICON', $icon_name);
+ $icon->set_tooltip($icon_name, 'mgaapplet', formatAlaTeX(translate($state{$state}{tt}[0])));
+ }
+ else {
+ $icon_name = "/usr/share/icons/hicolor/scalable/actions/${icon_name}.svg";
+ $icon->set_from_pixbuf(gtkcreate_pixbuf($icon_name));
+ $icon->set_tooltip_text(formatAlaTeX(translate($state{$state}{tt}[0])));
+ }
+ my @invisible_states = qw(delayed okay disconnected locked);
# do not show icon while checking if previously hidden:
- $icon->set_visible(0) if $state eq 'busy' && member($previous_state, @invisible_states);
+ if (!$::testing && (member($state, @invisible_states) or $state eq 'busy' && member($previous_state, @invisible_states))) {
+ $is_plasma ? $icon->set_status('STATUS_NOTIFIER_STATUS_PASSIVE') : $icon->set_visible(0);
+ }
+ else {
+ $is_plasma ? $icon->set_status('STATUS_NOTIFIER_STATUS_ACTIVE') : $icon->set_visible(1);
+ }
$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');
+ '/usr/share/icons/hicolor/scalable/apps/mgaonline.svg');
if ($state eq 'new_distribution') {
$bubble->add_action('upgrade', N("More Information"), sub { upgrade() });
if ($sub_state eq 'updates') {