diff --git a/src/manager_window.vala b/src/manager_window.vala index 436f82391f5600270fa12609f704ccc844dbe74c..5695474671800980bbf4dc6af9057ca83c4a0f7b 100644 --- a/src/manager_window.vala +++ b/src/manager_window.vala @@ -356,6 +356,7 @@ namespace Pamac { transaction.set_pkgreason_finished.connect (on_set_pkgreason_finished); transaction.generate_mirrors_list.connect (on_generate_mirrors_list); transaction.run_preferences_dialog_finished.connect (on_run_preferences_dialog_finished); + transaction.get_updates_progress.connect (on_get_updates_progress); transaction.get_updates_finished.connect (on_get_updates_finished); // integrate progress box and term widget @@ -2533,6 +2534,10 @@ namespace Pamac { transaction.start_refresh (force_refresh); } + void on_get_updates_progress (uint percent) { + checking_label.set_markup ("<big><b>%s %u %</b></big>".printf (dgettext (null, "Checking for Updates"), percent)); + } + void on_get_updates_finished (Updates updates) { repos_updates = updates.repos_updates; aur_updates = updates.aur_updates; diff --git a/src/transaction.vala b/src/transaction.vala index a4e03d1f0ffbfad71ce9f54a6b60c3205fad1b46..1c858fa2eb8c0b67ad38182c48a9243d4a05866f 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -52,6 +52,7 @@ namespace Pamac { public abstract void start_get_updates (bool check_aur_updates) throws IOError; [DBus (no_reply = true)] public abstract void quit () throws IOError; + public signal void emit_get_updates_progress (uint percent); public signal void get_updates_finished (Updates updates); } [DBus (name = "org.manjaro.pamac.system")] @@ -181,6 +182,7 @@ namespace Pamac { public signal void write_alpm_config_finished (bool checkspace); public signal void generate_mirrors_list (); public signal void run_preferences_dialog_finished (); + public signal void get_updates_progress (uint percent); public signal void get_updates_finished (Updates updates); public Transaction (Gtk.ApplicationWindow? application_window) { @@ -789,6 +791,7 @@ namespace Pamac { } public void start_get_updates () { + user_daemon.emit_get_updates_progress.connect (on_emit_get_updates_progress); user_daemon.get_updates_finished.connect (on_get_updates_finished); try { user_daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates); @@ -835,7 +838,13 @@ namespace Pamac { start_get_updates_for_sysupgrade (); } + void on_emit_get_updates_progress (uint percent) { + get_updates_progress (percent); + stdout.printf ("%u\n", percent); + } + void on_get_updates_finished (Updates updates) { + user_daemon.emit_get_updates_progress.disconnect (on_emit_get_updates_progress); user_daemon.get_updates_finished.disconnect (on_get_updates_finished); get_updates_finished (updates); } diff --git a/src/user_daemon.vala b/src/user_daemon.vala index fb56ddeffd6b315d23f5241a44af204268766c09..eee93351c389ac22c6f4e159701c8f3a80c4a316 100644 --- a/src/user_daemon.vala +++ b/src/user_daemon.vala @@ -94,6 +94,7 @@ namespace Pamac { private As.Store app_store; private string locale; + public signal void emit_get_updates_progress (uint percent); public signal void get_updates_finished (Updates updates); public UserDaemon () { @@ -1212,20 +1213,33 @@ namespace Pamac { // use a tmp handle var tmp_handle = alpm_config.get_handle (false, true); // refresh tmp dbs + // count this step as 45% of the total + emit_get_updates_progress (0); unowned Alpm.List<unowned Alpm.DB> syncdbs = tmp_handle.syncdbs; + size_t dbs_count = syncdbs.length; + size_t i = 0; while (syncdbs != null) { unowned Alpm.DB db = syncdbs.data; db.update (0); syncdbs.next (); + i++; + emit_get_updates_progress ((uint) ((double) i / dbs_count * (double) 45)); } // refresh file dbs + // count this step as 45% of the total var tmp_files_handle = alpm_config.get_handle (true, true); syncdbs = tmp_files_handle.syncdbs; + dbs_count = syncdbs.length; + i = 0; while (syncdbs != null) { unowned Alpm.DB db = syncdbs.data; db.update (0); syncdbs.next (); + i++; + emit_get_updates_progress ((uint) ((double) 45 + (double) i / dbs_count * (double) 45)); } + // check updates + // count this step as 5% of the total string[] local_pkgs = {}; unowned Alpm.List<unowned Alpm.Package> pkgcache = tmp_handle.localdb.pkgcache; while (pkgcache != null) { @@ -1257,8 +1271,10 @@ namespace Pamac { } pkgcache.next (); } + emit_get_updates_progress (95); if (check_aur_updates) { // get aur updates + // count this step as 5% of the total if (!aur_updates_checked) { AUR.multiinfo.begin (local_pkgs, (obj, res) => { var aur_updates_json = AUR.multiinfo.end (res); @@ -1268,6 +1284,7 @@ namespace Pamac { repos_updates = repos_updates, aur_updates = aur_updates }; + emit_get_updates_progress (100); get_updates_finished (updates); }); } else { @@ -1275,6 +1292,7 @@ namespace Pamac { repos_updates = repos_updates, aur_updates = aur_updates }; + emit_get_updates_progress (100); get_updates_finished (updates); } } else { @@ -1282,6 +1300,7 @@ namespace Pamac { repos_updates = repos_updates, aur_updates = {} }; + emit_get_updates_progress (100); get_updates_finished (updates); } return 0;