change config to gsettings

This commit is contained in:
2017-11-10 22:36:50 -03:00
parent e8a11f6960
commit 00f4092ee4
35 changed files with 347 additions and 545 deletions

View File

@@ -45,8 +45,10 @@ 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;
public TrayIcon () {
application_id = "org.pamac.tray";
@@ -116,10 +118,12 @@ namespace Pamac {
public abstract string get_icon ();
public abstract bool get_icon_visible ();
public abstract void set_icon_visible (bool visible);
bool check_updates () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
var pamac_config = new Pamac.Config ();
if (pamac_config.refresh_period != 0) {
try {
#if DISABLE_AUR
@@ -141,12 +145,14 @@ namespace Pamac {
uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
#endif
if (updates_nb == 0) {
updates_available = false;
set_icon (noupdate_icon_name);
set_tooltip (noupdate_info);
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
var pamac_config = new Pamac.Config ();
set_icon_visible (!pamac_config.no_update_hide_icon);
close_notification ();
} else {
updates_available = true;
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
set_icon (update_icon_name);
set_tooltip (info);
@@ -241,6 +247,22 @@ namespace Pamac {
return true;
}
bool check_icon_hide_setting () {
var pamac_config = new Pamac.Config ();
if (!updates_available) {
set_icon_visible (!pamac_config.no_update_hide_icon);
}
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);
}
void launch_refresh_timeout (uint64 refresh_period_in_hours) {
if (refresh_timeout_id != 0) {
Source.remove (refresh_timeout_id);
@@ -256,7 +278,7 @@ namespace Pamac {
Intl.textdomain ("pamac");
Intl.setlocale (LocaleCategory.ALL, "");
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
var pamac_config = new Pamac.Config ();
// if refresh period is 0, just return so tray will exit
if (pamac_config.refresh_period == 0) {
return;
@@ -266,6 +288,7 @@ namespace Pamac {
extern_lock = false;
refresh_timeout_id = 0;
icon_timeout_id = 0;
create_menu ();
init_status_icon ();
@@ -286,9 +309,11 @@ 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;
});
launch_icon_check_timeout ();
launch_refresh_timeout (pamac_config.refresh_period);
this.hold ();