fix actions display in terminal
This commit is contained in:
parent
60a34f6681
commit
95d3ffd071
@ -71,6 +71,7 @@ namespace Pamac {
|
|||||||
bool sysupgrade_after_build;
|
bool sysupgrade_after_build;
|
||||||
|
|
||||||
Terminal term;
|
Terminal term;
|
||||||
|
Pty pty;
|
||||||
|
|
||||||
//dialogs
|
//dialogs
|
||||||
ChooseProviderDialog choose_provider_dialog;
|
ChooseProviderDialog choose_provider_dialog;
|
||||||
@ -105,6 +106,14 @@ namespace Pamac {
|
|||||||
term.expand = true;
|
term.expand = true;
|
||||||
term.height_request = 200;
|
term.height_request = 200;
|
||||||
term.set_visible (true);
|
term.set_visible (true);
|
||||||
|
// creating pty for term
|
||||||
|
try {
|
||||||
|
pty = term.pty_new_sync (PtyFlags.NO_HELPER);
|
||||||
|
} catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
// connect to child_exited signal which will only be emit after a call to watch_child
|
||||||
|
term.child_exited.connect (on_term_child_exited);
|
||||||
// add term in a grid with a scrollbar
|
// add term in a grid with a scrollbar
|
||||||
var grid = new Grid ();
|
var grid = new Grid ();
|
||||||
grid.expand = true;
|
grid.expand = true;
|
||||||
@ -139,12 +148,7 @@ namespace Pamac {
|
|||||||
|
|
||||||
public void refresh (int force) {
|
public void refresh (int force) {
|
||||||
string action = dgettext ("pacman", "Synchronizing package databases...\n").replace ("\n", "");
|
string action = dgettext ("pacman", "Synchronizing package databases...\n").replace ("\n", "");
|
||||||
try {
|
spawn_in_term ({"/usr/bin/echo", action}, null);
|
||||||
term.reset (true, true);
|
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", {"/usr/bin/echo", action}, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, null);
|
|
||||||
} catch (Error e) {
|
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
progress_window.action_label.set_text (action);
|
progress_window.action_label.set_text (action);
|
||||||
progress_window.progressbar.set_fraction (0);
|
progress_window.progressbar.set_fraction (0);
|
||||||
progress_window.progressbar.set_text ("");
|
progress_window.progressbar.set_text ("");
|
||||||
@ -200,11 +204,7 @@ namespace Pamac {
|
|||||||
|
|
||||||
public void sysupgrade (int enable_downgrade) {
|
public void sysupgrade (int enable_downgrade) {
|
||||||
string action = dgettext ("pacman", "Starting full system upgrade...\n").replace ("\n", "");
|
string action = dgettext ("pacman", "Starting full system upgrade...\n").replace ("\n", "");
|
||||||
try {
|
spawn_in_term ({"/usr/bin/echo", action}, null);
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", {"/usr/bin/echo", action}, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, null);
|
|
||||||
} catch (Error e) {
|
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
progress_window.action_label.set_text (action);
|
progress_window.action_label.set_text (action);
|
||||||
progress_window.progressbar.set_fraction (0);
|
progress_window.progressbar.set_fraction (0);
|
||||||
progress_window.progressbar.set_text ("");
|
progress_window.progressbar.set_text ("");
|
||||||
@ -248,12 +248,7 @@ namespace Pamac {
|
|||||||
|
|
||||||
public void run () {
|
public void run () {
|
||||||
string action = dgettext (null,"Preparing") + "...";
|
string action = dgettext (null,"Preparing") + "...";
|
||||||
try {
|
spawn_in_term ({"/usr/bin/echo", action}, null);
|
||||||
term.reset (true, true);
|
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", {"/usr/bin/echo", action}, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, null);
|
|
||||||
} catch (Error e) {
|
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
progress_window.action_label.set_text (action);
|
progress_window.action_label.set_text (action);
|
||||||
progress_window.progressbar.set_fraction (0);
|
progress_window.progressbar.set_fraction (0);
|
||||||
progress_window.progressbar.set_text ("");
|
progress_window.progressbar.set_text ("");
|
||||||
@ -481,16 +476,9 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void build_aur_packages () {
|
public void build_aur_packages () {
|
||||||
string[] cmds = {"/usr/bin/yaourt", "-S"};
|
print ("building packages\n");
|
||||||
foreach (string name in data.to_build.get_keys ())
|
|
||||||
cmds += name;
|
|
||||||
string action = dgettext (null,"Building packages") + "...";
|
string action = dgettext (null,"Building packages") + "...";
|
||||||
try {
|
spawn_in_term ({"/usr/bin/echo", "-n", action}, null);
|
||||||
term.reset (true, true);
|
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", {"/usr/bin/echo", action}, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, null);
|
|
||||||
} catch (Error e) {
|
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
progress_window.action_label.set_text (action);
|
progress_window.action_label.set_text (action);
|
||||||
progress_window.progressbar.set_fraction (0);
|
progress_window.progressbar.set_fraction (0);
|
||||||
progress_window.progressbar.set_text ("");
|
progress_window.progressbar.set_text ("");
|
||||||
@ -498,16 +486,15 @@ namespace Pamac {
|
|||||||
progress_window.close_button.visible = false;
|
progress_window.close_button.visible = false;
|
||||||
progress_window.expander.set_expanded (true);
|
progress_window.expander.set_expanded (true);
|
||||||
progress_window.width_request = 700;
|
progress_window.width_request = 700;
|
||||||
term.child_exited.connect (on_term_child_exited);
|
|
||||||
term.grab_focus ();
|
term.grab_focus ();
|
||||||
build_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_window.progressbar.pulse);
|
build_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_window.progressbar.pulse);
|
||||||
try {
|
string[] cmds = {"/usr/bin/yaourt", "-S"};
|
||||||
|
foreach (string name in data.to_build.get_keys ())
|
||||||
|
cmds += name;
|
||||||
Pid child_pid;
|
Pid child_pid;
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", cmds, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, out child_pid);
|
spawn_in_term (cmds, out child_pid);
|
||||||
//term.watch_child (child_pid);
|
// watch_child is needed in order to have the child_exited signal emitted
|
||||||
} catch (Error e) {
|
term.watch_child (child_pid);
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel () {
|
public void cancel () {
|
||||||
@ -534,6 +521,15 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void spawn_in_term (string[] args, out int pid) {
|
||||||
|
try {
|
||||||
|
Process.spawn_async (null, args, null, SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out pid);
|
||||||
|
} catch (SpawnError e) {
|
||||||
|
stderr.printf ("SpawnError: %s\n", e.message);
|
||||||
|
}
|
||||||
|
term.set_pty (pty);
|
||||||
|
}
|
||||||
|
|
||||||
void on_emit_event (uint event, string msg) {
|
void on_emit_event (uint event, string msg) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case Event.CHECKDEPS_START:
|
case Event.CHECKDEPS_START:
|
||||||
@ -611,11 +607,7 @@ namespace Pamac {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
spawn_in_term ({"/usr/bin/echo", "-n", msg}, null);
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", {"/usr/bin/echo", "-n", msg}, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, null);
|
|
||||||
} catch (Error e) {
|
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_emit_providers (string depend, string[] providers) {
|
void on_emit_providers (string depend, string[] providers) {
|
||||||
@ -677,11 +669,7 @@ namespace Pamac {
|
|||||||
if (label != previous_label) {
|
if (label != previous_label) {
|
||||||
previous_label = label;
|
previous_label = label;
|
||||||
progress_window.action_label.set_text (label);
|
progress_window.action_label.set_text (label);
|
||||||
try {
|
spawn_in_term ({"/usr/bin/echo", label}, null);
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", {"/usr/bin/echo", label}, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, null);
|
|
||||||
} catch (Error e) {
|
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (total_download > 0) {
|
if (total_download > 0) {
|
||||||
@ -721,11 +709,7 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
progress_window.expander.set_expanded (true);
|
progress_window.expander.set_expanded (true);
|
||||||
try {
|
spawn_in_term ({"/usr/bin/echo", "-n", line}, null);
|
||||||
term.spawn_sync (PtyFlags.DEFAULT, "~/", {"/usr/bin/echo", "-n", line}, {}, SpawnFlags.DO_NOT_REAP_CHILD, null, null);
|
|
||||||
} catch (Error e) {
|
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,9 +826,13 @@ namespace Pamac {
|
|||||||
|
|
||||||
public void on_emit_trans_committed (ErrorInfos error) {
|
public void on_emit_trans_committed (ErrorInfos error) {
|
||||||
print("transaction committed\n");
|
print("transaction committed\n");
|
||||||
term.child_exited.disconnect (on_term_child_exited);
|
|
||||||
if (error.str == "") {
|
if (error.str == "") {
|
||||||
if (data.to_build.size () != 0) {
|
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);
|
||||||
|
}
|
||||||
build_aur_packages ();
|
build_aur_packages ();
|
||||||
} else {
|
} else {
|
||||||
//progress_window.action_label.set_text (dgettext (null, "Transaction successfully finished"));
|
//progress_window.action_label.set_text (dgettext (null, "Transaction successfully finished"));
|
||||||
@ -859,6 +847,7 @@ namespace Pamac {
|
|||||||
sysupgrade_simple (0);
|
sysupgrade_simple (0);
|
||||||
} else {
|
} else {
|
||||||
progress_window.hide ();
|
progress_window.hide ();
|
||||||
|
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + "\n"}, null);
|
||||||
finished (false);
|
finished (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user