Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option to disable tray feature [Suggestion from issue 433] #438

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion resources/preferences_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,23 @@
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="always_hide_icon_checkbutton">
<property name="label" translatable="yes">Always hide tray icon</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="margin_left">22</property>
<property name="hexpand">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkBox" id="ignorepkgs_box">
<property name="visible">True</property>
Expand Down Expand Up @@ -399,7 +416,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
</object>
Expand Down
21 changes: 21 additions & 0 deletions src/pamac_config.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Pamac {
public bool recurse { get; private set; }
public uint64 refresh_period { get; private set; }
public bool no_update_hide_icon { get; private set; }
public bool always_hide_icon { get; private set; }
public bool enable_aur { get; private set; }
public string aur_build_dir { get; private set; }
public bool check_aur_updates { get; private set; }
Expand Down Expand Up @@ -72,6 +73,7 @@ namespace Pamac {
// set default options
recurse = false;
no_update_hide_icon = false;
always_hide_icon = false;
enable_aur = false;
aur_build_dir = "/tmp";
check_aur_updates = false;
Expand Down Expand Up @@ -118,6 +120,8 @@ namespace Pamac {
rm_only_uninstalled = true;
} else if (key == "NoUpdateHideIcon") {
no_update_hide_icon = true;
} else if (key == "AlwaysHideIcon") {
always_hide_icon = true;
} else if (key == "EnableAUR") {
enable_aur = true;
} else if (key == "BuildDirectory") {
Expand Down Expand Up @@ -201,6 +205,17 @@ namespace Pamac {
} else {
data.append (line + "\n");
}
} else if (line.contains ("AlwaysHideIcon")) {
if (new_conf.lookup_extended ("AlwaysHideIcon", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("AlwaysHideIcon\n");
} else {
data.append ("#AlwaysHideIcon\n");
}
new_conf.remove ("AlwaysHideIcon");
} else {
data.append (line + "\n");
}
} else if (line.contains ("EnableAUR")) {
if (new_conf.lookup_extended ("EnableAUR", null, out variant)) {
if (variant.get_boolean ()) {
Expand Down Expand Up @@ -282,6 +297,12 @@ namespace Pamac {
} else {
data.append ("#NoUpdateHideIcon\n");
}
} else if (key =="AlwaysHideIcon") {
if (val.get_boolean ()) {
data.append ("AlwaysHideIcon\n");
} else {
data.append ("#AlwaysHideIcon\n");
}
} else if (key == "EnableAUR") {
if (val.get_boolean ()) {
data.append ("EnableAUR\n");
Expand Down
17 changes: 16 additions & 1 deletion src/preferences_dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace Pamac {
[GtkChild]
Gtk.CheckButton no_update_hide_icon_checkbutton;
[GtkChild]
Gtk.CheckButton always_hide_icon_checkbutton;
[GtkChild]
Gtk.CheckButton download_updates_checkbutton;
[GtkChild]
Gtk.Box ignorepkgs_box;
Expand Down Expand Up @@ -86,6 +88,7 @@ namespace Pamac {
refresh_period_spin_button.sensitive = false;
no_update_hide_icon_checkbutton.sensitive = false;
download_updates_checkbutton.sensitive = false;
always_hide_icon_checkbutton.sensitive = false;
ignorepkgs_box.sensitive = false;
} else {
check_updates_button.active = true;
Expand All @@ -94,6 +97,7 @@ namespace Pamac {
}
no_update_hide_icon_checkbutton.active = transaction.no_update_hide_icon;
download_updates_checkbutton.active = transaction.download_updates;
always_hide_icon_checkbutton.active = transaction.always_hide_icon;
cache_keep_nb_spin_button.value = transaction.keep_num_pkgs;
cache_only_uninstalled_checkbutton.active = transaction.rm_only_uninstalled;

Expand All @@ -110,6 +114,8 @@ namespace Pamac {
refresh_period_spin_button.value_changed.connect (on_refresh_period_spin_button_value_changed);
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
download_updates_checkbutton.toggled.connect (on_download_updates_checkbutton_toggled);
always_hide_icon_checkbutton.toggled.connect (on_always_hide_icon_checkbutton_toggled);

cache_keep_nb_spin_button.value_changed.connect (on_cache_keep_nb_spin_button_value_changed);
cache_only_uninstalled_checkbutton.toggled.connect (on_cache_only_uninstalled_checkbutton_toggled);
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
Expand Down Expand Up @@ -198,6 +204,12 @@ namespace Pamac {
new_pamac_conf.insert ("NoUpdateHideIcon", new Variant.boolean (no_update_hide_icon_checkbutton.active));
transaction.start_write_pamac_config (new_pamac_conf);
}

void on_always_hide_icon_checkbutton_toggled () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("AlwaysHideIcon", new Variant.boolean (always_hide_icon_checkbutton.active));
transaction.start_write_pamac_config (new_pamac_conf);
}

void on_download_updates_checkbutton_toggled () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
Expand All @@ -224,7 +236,7 @@ namespace Pamac {
transaction.start_write_pamac_config (new_pamac_conf);
}

void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, bool always_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates,
bool download_updates) {
remove_unrequired_deps_button.state = recurse;
Expand All @@ -233,6 +245,7 @@ namespace Pamac {
refresh_period_label.sensitive = false;
refresh_period_spin_button.sensitive = false;
no_update_hide_icon_checkbutton.sensitive = false;
always_hide_icon_checkbutton.sensitive = false;
download_updates_checkbutton.sensitive = false;
ignorepkgs_box.sensitive = false;
} else {
Expand All @@ -242,11 +255,13 @@ namespace Pamac {
previous_refresh_period = refresh_period;
refresh_period_spin_button.sensitive = true;
no_update_hide_icon_checkbutton.sensitive = true;
always_hide_icon_checkbutton.sensitive = true;
download_updates_checkbutton.sensitive = true;
ignorepkgs_box.sensitive = true;
}
no_update_hide_icon_checkbutton.active = no_update_hide_icon;
download_updates_checkbutton.active = download_updates;
always_hide_icon_checkbutton.active = always_hide_icon;
enable_aur_button.state = enable_aur;
aur_build_dir_label.sensitive = enable_aur;
aur_build_dir_file_chooser.sensitive = enable_aur;
Expand Down
9 changes: 5 additions & 4 deletions src/transaction.vala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Pamac {
public signal void trans_prepare_finished (bool success);
public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, bool always_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates,
bool download_updates);
public signal void write_alpm_config_finished (bool checkspace);
Expand Down Expand Up @@ -120,6 +120,7 @@ namespace Pamac {
public bool enable_aur { get { return pamac_config.enable_aur; } }
public unowned GLib.HashTable<string,string> environment_variables { get {return pamac_config.environment_variables; } }
public bool no_update_hide_icon { get { return pamac_config.no_update_hide_icon; } }
public bool always_hide_icon { get { return pamac_config.always_hide_icon; } }
public bool download_updates { get { return pamac_config.download_updates; } }
public bool recurse { get { return pamac_config.recurse; } }
public uint64 refresh_period { get { return pamac_config.refresh_period; } }
Expand Down Expand Up @@ -178,7 +179,7 @@ namespace Pamac {
public signal void important_details_outpout (bool must_show);
public signal void finished (bool success);
public signal void set_pkgreason_finished ();
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, bool always_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates,
bool download_updates);
public signal void write_alpm_config_finished (bool checkspace);
Expand Down Expand Up @@ -1820,15 +1821,15 @@ namespace Pamac {
set_pkgreason_finished ();
}

void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, bool always_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates) {
system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished);
pamac_config.reload ();
flags = (1 << 4); //Alpm.TransFlag.CASCADE
if (pamac_config.recurse) {
flags |= (1 << 5); //Alpm.TransFlag.RECURSE
}
write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon,
write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon, always_hide_icon,
enable_aur, aur_build_dir, check_aur_updates,
download_updates);
}
Expand Down
8 changes: 4 additions & 4 deletions src/tray-appindicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ namespace Pamac {
return indicator_status_icon.get_icon ();
}

public override void set_icon_visible (bool visible) {
if (visible) {
public override void set_icon_visible (bool visible, bool forceHide) {
if (visible && !forceHide) {
indicator_status_icon.set_status (AppIndicator.IndicatorStatus.ACTIVE);
} else {
indicator_status_icon.set_status (AppIndicator.IndicatorStatus.PASSIVE);
}
indicator_status_icon.set_status (AppIndicator.IndicatorStatus.PASSIVE);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tray-gtk.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ namespace Pamac {
return status_icon.get_icon_name ();
}

public override void set_icon_visible (bool visible) {
if (visible) {
public override void set_icon_visible (bool visible, bool forceHide) {
if (visible && !forceHide) {
status_icon.visible = true;
} else {
status_icon.visible = false;
Expand Down
15 changes: 11 additions & 4 deletions src/tray.vala
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace Pamac {

public abstract string get_icon ();

public abstract void set_icon_visible (bool visible);
public abstract void set_icon_visible (bool visible, bool forceHide);

bool check_updates () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
Expand All @@ -167,7 +167,7 @@ namespace Pamac {
if (updates_nb == 0) {
set_icon (noupdate_icon_name);
set_tooltip (noupdate_info);
set_icon_visible (!pamac_config.no_update_hide_icon);
set_icon_visible (!pamac_config.no_update_hide_icon, pamac_config.always_hide_icon);
close_notification ();
} else {
if (!check_pamac_running () && pamac_config.download_updates) {
Expand All @@ -190,10 +190,11 @@ namespace Pamac {
}

void show_or_update_notification () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
set_icon (update_icon_name);
set_tooltip (info);
set_icon_visible (true);
set_icon_visible (true, pamac_config.always_hide_icon);
if (check_pamac_running ()) {
update_notification (info);
} else {
Expand Down Expand Up @@ -312,7 +313,13 @@ namespace Pamac {
init_status_icon ();
set_icon (noupdate_icon_name);
set_tooltip (noupdate_info);
set_icon_visible (!pamac_config.no_update_hide_icon);

if (pamac_config.always_hide_icon) {
set_icon_visible(false, pamac_config.always_hide_icon);
}
else {
set_icon_visible (!pamac_config.no_update_hide_icon, pamac_config.always_hide_icon);
}

Notify.init (_("Package Manager"));

Expand Down