diff options
author | Frédéric Buclin <LpSolit@netscape.net> | 2017-03-11 19:45:14 +0100 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2017-03-13 17:37:45 +0100 |
commit | 74fafa20c2a11d9c59db1016342eca1d240d7ce7 (patch) | |
tree | 69e61d4314984d04ddee2550da4bb84fea7bab91 /mgaapplet | |
parent | 577d4f6312a8cbd3572ede4017202346bb5f85ed (diff) | |
download | mgaonline-74fafa20c2a11d9c59db1016342eca1d240d7ce7.tar mgaonline-74fafa20c2a11d9c59db1016342eca1d240d7ce7.tar.gz mgaonline-74fafa20c2a11d9c59db1016342eca1d240d7ce7.tar.bz2 mgaonline-74fafa20c2a11d9c59db1016342eca1d240d7ce7.tar.xz mgaonline-74fafa20c2a11d9c59db1016342eca1d240d7ce7.zip |
Use DBus Menu + StatusNotifier 1.0 (mga#20410)
Diffstat (limited to 'mgaapplet')
-rwxr-xr-x | mgaapplet | 34 |
1 files changed, 14 insertions, 20 deletions
@@ -42,11 +42,6 @@ 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)); if (!find { $_ eq '--auto-update' } @ARGV) { @@ -180,13 +175,16 @@ my ($icon, $is_plasma); # 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'); + + Glib::Object::Introspection->setup( + basename => 'StatusNotifier', + version => '1.0', + package => 'StatusNotifier'); + + $icon = StatusNotifier::Item->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; @@ -636,14 +634,6 @@ sub checkUpdates() { member($state_global, qw(disconnected)) or silentCheck(); } -sub go2State { - my ($state) = @_; - $menu->destroy if $menu; - $menu = setState($state); - $state_global = $state; - gtkflush(); -} - sub shouldStart() { to_bool($local_config{AUTOSTART} ne 'FALSE'); } @@ -672,7 +662,7 @@ sub about_dialog() { return 1; } -sub setState { +sub go2State { my ($state) = @_; my $checkme; state $previous_state; @@ -731,7 +721,8 @@ sub setState { warn ">> ERR:$@" if $@; } - my $menu = Gtk3::Menu->new; + $menu->destroy if $menu; + $menu = Gtk3::Menu->new; foreach (@arr) { my $action = $actions{$_}; next if !ref($action->{launch}); @@ -745,7 +736,10 @@ sub setState { $menu->append(gtksignal_connect(gtkset_active($checkme = Gtk3::CheckMenuItem->new_with_label(N("Always launch on startup")), shouldStart()), toggled => sub { setAutoStart(uc(bool2text($checkme->get_active))) })); $checkme->show; $menu->append(gtksignal_connect(gtkshow(Gtk3::MenuItem->new_with_label(N("Quit"))), activate => sub { mainQuit() })); - $menu; + + $icon->set_context_menu($menu) if $is_plasma; + $state_global = $state; + gtkflush(); } sub setAutoStart { |