update displayed strings

This commit is contained in:
guinux
2014-10-26 12:30:04 +01:00
parent 03638f6375
commit a2d248bc2d
15 changed files with 661 additions and 353 deletions

View File

@@ -22,7 +22,7 @@ using Pamac;
using Polkit;
// i18n
const string GETTEXT_PACKAGE = "pacman";
const string GETTEXT_PACKAGE = "pamac";
PamacServer server;
MainLoop loop;
@@ -41,9 +41,9 @@ public class PamacServer : Object {
public Mutex provider_mutex;
public int? choosen_provider;
public signal void emit_event (uint event, string msg);
public signal void emit_event (uint event, string[] details);
public signal void emit_providers (string depend, string[] providers);
public signal void emit_progress (uint progress, string action, string pkgname, int percent, uint n_targets, uint current_target);
public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total);
public signal void emit_totaldownload (uint64 total);
public signal void emit_log (uint level, string msg);
@@ -91,6 +91,10 @@ public class PamacServer : Object {
}
}
public void refresh_alpm_config () {
get_handle ();
}
private void refresh_real () {
ErrorInfos err = ErrorInfos ();
string[] details = {};
@@ -106,17 +110,21 @@ public class PamacServer : Object {
// We should always succeed if at least one DB was upgraded - we may possibly
// fail later with unresolved deps, but that should be rare, and would be expected
if (success == 0) {
err.str = _("failed to synchronize any databases\n");
details += Alpm.strerror (alpm_config.handle.errno ()) + "\n";
err.str = _("Failed to synchronize any databases");
details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details;
}
trans_release ();
get_handle ();
if (emit_refreshed_signal)
emit_refreshed (err);
else
emit_refreshed_signal = true;
} else {
err.str = _("Failed to synchronize any databases");
details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details;
}
if (emit_refreshed_signal)
emit_refreshed (err);
else
emit_refreshed_signal = true;
}
public async void refresh (int force, bool emit_signal) {
@@ -148,25 +156,31 @@ public class PamacServer : Object {
public ErrorInfos trans_init (TransFlag transflags) {
ErrorInfos err = ErrorInfos ();
string[] details = {};
int ret = alpm_config.handle.trans_init (transflags);
if (ret == -1) {
//err = _("failed to init transaction (%s)\n").printf (Alpm.strerror (errno));
err.str = Alpm.strerror (alpm_config.handle.errno ()) + "\n";
err.str = _("Failed to init transaction");
details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details;
}
return err;
}
public ErrorInfos trans_sysupgrade (int enable_downgrade) {
ErrorInfos err = ErrorInfos ();
string[] details = {};
int ret = alpm_config.handle.trans_sysupgrade (enable_downgrade);
if (ret == -1) {;
err.str = Alpm.strerror (alpm_config.handle.errno ()) + "\n";
err.str = _("Failed to prepare transaction");
details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details;
}
return err;
}
public ErrorInfos trans_add_pkg (string pkgname) {
ErrorInfos err = ErrorInfos ();
string[] details = {};
unowned Package? pkg = null;
//pkg = alpm_config.handle.find_dbs_satisfier (syncdbs, pkgname);
foreach (var db in syncdbs) {
@@ -175,7 +189,9 @@ public class PamacServer : Object {
break;
}
if (pkg == null) {
err.str = _("target not found: %s\n").printf (pkgname);
err.str = _("Failed to prepare transaction");
details += _("target not found: %s").printf (pkgname);
err.details = details;
return err;
}
int ret = alpm_config.handle.trans_add_pkg (pkg);
@@ -185,7 +201,9 @@ public class PamacServer : Object {
// just skip duplicate or ignored targets
return err;
else {
err.str = "'%s': %s\n".printf (pkg.name, Alpm.strerror (errno));
err.str = _("Failed to prepare transaction");
details += "%s: %s".printf (pkg.name, Alpm.strerror (errno));
err.details = details;
return err;
}
}
@@ -194,19 +212,24 @@ public class PamacServer : Object {
public ErrorInfos trans_load_pkg (string pkgpath) {
ErrorInfos err = ErrorInfos ();
string[] details = {};
unowned Package? pkg = alpm_config.handle.load_file (pkgpath, 1, alpm_config.handle.localfilesiglevel);
if (pkg == null) {
err.str = "'%s': %s\n".printf (pkgpath, Alpm.strerror (alpm_config.handle.errno ()));
err.str = _("Failed to prepare transaction");
details += "%s: %s".printf (pkgpath, Alpm.strerror (alpm_config.handle.errno ()));
err.details = details;
return err;
} else {
int ret = alpm_config.handle.trans_add_pkg (pkg);
if (ret == -1) {
Alpm.Errno errno = alpm_config.handle.errno ();
if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED) {
if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED)
// just skip duplicate or ignored targets
return err;
} else {
err.str = "'%s': %s\n".printf (pkg.name, Alpm.strerror (errno));
else {
err.str = _("Failed to prepare transaction");
details += "%s: %s".printf (pkg.name, Alpm.strerror (errno));
err.details = details;
return err;
}
}
@@ -216,14 +239,19 @@ public class PamacServer : Object {
public ErrorInfos trans_remove_pkg (string pkgname) {
ErrorInfos err = ErrorInfos ();
string[] details = {};
unowned Package? pkg = localdb.get_pkg (pkgname);
if (pkg == null) {
err.str = _("target not found: %s\n").printf (pkgname);
err.str = _("Failed to prepare transaction");
details += _("target not found: %s").printf (pkgname);
err.details = details;
return err;
}
int ret = alpm_config.handle.trans_remove_pkg (pkg);
if (ret == -1) {
err.str = "'%s': %s\n".printf (pkg.name, Alpm.strerror (alpm_config.handle.errno ()));
err.str = _("Failed to prepare transaction");
details += "%s: %s".printf (pkg.name, Alpm.strerror (alpm_config.handle.errno ()));
err.details = details;
}
return err;
}
@@ -235,39 +263,60 @@ public class PamacServer : Object {
int ret = alpm_config.handle.trans_prepare (out err_data);
if (ret == -1) {
Alpm.Errno errno = alpm_config.handle.errno ();
//err = _("failed to prepare transaction (%s)\n").printf ();
err.str = Alpm.strerror (errno) + "\n";
err.str = _("Failed to prepare transaction");
string detail = Alpm.strerror (errno);
switch (errno) {
case Errno.PKG_INVALID_ARCH:
detail += ":";
details += detail;
foreach (void *i in err_data) {
char *pkgname = i;
details += _("package %s does not have a valid architecture\n").printf (pkgname);
details += _("package %s does not have a valid architecture").printf (pkgname);
}
break;
case Errno.UNSATISFIED_DEPS:
detail += ":";
details += detail;
foreach (void *i in err_data) {
DepMissing *miss = i;
string depstring = miss->depend.compute_string ();
details += _("%s: requires %s\n").printf (miss->target, depstring);
details += _("%s: requires %s").printf (miss->target, depstring);
}
break;
case Errno.CONFLICTING_DEPS:
detail += ":";
details += detail;
foreach (void *i in err_data) {
Conflict *conflict = i;
detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2);
// only print reason if it contains new information
if (conflict->reason.mod == DepMod.ANY)
details += _("%s and %s are in conflict\n").printf (conflict->package1, conflict->package2);
else {
string reason = conflict->reason.compute_string ();
details += _("%s and %s are in conflict (%s)\n").printf (conflict->package1, conflict->package2, reason);
if (conflict->reason.mod != DepMod.ANY) {
detail += " (%s)".printf (conflict->reason.compute_string ());
}
details += detail;
}
break;
default:
details += detail;
break;
}
err.details = details;
trans_release ();
} else {
// Search for holdpkg in target list
bool found_locked_pkg = false;
foreach (unowned Package pkg in alpm_config.handle.trans_to_remove ()) {
if (pkg.name in alpm_config.holdpkg) {
details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
found_locked_pkg = true;
break;
}
}
if (found_locked_pkg) {
err.str = _("Failed to prepare transaction");
err.details = details;
trans_release ();
}
}
emit_trans_prepared (err);
}
@@ -326,22 +375,24 @@ public class PamacServer : Object {
int ret = alpm_config.handle.trans_commit (out err_data);
if (ret == -1) {
Alpm.Errno errno = alpm_config.handle.errno ();
//err = _("failed to commit transaction (%s)\n").printf (Alpm.strerror (errno));
err.str = Alpm.strerror (errno) + "\n";
err.str = _("Failed to commit transaction");
string detail = Alpm.strerror (errno);
switch (errno) {
case Alpm.Errno.FILE_CONFLICTS:
TransFlag flags = alpm_config.handle.trans_get_flags ();
if ((flags & TransFlag.FORCE) != 0) {
details += _("unable to %s directory-file conflicts\n").printf ("--force");
}
detail += ":";
details += detail;
//TransFlag flags = alpm_config.handle.trans_get_flags ();
//if ((flags & TransFlag.FORCE) != 0) {
//details += _("unable to %s directory-file conflicts").printf ("--force");
//}
foreach (void *i in err_data) {
FileConflict *conflict = i;
switch (conflict->type) {
case FileConflictType.TARGET:
details += _("%s exists in both '%s' and '%s'\n").printf (conflict->file, conflict->target, conflict->ctarget);
details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget);
break;
case FileConflictType.FILESYSTEM:
details += _("%s: %s exists in filesystem\n").printf (conflict->target, conflict->file);
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
break;
}
}
@@ -350,12 +401,15 @@ public class PamacServer : Object {
case Alpm.Errno.PKG_INVALID_CHECKSUM:
case Alpm.Errno.PKG_INVALID_SIG:
case Alpm.Errno.DLT_INVALID:
detail += ":";
details += detail;
foreach (void *i in err_data) {
char *filename = i;
details += _("%s is invalid or corrupted\n").printf (filename);
details += _("%s is invalid or corrupted").printf (filename);
}
break;
default:
details += detail;
break;
}
err.details = details;
@@ -379,7 +433,7 @@ public class PamacServer : Object {
new Thread<void*>.try ("commit thread", (ThreadFunc) trans_commit_real);
} else {
ErrorInfos err = ErrorInfos ();
err.str = "Not Authorized\n";
err.str = dgettext ("pamac", "Authentication failed");
emit_trans_committed (err);
trans_release ();
}
@@ -416,143 +470,105 @@ private void write_log_file (string event) {
// writing a short string to the stream
dos.put_string (log);
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
stderr.printf("%s\n", e.message);
}
}
private void cb_event (Event event, void *data1, void *data2) {
string event_str = null;
string[] details = {};
switch (event) {
case Event.CHECKDEPS_START:
event_str = _("checking dependencies...\n");
break;
case Event.FILECONFLICTS_START:
event_str = _("checking for file conflicts...\n");
break;
case Event.RESOLVEDEPS_START:
event_str = _("resolving dependencies...\n");
break;
case Event.INTERCONFLICTS_START:
event_str = _("looking for inter-conflicts...\n");
break;
case Event.ADD_START:
case Event.REMOVE_START:
case Event.REINSTALL_START:
unowned Package pkg = (Package) data1;
event_str = _("installing %s...\n").printf ("%s (%s)".printf (pkg.name, pkg.version));
details += pkg.name;
details += pkg.version;
break;
case Event.ADD_DONE:
unowned Package pkg = (Package) data1;
string log = "installed %s (%s)\n".printf (pkg.name, pkg.version);
string log = "Installed %s (%s)\n".printf (pkg.name, pkg.version);
write_log_file (log);
break;
case Event.REMOVE_START:
unowned Package pkg = (Package) data1;
event_str = _("removing %s...\n").printf ("%s (%s)".printf (pkg.name, pkg.version));
break;
case Event.REMOVE_DONE:
unowned Package pkg = (Package) data1;
string log = "removed %s (%s)\n".printf (pkg.name, pkg.version);
string log = "Removed %s (%s)\n".printf (pkg.name, pkg.version);
write_log_file (log);
break;
case Event.REINSTALL_DONE:
unowned Package pkg = (Package) data1;
string log = "Reinstalled %s (%s)\n".printf (pkg.name, pkg.version);
write_log_file (log);
break;
case Event.UPGRADE_START:
case Event.DOWNGRADE_START:
unowned Package new_pkg = (Package) data1;
unowned Package old_pkg = (Package) data2;
event_str = _("upgrading %s...\n").printf ("%s (%s -> %s)".printf (old_pkg.name, old_pkg.version, new_pkg.version));
details += old_pkg.name;
details += old_pkg.version;
details += new_pkg.version;
break;
case Event.UPGRADE_DONE:
unowned Package new_pkg = (Package) data1;
unowned Package old_pkg = (Package) data2;
string log = _("upgraded %s (%s -> %s)\n").printf (old_pkg.name, old_pkg.version, new_pkg.version);
string log = "Upgraded %s (%s -> %s)\n".printf (old_pkg.name, old_pkg.version, new_pkg.version);
write_log_file (log);
break;
case Event.DOWNGRADE_START:
unowned Package new_pkg = (Package) data1;
unowned Package old_pkg = (Package) data2;
event_str = _("downgrading %s...\n").printf ("%s (%s -> %s)".printf (old_pkg.name, old_pkg.version, new_pkg.version));
break;
case Event.DOWNGRADE_DONE:
unowned Package new_pkg = (Package) data1;
unowned Package old_pkg = (Package) data2;
string log = _("downgraded %s (%s -> %s)\n").printf (old_pkg.name, old_pkg.version, new_pkg.version);
string log = "Downgraded %s (%s -> %s)\n".printf (old_pkg.name, old_pkg.version, new_pkg.version);
write_log_file (log);
break;
case Event.REINSTALL_START:
unowned Package pkg = (Package) data1;
event_str = _("reinstalling %s...\n").printf ("%s (%s)".printf (pkg.name, pkg.version));
break;
case Event.REINSTALL_DONE:
unowned Package pkg = (Package) data1;
string log = "reinstalled %s (%s)\n".printf (pkg.name, pkg.version);
write_log_file (log);
break;
case Event.INTEGRITY_START:
event_str = _("checking package integrity...\n");
break;
case Event.KEYRING_START:
event_str = _("checking keyring...\n");
break;
case Event.KEY_DOWNLOAD_START:
event_str = _("downloading required keys...\n");
break;
case Event.LOAD_START:
event_str = _("loading package files...\n");
break;
case Event.DELTA_INTEGRITY_START:
event_str = _("checking delta integrity...\n");
break;
case Event.DELTA_PATCHES_START:
event_str = _("applying deltas...\n");
break;
case Event.DELTA_PATCH_START:
unowned string string1 = (string) data1;
unowned string string2 = (string) data2;
event_str = _("generating %s with %s... ").printf (string1, string2);
break;
case Event.DELTA_PATCH_DONE:
event_str = _("success!\n");
break;
case Event.DELTA_PATCH_FAILED:
event_str = _("failed.\n");
details += string1;
details += string2;
break;
case Event.SCRIPTLET_INFO:
unowned string info = (string) data1;
event_str = info;
write_log_file (event_str);
break;
case Event.RETRIEVE_START:
event_str = _("Retrieving packages ...\n");
break;
case Event.DISKSPACE_START:
event_str = _("checking available disk space...\n");
details += info;
write_log_file (info);
break;
case Event.OPTDEP_REQUIRED:
unowned Package pkg = (Package) data1;
Depend *depend = data2;
event_str = _("%s optionally requires %s\n").printf (pkg.name, depend->compute_string ());
details += pkg.name;
details += depend->compute_string ();
break;
case Event.DATABASE_MISSING:
event_str = _("database file for '%s' does not exist\n").printf ((char *) data1);
break;
/* all the simple done events, with fallthrough for each */
case Event.FILECONFLICTS_DONE:
case Event.CHECKDEPS_DONE:
case Event.RESOLVEDEPS_DONE:
case Event.INTERCONFLICTS_DONE:
case Event.INTEGRITY_DONE:
case Event.KEYRING_DONE:
case Event.KEY_DOWNLOAD_DONE:
case Event.LOAD_DONE:
case Event.DELTA_INTEGRITY_DONE:
case Event.DELTA_PATCHES_DONE:
case Event.DISKSPACE_DONE:
/* nothing */
unowned string db_name = (string) data1;
details += db_name;
break;
//~ case Event.CHECKDEPS_START:
//~ case Event.CHECKDEPS_DONE:
//~ case Event.FILECONFLICTS_START:
//~ case Event.FILECONFLICTS_DONE:
//~ case Event.RESOLVEDEPS_START:
//~ case Event.RESOLVEDEPS_DONE:
//~ case Event.INTERCONFLICTS_START:
//~ case Event.INTERCONFLICTS_DONE:
//~ case Event.INTEGRITY_START:
//~ case Event.INTEGRITY_DONE:
//~ case Event.KEYRING_START:
//~ case Event.KEYRING_DONE:
//~ case Event.KEY_DOWNLOAD_START:
//~ case Event.KEY_DOWNLOAD_DONE:
//~ case Event.LOAD_START:
//~ case Event.LOAD_DONE:
//~ case Event.DELTA_INTEGRITY_START:
//~ case Event.DELTA_INTEGRITY_DONE:
//~ case Event.DELTA_PATCHES_START:
//~ case Event.DELTA_PATCHES_DONE:
//~ case Event.DELTA_PATCH_DONE:
//~ case Event.DELTA_PATCH_FAILED:
//~ case Event.RETRIEVE_START:
//~ case Event.DISKSPACE_START:
//~ case Event.DISKSPACE_DONE:
default:
event_str = "unknown event";
break;
}
if (event_str != null)
server.emit_event ((uint) event, event_str);
server.emit_event ((uint) event, details);
}
private void cb_question (Question question, void *data1, void *data2, void *data3, out int response) {
@@ -610,44 +626,23 @@ private void cb_question (Question question, void *data1, void *data2, void *dat
}
private void cb_progress (Progress progress, string pkgname, int percent, uint n_targets, uint current_target) {
string action = "";
switch (progress) {
case Progress.ADD_START:
action = _("installing");
break;
case Progress.UPGRADE_START:
action = _("upgrading");
break;
case Progress.DOWNGRADE_START:
action = _("downgrading");
break;
case Progress.REINSTALL_START:
action = _("reinstalling");
break;
case Progress.REMOVE_START:
action = _("removing");
break;
case Progress.CONFLICTS_START:
action = _("checking for file conflicts");
break;
case Progress.DISKSPACE_START:
action = _("checking available disk space");
break;
case Progress.INTEGRITY_START:
action = _("checking package integrity");
break;
case Progress.KEYRING_START:
action = _("checking keys in keyring");
break;
case Progress.LOAD_START:
action = _("loading package files");
break;
default:
break;
}
//~ switch (progress) {
//~ case Progress.ADD_START:
//~ case Progress.UPGRADE_START:
//~ case Progress.DOWNGRADE_START:
//~ case Progress.REINSTALL_START:
//~ case Progress.REMOVE_START:
//~ case Progress.CONFLICTS_START:
//~ case Progress.DISKSPACE_START:
//~ case Progress.INTEGRITY_START:
//~ case Progress.KEYRING_START:
//~ case Progress.LOAD_START:
//~ default:
//~ break;
//~ }
if ((uint64) percent != server.previous_percent) {
server.previous_percent = (uint64) percent;
server.emit_progress ((uint) progress, action, pkgname, percent, n_targets, current_target);
server.emit_progress ((uint) progress, pkgname, percent, n_targets, current_target);
}
}

View File

@@ -249,7 +249,7 @@ namespace Pamac {
if (satisfier != null)
optdep_str = optdep_str + " [" + dgettext (null, "Installed") + "]";
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Optional Deps") + ":",
0, dgettext (null, "Optional Dependencies") + ":",
1, optdep_str);
i = 1;
while (i < len) {
@@ -885,7 +885,7 @@ namespace Pamac {
this,
"program_name", "Pamac",
"logo_icon_name", "system-software-install",
"comments", "A GTK3 frontend of libalpm",
"comments", dgettext (null, "A Gtk3 frontend for libalpm"),
"copyright", "Copyright © 2014 Guillaume Benoit",
"version", VERSION,
"license_type", License.GPL_3_0,
@@ -916,6 +916,7 @@ namespace Pamac {
}
public void on_emit_trans_finished (bool error) {
print ("transaction finished\n");
if (error == false) {
set_buttons_sensitive (false);
refresh_packages_list ();

View File

@@ -52,8 +52,9 @@ namespace Pamac {
public void on_cancel_button_clicked () {
transaction.cancel ();
transaction.clear_lists ();
transaction.finished (false);
transaction.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
this.hide ();
transaction.finished (false);
while (Gtk.events_pending ())
Gtk.main_iteration ();
}

View File

@@ -25,6 +25,7 @@ namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
public abstract void write_config (HashTable<string,string> new_conf) throws IOError;
public abstract void refresh_alpm_config () throws IOError;
public abstract async void refresh (int force, bool emit_signal) throws IOError;
public abstract ErrorInfos trans_init (TransFlag transflags) throws IOError;
public abstract ErrorInfos trans_sysupgrade (int enable_downgrade) throws IOError;
@@ -37,12 +38,13 @@ namespace Pamac {
public abstract UpdatesInfos[] trans_to_remove () throws IOError;
public abstract async void trans_commit () throws IOError;
public abstract void trans_release () throws IOError;
[DBus (no_reply = true)]
public abstract void trans_cancel () throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
public signal void emit_event (uint event, string msg);
public signal void emit_event (uint event, string[] details);
public signal void emit_providers (string depend, string[] providers);
public signal void emit_progress (uint progress, string action, string pkgname, int percent, uint n_targets, uint current_target);
public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total);
public signal void emit_totaldownload (uint64 total);
public signal void emit_log (uint level, string msg);
@@ -69,6 +71,7 @@ namespace Pamac {
uint build_timeout_id;
bool sysupgrade_after_trans;
bool sysupgrade_after_build;
int build_status;
Terminal term;
Pty pty;
@@ -132,6 +135,7 @@ namespace Pamac {
previous_filename = "";
sysupgrade_after_trans = false;
sysupgrade_after_build = false;
build_status = 0;
}
public void write_config (HashTable<string,string> new_conf) {
@@ -147,13 +151,13 @@ namespace Pamac {
}
public void refresh (int force) {
string action = dgettext ("pacman", "Synchronizing package databases...\n").replace ("\n", "");
spawn_in_term ({"/usr/bin/echo", action}, null);
string action = dgettext (null, "Synchronizing package databases") + "...";
spawn_in_term ({"/usr/bin/echo", action});
progress_window.action_label.set_text (action);
progress_window.progressbar.set_fraction (0);
progress_window.progressbar.set_text ("");
progress_window.cancel_button.visible = true;
progress_window.close_button.visible = false;
progress_window.cancel_button.set_visible (true);
progress_window.close_button.set_visible (false);
progress_window.show ();
daemon.refresh.begin (force, true, (obj, res) => {
try {
@@ -165,9 +169,9 @@ namespace Pamac {
}
public void sysupgrade_simple (int enable_downgrade) {
print("simple sysupgrade\n");
print ("simple sysupgrade\n");
progress_window.progressbar.set_fraction (0);
progress_window.cancel_button.visible = true;
progress_window.cancel_button.set_visible (true);
ErrorInfos err = ErrorInfos ();
try {
err = daemon.trans_init (0);
@@ -203,17 +207,17 @@ namespace Pamac {
}
public void sysupgrade (int enable_downgrade) {
string action = dgettext ("pacman", "Starting full system upgrade...\n").replace ("\n", "");
spawn_in_term ({"/usr/bin/echo", action}, null);
string action = dgettext (null, "Starting full system upgrade") + "...";
spawn_in_term ({"/usr/bin/echo", action});
progress_window.action_label.set_text (action);
progress_window.progressbar.set_fraction (0);
progress_window.progressbar.set_text ("");
progress_window.cancel_button.visible = true;
progress_window.close_button.visible = false;
progress_window.cancel_button.set_visible (true);
progress_window.close_button.set_visible (false);
while (Gtk.events_pending ())
Gtk.main_iteration ();
// sysupgrade
print("get syncfirst\n");
print ("get syncfirst\n");
// get syncfirst updates
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (alpm_config);
if (syncfirst_updates.length != 0) {
@@ -226,7 +230,7 @@ namespace Pamac {
run ();
} else {
if (pamac_config.enable_aur) {
print("get aur updates\n");
print ("get aur updates\n");
string[] ignore_pkgs = get_ignore_pkgs (alpm_config);
UpdatesInfos[] aur_updates = get_aur_updates (alpm_config, ignore_pkgs);
if (aur_updates.length != 0) {
@@ -248,12 +252,12 @@ namespace Pamac {
public void run () {
string action = dgettext (null,"Preparing") + "...";
spawn_in_term ({"/usr/bin/echo", action}, null);
spawn_in_term ({"/usr/bin/echo", action});
progress_window.action_label.set_text (action);
progress_window.progressbar.set_fraction (0);
progress_window.progressbar.set_text ("");
progress_window.cancel_button.visible = true;
progress_window.close_button.visible = false;
progress_window.cancel_button.set_visible (true);
progress_window.close_button.set_visible (false);
progress_window.show ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
@@ -321,7 +325,7 @@ namespace Pamac {
public void choose_provider (string depend, string[] providers) {
int len = providers.length;
choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s:").printf (depend, len)));
choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend, len)));
choose_provider_dialog.comboboxtext.remove_all ();
foreach (string provider in providers)
choose_provider_dialog.comboboxtext.append_text (provider);
@@ -458,14 +462,13 @@ namespace Pamac {
if (dsize == 0)
transaction_sum_dialog.bottom_label.set_visible (false);
else {
transaction_sum_dialog.bottom_label.set_markup ("<b>%s %s</b>".printf (dgettext (null, "Total download size:"), format_size (dsize)));
transaction_sum_dialog.bottom_label.set_markup ("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size (dsize)));
transaction_sum_dialog.bottom_label.set_visible (true);
}
return ret;
}
public void commit () {
progress_window.cancel_button.visible = false;
daemon.trans_commit.begin ((obj, res) => {
try {
daemon.trans_commit.end (res);
@@ -478,12 +481,12 @@ namespace Pamac {
public void build_aur_packages () {
print ("building packages\n");
string action = dgettext (null,"Building packages") + "...";
spawn_in_term ({"/usr/bin/echo", "-n", action}, null);
spawn_in_term ({"/usr/bin/echo", "-n", action});
progress_window.action_label.set_text (action);
progress_window.progressbar.set_fraction (0);
progress_window.progressbar.set_text ("");
progress_window.cancel_button.visible = false;
progress_window.close_button.visible = false;
progress_window.cancel_button.set_visible (false);
progress_window.close_button.set_visible (false);
progress_window.expander.set_expanded (true);
progress_window.width_request = 700;
term.grab_focus ();
@@ -521,7 +524,7 @@ namespace Pamac {
}
}
void spawn_in_term (string[] args, out int pid) {
public void spawn_in_term (string[] args, out int pid = null) {
try {
Process.spawn_async (null, args, null, SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out pid);
} catch (SpawnError e) {
@@ -530,91 +533,147 @@ namespace Pamac {
term.set_pty (pty);
}
void on_emit_event (uint event, string msg) {
void on_emit_event (uint event, string[] details) {
string msg;
switch (event) {
case Event.CHECKDEPS_START:
msg = dgettext (null, "Checking dependencies") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.FILECONFLICTS_START:
msg = dgettext (null, "Checking file conflicts") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.RESOLVEDEPS_START:
msg = dgettext (null, "Resolving dependencies") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.INTERCONFLICTS_START:
msg = dgettext (null, "Checking inter-conflicts") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.ADD_START:
progress_window.cancel_button.visible = false;
break;
case Event.ADD_DONE:
break;
case Event.REMOVE_START:
progress_window.cancel_button.visible = false;
break;
case Event.REMOVE_DONE:
break;
case Event.UPGRADE_START:
break;
case Event.UPGRADE_DONE:
break;
case Event.DOWNGRADE_START:
break;
case Event.DOWNGRADE_DONE:
progress_window.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
progress_window.action_label.set_text (msg);
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.REINSTALL_START:
progress_window.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "...";
progress_window.action_label.set_text (msg);
msg = dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.REINSTALL_DONE:
case Event.REMOVE_START:
progress_window.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Removing %s").printf (details[0]) + "...";
progress_window.action_label.set_text (msg);
msg = dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.UPGRADE_START:
progress_window.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Upgrading %s").printf (details[0]) + "...";
progress_window.action_label.set_text (msg);
msg = dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DOWNGRADE_START:
progress_window.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Downgrading %s").printf (details[0]) + "...";
progress_window.action_label.set_text (msg);
msg = dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.INTEGRITY_START:
msg = dgettext (null, "Checking integrity") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.KEYRING_START:
msg = dgettext (null, "Checking keyring") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.KEY_DOWNLOAD_START:
msg = dgettext (null, "Downloading required keys") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
//~ case Event.KEY_DOWNLOAD_START:
//~ break;
case Event.LOAD_START:
msg = dgettext (null, "Loading packages files") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_INTEGRITY_START:
msg = dgettext (null, "Checking delta integrity") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCHES_START:
msg = dgettext (null, "Applying deltas") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCH_START:
msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCH_DONE:
msg = dgettext (null, "Generation succeeded") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCH_FAILED:
msg = dgettext (null, "Generation failed") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
//~ case Event.DELTA_INTEGRITY_START:
//~ break;
//~ case Event.DELTA_PATCHES_START:
//~ break;
//~ case Event.DELTA_PATCH_START:
//~ break;
//~ case Event.DELTA_PATCH_DONE:
//~ break;
//~ case Event.DELTA_PATCH_FAILED:
//~ break;
case Event.SCRIPTLET_INFO:
progress_window.action_label.set_text (dgettext (null, "Configuring %s").printf (previous_filename) + "...");
progress_window.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", details[0]});
break;
case Event.RETRIEVE_START:
progress_window.action_label.set_text (msg.replace ("\n", ""));
msg = dgettext (null, "Downloading") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DISKSPACE_START:
msg = dgettext (null, "Checking available disk space") + "...";
progress_window.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
//~ case Event.OPTDEP_REQUIRED:
//~ break;
//~ case Event.DATABASE_MISSING:
//~ break;
case Event.FILECONFLICTS_DONE:
case Event.CHECKDEPS_DONE:
case Event.RESOLVEDEPS_DONE:
case Event.INTERCONFLICTS_DONE:
case Event.INTEGRITY_DONE:
case Event.KEYRING_DONE:
case Event.KEY_DOWNLOAD_DONE:
case Event.LOAD_DONE:
case Event.DELTA_INTEGRITY_DONE:
case Event.DELTA_PATCHES_DONE:
case Event.DISKSPACE_DONE:
case Event.OPTDEP_REQUIRED:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])});
break;
case Event.DATABASE_MISSING:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Database file for %s does not exist").printf (details[0])});
break;
default:
break;
}
spawn_in_term ({"/usr/bin/echo", "-n", msg}, null);
while (Gtk.events_pending ())
Gtk.main_iteration ();
}
void on_emit_providers (string depend, string[] providers) {
choose_provider (depend, providers);
}
void on_emit_progress (uint progress, string action, string pkgname, int percent, uint n_targets, uint current_target) {
void on_emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target) {
double fraction;
switch (progress) {
case Progress.ADD_START:
@@ -633,15 +692,6 @@ namespace Pamac {
fraction = (float) percent/100;
break;
}
string label;
if (pkgname != "")
label = "%s %s...".printf (action, pkgname);
else
label = "%s...".printf (action);
if (label != previous_label) {
previous_label = label;
progress_window.action_label.set_text (label);
}
string textbar = "%lu/%lu".printf (current_target, n_targets);
if (textbar != previous_textbar) {
previous_textbar = textbar;
@@ -662,14 +712,14 @@ namespace Pamac {
if (filename != previous_filename) {
previous_filename = filename;
if (filename.has_suffix (".db")) {
label = dgettext (null, "Refreshing {repo}").replace ("{repo}", filename.replace (".db", "")) + "...";
label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
} else {
label = dgettext (null, "Downloading {pkgname}").replace ("{pkgname}", filename.replace (".pkg.tar.xz", "")) + "...";
label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "...";
}
if (label != previous_label) {
previous_label = label;
progress_window.action_label.set_text (label);
spawn_in_term ({"/usr/bin/echo", label}, null);
spawn_in_term ({"/usr/bin/echo", label});
}
}
if (total_download > 0) {
@@ -709,11 +759,11 @@ namespace Pamac {
}
if (line != null) {
progress_window.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", "-n", line}, null);
spawn_in_term ({"/usr/bin/echo", "-n", line});
}
}
public void handle_warning () {
public void show_warnings () {
if (transaction_info_dialog.textbuffer.text != "") {
transaction_info_dialog.set_title (dgettext (null, "Warning"));
transaction_info_dialog.label.set_visible (false);
@@ -730,31 +780,41 @@ namespace Pamac {
}
public void handle_error (ErrorInfos error) {
progress_window.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", "-n", error.str});
TextIter start_iter;
TextIter end_iter;
transaction_info_dialog.set_title (dgettext (null, "Error"));
transaction_info_dialog.label.set_visible (true);
transaction_info_dialog.label.set_markup (error.str.replace ("\n", ""));
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
transaction_info_dialog.label.set_markup (error.str);
if (error.details.length != 0) {
foreach (string detail in error.details) {
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.insert (ref end_iter, detail, detail.length);
}
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
transaction_info_dialog.expander.set_visible (true);
transaction_info_dialog.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", ":"});
foreach (string detail in error.details) {
spawn_in_term ({"/usr/bin/echo", detail});
string str = detail + "\n";
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.insert (ref end_iter, str, str.length);
}
} else
transaction_info_dialog.expander.set_visible (false);
spawn_in_term ({"/usr/bin/echo"});
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
progress_window.hide ();
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
while (Gtk.events_pending ())
Gtk.main_iteration ();
}
public void on_emit_refreshed (ErrorInfos error) {
print("transaction refreshed\n");
print ("transaction refreshed\n");
refresh_alpm_config ();
if (error.str == "") {
if (mode == Mode.UPDATER) {
@@ -772,7 +832,7 @@ namespace Pamac {
public void on_emit_trans_prepared (ErrorInfos error) {
print ("transaction prepared\n");
if (error.str == "") {
handle_warning ();
show_warnings ();
int ret = set_transaction_sum ();
if (ret == 0) {
if (data.to_add.size () == 0
@@ -788,12 +848,13 @@ namespace Pamac {
ErrorInfos err = ErrorInfos ();
on_emit_trans_committed (err);
} else {
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
progress_window.hide ();
transaction_sum_dialog.hide ();
finished (true);
}
} else if (sysupgrade_after_build) {
print("sysupgrade_after_build\n");
print ("sysupgrade_after_build\n");
sysupgrade_after_build = false;
commit ();
} else if (transaction_sum_dialog.run () == ResponseType.OK) {
@@ -802,6 +863,7 @@ namespace Pamac {
Gtk.main_iteration ();
commit ();
} else {
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
progress_window.hide ();
transaction_sum_dialog.hide ();
release ();
@@ -812,6 +874,7 @@ namespace Pamac {
} else {
//ErrorInfos err = ErrorInfos ();
//err.str = dgettext (null, "Nothing to do") + "\n";
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Nothing to do") + ".\n"});
progress_window.hide ();
release ();
clear_lists ();
@@ -825,20 +888,20 @@ namespace Pamac {
}
public void on_emit_trans_committed (ErrorInfos error) {
print("transaction committed\n");
print ("transaction committed\n");
if (error.str == "") {
if (data.to_build.size () != 0) {
if (data.to_add.size () != 0
|| data.to_remove.size () != 0
|| data.to_load.size () != 0) {
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + "\n"}, null);
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + ".\n"});
}
build_aur_packages ();
} else {
//progress_window.action_label.set_text (dgettext (null, "Transaction successfully finished"));
//progress_window.close_button.set_visible (true);
clear_lists ();
handle_warning ();
show_warnings ();
refresh_alpm_config ();
if (sysupgrade_after_trans) {
sysupgrade_after_trans = false;
@@ -846,22 +909,33 @@ namespace Pamac {
} else if (sysupgrade_after_build) {
sysupgrade_simple (0);
} else {
if (build_status == 0)
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + ".\n"});
else
spawn_in_term ({"/usr/bin/echo"});
progress_window.hide ();
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + "\n"}, null);
finished (false);
}
}
} else {
refresh_alpm_config ();
finished (true);
handle_error (error);
}
total_download = 0;
already_downloaded = 0;
build_status = 0;
}
void on_term_child_exited (int status) {
Source.remove (build_timeout_id);
data.to_build.steal_all ();
build_status = status;
try {
daemon.refresh_alpm_config ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
ErrorInfos err = ErrorInfos ();
on_emit_trans_committed (err);
}

View File

@@ -21,7 +21,7 @@
const string GETTEXT_PACKAGE = "pamac";
const string update_icon_name = "pamac-tray-update";
const string update_info = _("{number} available updates");
const string update_info = _("%u available updates");
const string one_update_info = _("1 available update");
const string noupdate_icon_name = "pamac-tray-no-update";
const string noupdate_info = _("Your system is up-to-date");
@@ -142,7 +142,7 @@ namespace Pamac {
show_notification (one_update_info);
} else {
// workaround to use python format string
string info = update_info.replace ("{number}", updates_nb.to_string ());
string info = update_info.printf (updates_nb);
this.update_icon (update_icon_name, info);
if (pamac_run == false)
show_notification (info);

View File

@@ -132,7 +132,10 @@ namespace Pamac {
updates_nb = syncfirst_updates.length;
foreach (UpdatesInfos infos in syncfirst_updates) {
name = infos.name + " " + infos.version;
size = format_size (infos.download_size);
if (infos.download_size != 0)
size = format_size (infos.download_size);
else
size = "";
dsize += infos.download_size;
updates_list.insert_with_values (out iter, -1, 0, name, 1, size);
}
@@ -141,7 +144,10 @@ namespace Pamac {
UpdatesInfos[] updates = get_repos_updates (transaction.alpm_config, ignore_pkgs);
foreach (UpdatesInfos infos in updates) {
name = infos.name + " " + infos.version;
size = format_size (infos.download_size);
if (infos.download_size != 0)
size = format_size (infos.download_size);
else
size = "";
dsize += infos.download_size;
updates_list.insert_with_values (out iter, -1, 0, name, 1, size);
}
@@ -151,7 +157,10 @@ namespace Pamac {
updates_nb += aur_updates.length;
foreach (UpdatesInfos infos in aur_updates) {
name = infos.name + " " + infos.version;
size = format_size (infos.download_size);
if (infos.download_size != 0)
size = format_size (infos.download_size);
else
size = "";
dsize += infos.download_size;
updates_list.insert_with_values (out iter, -1, 0, name, 1, size);
}
@@ -164,15 +173,14 @@ namespace Pamac {
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "1 available update")));
apply_button.set_sensitive (true);
} else {
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "{number} available updates").replace ("{number}", updates_nb.to_string ())));
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "%u available updates").printf (updates_nb)));
apply_button.set_sensitive (true);
}
if (dsize == 0)
bottom_label.set_visible (false);
else {
bottom_label.set_markup("<b>%s %s</b>".printf (dgettext (null, "Total download size:"), format_size(dsize)));
if (dsize != 0) {
bottom_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size(dsize)));
bottom_label.set_visible (true);
}
} else
bottom_label.set_visible (false);
}
}
}