forked from cromer/pamac-classic
some display fixes and improve generate mirror list
This commit is contained in:
parent
ec7dd3a3a9
commit
afea4d64b4
@ -230,57 +230,28 @@ namespace Pamac {
|
||||
});
|
||||
}
|
||||
|
||||
private bool process_line (IOChannel channel, IOCondition condition, string stream_name) {
|
||||
if (condition == IOCondition.HUP) {
|
||||
return false;
|
||||
}
|
||||
private void generate_mirrors_list () {
|
||||
try {
|
||||
string line;
|
||||
channel.read_line (out line, null, null);
|
||||
generate_mirrors_list_data (line);
|
||||
} catch (IOChannelError e) {
|
||||
stderr.printf ("%s: IOChannelError: %s\n", stream_name, e.message);
|
||||
return false;
|
||||
} catch (ConvertError e) {
|
||||
stderr.printf ("%s: ConvertError: %s\n", stream_name, e.message);
|
||||
return false;
|
||||
var process = new Subprocess.newv (
|
||||
{"pacman-mirrors", "-g"},
|
||||
SubprocessFlags.STDOUT_PIPE | SubprocessFlags.STDERR_MERGE);
|
||||
var dis = new DataInputStream (process.get_stdout_pipe ());
|
||||
string? line;
|
||||
while ((line = dis.read_line ()) != null) {
|
||||
generate_mirrors_list_data (line);
|
||||
}
|
||||
generate_mirrors_list_finished ();
|
||||
} catch (Error e) {
|
||||
generate_mirrors_list_finished ();
|
||||
stderr.printf ("Error: %s\n", e.message);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void start_generate_mirrors_list () {
|
||||
int standard_output;
|
||||
int standard_error;
|
||||
Pid child_pid;
|
||||
try {
|
||||
Process.spawn_async_with_pipes (null,
|
||||
{"pacman-mirrors", "-g"},
|
||||
null,
|
||||
SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
|
||||
null,
|
||||
out child_pid,
|
||||
null,
|
||||
out standard_output,
|
||||
out standard_error);
|
||||
// stdout
|
||||
IOChannel output = new IOChannel.unix_new (standard_output);
|
||||
output.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => {
|
||||
return process_line (channel, condition, "stdout");
|
||||
});
|
||||
// stderr
|
||||
IOChannel error = new IOChannel.unix_new (standard_error);
|
||||
error.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => {
|
||||
return process_line (channel, condition, "stderr");
|
||||
});
|
||||
ChildWatch.add (child_pid, (pid, status) => {
|
||||
// Triggered when the child indicated by child_pid exits
|
||||
Process.close_pid (pid);
|
||||
refresh_handle ();
|
||||
generate_mirrors_list_finished ();
|
||||
});
|
||||
} catch (SpawnError e) {
|
||||
generate_mirrors_list_finished ();
|
||||
stdout.printf ("SpawnError: %s\n", e.message);
|
||||
thread_pool.add (new AlpmAction (generate_mirrors_list));
|
||||
} catch (ThreadError e) {
|
||||
stderr.printf ("Thread Error %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,13 +37,13 @@ namespace Pamac {
|
||||
[GtkTemplate (ui = "/org/manjaro/pamac/manager/manager_window.ui")]
|
||||
class ManagerWindow : Gtk.ApplicationWindow {
|
||||
// icons
|
||||
public Gdk.Pixbuf? installed_icon;
|
||||
public Gdk.Pixbuf? uninstalled_icon;
|
||||
public Gdk.Pixbuf? to_install_icon;
|
||||
public Gdk.Pixbuf? to_reinstall_icon;
|
||||
public Gdk.Pixbuf? to_remove_icon;
|
||||
public Gdk.Pixbuf? installed_locked_icon;
|
||||
public Gdk.Pixbuf? available_locked_icon;
|
||||
Gdk.Pixbuf? installed_icon;
|
||||
Gdk.Pixbuf? uninstalled_icon;
|
||||
Gdk.Pixbuf? to_install_icon;
|
||||
Gdk.Pixbuf? to_reinstall_icon;
|
||||
Gdk.Pixbuf? to_remove_icon;
|
||||
Gdk.Pixbuf? installed_locked_icon;
|
||||
Gdk.Pixbuf? available_locked_icon;
|
||||
|
||||
// manager objects
|
||||
[GtkChild]
|
||||
@ -139,7 +139,8 @@ namespace Pamac {
|
||||
|
||||
bool refreshing;
|
||||
bool important_details;
|
||||
public bool transaction_running;
|
||||
bool transaction_running;
|
||||
bool generate_mirrors_list;
|
||||
|
||||
uint search_entry_timeout_id;
|
||||
|
||||
@ -148,10 +149,11 @@ namespace Pamac {
|
||||
|
||||
support_aur (false, false);
|
||||
button_back.visible = false;
|
||||
transaction_infobox.visible = false;;
|
||||
transaction_infobox.visible = false;
|
||||
refreshing = false;
|
||||
important_details = false;
|
||||
transaction_running = false;
|
||||
generate_mirrors_list = false;
|
||||
|
||||
Timeout.add (100, populate_window);
|
||||
}
|
||||
@ -198,7 +200,7 @@ namespace Pamac {
|
||||
packages_treeview.set_model (packages_list);
|
||||
// add custom cellrenderer to packages_treeview and aur_treewiew
|
||||
var packages_state_renderer = new ActivableCellRendererPixbuf ();
|
||||
packages_state_column.pack_start (packages_state_renderer, true);
|
||||
packages_state_column.pack_start (packages_state_renderer, false);
|
||||
packages_state_column.set_cell_data_func (packages_state_renderer, (celllayout, cellrenderer, treemodel, treeiter) => {
|
||||
Gdk.Pixbuf pixbuf;
|
||||
uint origin;
|
||||
@ -239,7 +241,7 @@ namespace Pamac {
|
||||
aur_treeview.set_model (aur_list);
|
||||
// add custom cellrenderer to aur_treewiew
|
||||
var aur_state_renderer = new ActivableCellRendererPixbuf ();
|
||||
aur_state_column.pack_start (aur_state_renderer, true);
|
||||
aur_state_column.pack_start (aur_state_renderer, false);
|
||||
aur_state_column.set_cell_data_func (aur_state_renderer, (celllayout, cellrenderer, treemodel, treeiter) => {
|
||||
Gdk.Pixbuf pixbuf;
|
||||
uint origin;
|
||||
@ -285,6 +287,7 @@ namespace Pamac {
|
||||
transaction.finished.connect (on_transaction_finished);
|
||||
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
||||
transaction.set_pkgreason_finished.connect (on_set_pkgreason_finished);
|
||||
transaction.generate_mirrors_list.connect (on_generate_mirrors_list);
|
||||
|
||||
// integrate progress box and term widget
|
||||
main_stack.add_named (transaction.term_grid, "term");
|
||||
@ -338,11 +341,15 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
void set_pendings_operations () {
|
||||
if (!transaction_running) {
|
||||
if (!transaction_running && !generate_mirrors_list) {
|
||||
uint total_pending = transaction.to_install.length + transaction.to_remove.length + transaction.to_build.length;
|
||||
if (total_pending == 0) {
|
||||
transaction.progress_box.action_label.label = "";
|
||||
transaction_infobox.visible = important_details;
|
||||
if (important_details) {
|
||||
transaction_infobox.show_all ();
|
||||
} else {
|
||||
transaction_infobox.visible = false;
|
||||
}
|
||||
} else {
|
||||
string info = dngettext (null, "%u pending operation", "%u pending operations", total_pending).printf (total_pending);
|
||||
transaction.progress_box.action_label.label = info;
|
||||
@ -1574,7 +1581,7 @@ namespace Pamac {
|
||||
refreshing = true;
|
||||
transaction.start_refresh (false);
|
||||
apply_button.sensitive = false;
|
||||
transaction_infobox.visible = true;
|
||||
transaction_infobox.show_all ();
|
||||
}
|
||||
|
||||
void on_start_transaction () {
|
||||
@ -1591,6 +1598,12 @@ namespace Pamac {
|
||||
}
|
||||
}
|
||||
|
||||
void on_generate_mirrors_list () {
|
||||
generate_mirrors_list = true;
|
||||
apply_button.sensitive = false;
|
||||
transaction_infobox.show_all ();
|
||||
}
|
||||
|
||||
void on_transaction_finished (bool success) {
|
||||
refresh_packages_list ();
|
||||
if (main_stack.visible_child_name == "details") {
|
||||
@ -1607,6 +1620,7 @@ namespace Pamac {
|
||||
refreshing = false;
|
||||
} else {
|
||||
transaction_running = false;
|
||||
generate_mirrors_list = false;
|
||||
cancel_button.sensitive = true;
|
||||
apply_button.sensitive = true;
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ namespace Pamac {
|
||||
bool no_confirm_build);
|
||||
public signal void write_alpm_config_finished (bool checkspace);
|
||||
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
|
||||
public signal void generate_mirrors_list ();
|
||||
|
||||
public Transaction (Gtk.ApplicationWindow? application_window) {
|
||||
pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
@ -341,6 +342,7 @@ namespace Pamac {
|
||||
reset_progress_box (action);
|
||||
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_box.progressbar.pulse);
|
||||
important_details_outpout (false);
|
||||
generate_mirrors_list ();
|
||||
try {
|
||||
daemon.start_generate_mirrors_list ();
|
||||
} catch (IOError e) {
|
||||
@ -1115,7 +1117,7 @@ namespace Pamac {
|
||||
detailed_action = dgettext (null, "Generation failed") + "...";
|
||||
break;
|
||||
case 24: //Alpm.Event.Type.SCRIPTLET_INFO
|
||||
action = dgettext (null, "Configuring %s").printf (previous_filename) + "...";
|
||||
progress_box.action_label.label = dgettext (null, "Configuring %s").printf (previous_filename) + "...";
|
||||
detailed_action = details[0].replace ("\n", "");
|
||||
important_details_outpout (false);
|
||||
break;
|
||||
@ -1280,8 +1282,7 @@ namespace Pamac {
|
||||
timer.start ();
|
||||
if (filename.has_suffix (".db")) {
|
||||
string action = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
|
||||
progress_box.action_label.label = action;
|
||||
spawn_in_term ({"echo", action});
|
||||
reset_progress_box (action);
|
||||
}
|
||||
} else if (xfered == total) {
|
||||
timer.stop ();
|
||||
@ -1587,7 +1588,7 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
void on_generate_mirrors_list_data (string line) {
|
||||
spawn_in_term ({"echo", "-n", line});
|
||||
spawn_in_term ({"echo", line});
|
||||
}
|
||||
|
||||
void on_generate_mirrors_list_finished () {
|
||||
|
@ -58,7 +58,8 @@ namespace Pamac {
|
||||
|
||||
public Pamac.Transaction transaction;
|
||||
|
||||
public bool transaction_running;
|
||||
bool transaction_running;
|
||||
bool generate_mirrors_list;
|
||||
bool important_details;
|
||||
string previous_visible_child_name;
|
||||
|
||||
@ -72,6 +73,7 @@ namespace Pamac {
|
||||
aur_scrolledwindow.visible = false;
|
||||
transaction_running = false;
|
||||
important_details = false;
|
||||
generate_mirrors_list = false;
|
||||
|
||||
Timeout.add (100, populate_window);
|
||||
}
|
||||
@ -90,6 +92,7 @@ namespace Pamac {
|
||||
transaction.important_details_outpout.connect (on_important_details_outpout);
|
||||
transaction.finished.connect (populate_updates_list);
|
||||
transaction.get_updates_finished.connect (on_get_updates_finished);
|
||||
transaction.generate_mirrors_list.connect (on_generate_mirrors_list);
|
||||
|
||||
// integrate progress box and term widget
|
||||
stack.add_named (transaction.term_grid, "term");
|
||||
@ -103,35 +106,38 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
void set_transaction_infobox_visible () {
|
||||
bool visible = false;
|
||||
uint64 total_dsize = 0;
|
||||
repos_updates_list.foreach ((model, path, iter) => {
|
||||
bool selected;
|
||||
uint64 dsize;
|
||||
repos_updates_list.get (iter, 0, out selected, 6, out dsize);
|
||||
visible |= selected;
|
||||
if (selected) {
|
||||
total_dsize += dsize;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!visible) {
|
||||
aur_updates_list.foreach ((model, path, iter) => {
|
||||
if (!generate_mirrors_list) {
|
||||
bool visible = false;
|
||||
uint64 total_dsize = 0;
|
||||
repos_updates_list.foreach ((model, path, iter) => {
|
||||
bool selected;
|
||||
aur_updates_list.get (iter, 0, out selected);
|
||||
uint64 dsize;
|
||||
repos_updates_list.get (iter, 0, out selected, 6, out dsize);
|
||||
visible |= selected;
|
||||
return visible;
|
||||
if (selected) {
|
||||
total_dsize += dsize;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
transaction_infobox.visible = visible;
|
||||
if (visible) {
|
||||
if (total_dsize != 0) {
|
||||
transaction.progress_box.action_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size (total_dsize)));
|
||||
} else {
|
||||
transaction.progress_box.action_label.label = "";
|
||||
if (!visible) {
|
||||
aur_updates_list.foreach ((model, path, iter) => {
|
||||
bool selected;
|
||||
aur_updates_list.get (iter, 0, out selected);
|
||||
visible |= selected;
|
||||
return visible;
|
||||
});
|
||||
}
|
||||
if (visible) {
|
||||
if (total_dsize != 0) {
|
||||
transaction.progress_box.action_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size (total_dsize)));
|
||||
} else {
|
||||
transaction.progress_box.action_label.label = "";
|
||||
}
|
||||
// fix an possible visibility issue
|
||||
transaction_infobox.show_all ();
|
||||
} else {
|
||||
transaction_infobox.visible = false;
|
||||
}
|
||||
// fix an possible visibility issue
|
||||
transaction_infobox.show_all ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,7 +203,9 @@ namespace Pamac {
|
||||
[GtkCallback]
|
||||
void on_preferences_button_clicked () {
|
||||
transaction.run_preferences_dialog.begin (() => {
|
||||
populate_updates_list ();
|
||||
if (!generate_mirrors_list) {
|
||||
populate_updates_list ();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -213,7 +221,7 @@ namespace Pamac {
|
||||
[GtkCallback]
|
||||
void on_refresh_button_clicked () {
|
||||
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
||||
transaction_infobox.visible = true;
|
||||
transaction_infobox.show_all ();
|
||||
apply_button.sensitive = false;
|
||||
details_button.sensitive = true;
|
||||
cancel_button.sensitive = true;
|
||||
@ -255,12 +263,20 @@ namespace Pamac {
|
||||
button_back.visible = false;
|
||||
} else if (stack.visible_child_name != "term") {
|
||||
important_details = true;
|
||||
details_button.sensitive = true;
|
||||
details_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
void on_generate_mirrors_list () {
|
||||
generate_mirrors_list = true;
|
||||
apply_button.sensitive = false;
|
||||
transaction_infobox.show_all ();
|
||||
}
|
||||
|
||||
void populate_updates_list () {
|
||||
transaction_running = false;
|
||||
generate_mirrors_list = false;
|
||||
apply_button.sensitive = true;
|
||||
apply_button.grab_default ();
|
||||
details_button.sensitive = false;
|
||||
|
Loading…
Reference in New Issue
Block a user