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