make updates unactivatable when a transaction is running

This commit is contained in:
guinux 2016-04-24 11:06:25 +02:00
parent f0ac44bc4f
commit 47b2c34db3

View File

@ -56,6 +56,8 @@ namespace Pamac {
public Pamac.Transaction transaction; public Pamac.Transaction transaction;
public bool transaction_running;
public UpdaterWindow (Gtk.Application application) { public UpdaterWindow (Gtk.Application application) {
Object (application: application); Object (application: application);
@ -66,6 +68,7 @@ namespace Pamac {
transaction_infobox.visible = false; transaction_infobox.visible = false;
stackswitcher.visible = false; stackswitcher.visible = false;
aur_scrolledwindow.visible = false; aur_scrolledwindow.visible = false;
transaction_running = false;
Timeout.add (100, populate_window); Timeout.add (100, populate_window);
} }
@ -111,36 +114,40 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
void on_repos_select_update_toggled (string path) { void on_repos_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path); if (!transaction_running) {
Gtk.TreeIter iter; Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
string pkgname; Gtk.TreeIter iter;
repos_updates_list.get_iter (out iter, treepath); string pkgname;
repos_updates_list.get (iter, 1, out pkgname); repos_updates_list.get_iter (out iter, treepath);
if (repos_select_update.active) { repos_updates_list.get (iter, 1, out pkgname);
repos_updates_list.set (iter, 0, false); if (repos_select_update.active) {
transaction.temporary_ignorepkgs.add (pkgname); repos_updates_list.set (iter, 0, false);
} else { transaction.temporary_ignorepkgs.add (pkgname);
repos_updates_list.set (iter, 0, true); } else {
transaction.temporary_ignorepkgs.remove (pkgname); repos_updates_list.set (iter, 0, true);
transaction.temporary_ignorepkgs.remove (pkgname);
}
set_transaction_infobox_visible ();
} }
set_transaction_infobox_visible ();
} }
[GtkCallback] [GtkCallback]
void on_aur_select_update_toggled (string path) { void on_aur_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path); if (!transaction_running) {
Gtk.TreeIter iter; Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
string pkgname; Gtk.TreeIter iter;
aur_updates_list.get_iter (out iter, treepath); string pkgname;
aur_updates_list.get (iter, 1, out pkgname); aur_updates_list.get_iter (out iter, treepath);
if (aur_select_update.active) { aur_updates_list.get (iter, 1, out pkgname);
aur_updates_list.set (iter, 0, false); if (aur_select_update.active) {
transaction.temporary_ignorepkgs.add (pkgname); aur_updates_list.set (iter, 0, false);
} else { transaction.temporary_ignorepkgs.add (pkgname);
aur_updates_list.set (iter, 0, true); } else {
transaction.temporary_ignorepkgs.remove (pkgname); aur_updates_list.set (iter, 0, true);
transaction.temporary_ignorepkgs.remove (pkgname);
}
set_transaction_infobox_visible ();
} }
set_transaction_infobox_visible ();
} }
[GtkCallback] [GtkCallback]
@ -152,6 +159,7 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
void on_apply_button_clicked () { void on_apply_button_clicked () {
transaction_running = true;
transaction.sysupgrade (false); transaction.sysupgrade (false);
details_button.visible = true; details_button.visible = true;
cancel_button.visible = true; cancel_button.visible = true;
@ -193,6 +201,7 @@ namespace Pamac {
} }
void populate_updates_list () { void populate_updates_list () {
transaction_running = false;
apply_button.visible = true; apply_button.visible = true;
apply_button.grab_default (); apply_button.grab_default ();
details_button.visible = false; details_button.visible = false;