From fc472978522a7224dd1e814caeebd3e80fdbd471 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sat, 11 Nov 2017 15:56:30 -0300 Subject: [PATCH] make tray icon config more effecient --- po/pamac.pot | 2 +- src/pamac-tray/tray.vala | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/po/pamac.pot b/po/pamac.pot index 154d915..9330e2c 100644 --- a/po/pamac.pot +++ b/po/pamac.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Pamac\n" "Report-Msgid-Bugs-To: cromer@cromnix.org\n" -"POT-Creation-Date: 2017-11-11 11:40-0300\n" +"POT-Creation-Date: 2017-11-11 15:55-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/pamac-tray/tray.vala b/src/pamac-tray/tray.vala index 053d72e..7c31514 100644 --- a/src/pamac-tray/tray.vala +++ b/src/pamac-tray/tray.vala @@ -45,7 +45,6 @@ namespace Pamac { UserDaemon daemon; bool extern_lock; uint refresh_timeout_id; - uint icon_timeout_id; public Gtk.Menu menu; GLib.File lockfile; bool updates_available; @@ -250,17 +249,17 @@ namespace Pamac { bool check_icon_hide_setting () { var pamac_config = new Pamac.Config (); if (!updates_available) { - set_icon_visible (!pamac_config.no_update_hide_icon); + if (get_icon_visible () && pamac_config.no_update_hide_icon) { + set_icon_visible (false); + } else if (!get_icon_visible () && !pamac_config.no_update_hide_icon) { + set_icon_visible (true); + } } return true; } void launch_icon_check_timeout () { - if (icon_timeout_id != 0) { - Source.remove (icon_timeout_id); - icon_timeout_id = 0; - } - icon_timeout_id = Timeout.add_seconds ((uint) 1, check_icon_hide_setting); + Timeout.add_seconds ((uint) 1, check_icon_hide_setting); } void launch_refresh_timeout (uint64 refresh_period_in_hours) { @@ -288,7 +287,6 @@ namespace Pamac { extern_lock = false; refresh_timeout_id = 0; - icon_timeout_id = 0; create_menu (); init_status_icon (); @@ -309,7 +307,6 @@ namespace Pamac { Timeout.add (200, check_extern_lock); // wait 30 seconds before check updates Timeout.add_seconds (30, () => { - check_icon_hide_setting (); check_updates (); return false; });