From 92191382bc3210ee2474ca6575ddb76e7bc05d37 Mon Sep 17 00:00:00 2001 From: guinux Date: Tue, 17 May 2016 19:11:49 +0200 Subject: [PATCH] v4.1.0-beta2 --- resources/Makefile | 1 + resources/manager_window.ui | 14 +- resources/pamac.transaction.gresource.xml | 1 + resources/progress_box.ui | 34 +++ resources/progress_dialog.ui | 24 +-- resources/updater_window.ui | 37 ++-- src/Makefile | 1 + src/daemon.vala | 2 +- src/manager_window.vala | 79 ++++--- src/progress_box.vala | 36 ++++ src/progress_dialog.vala | 38 ---- src/transaction.vala | 245 ++++++++++------------ src/updater_window.vala | 73 +++++-- 13 files changed, 316 insertions(+), 269 deletions(-) create mode 100644 resources/progress_box.ui create mode 100644 src/progress_box.vala diff --git a/resources/Makefile b/resources/Makefile index 04f3d13..ac843ba 100644 --- a/resources/Makefile +++ b/resources/Makefile @@ -12,6 +12,7 @@ MANAGER_RESOURCES_FILES = manager_window.ui \ UPDATER_RESOURCES_FILES = updater_window.ui TRANSACTION_RESOURCES_FILES = progress_dialog.ui \ + progress_box.ui \ choose_provider_dialog.ui \ transaction_sum_dialog.ui \ preferences_dialog.ui \ diff --git a/resources/manager_window.ui b/resources/manager_window.ui index 45959b9..882ceb1 100644 --- a/resources/manager_window.ui +++ b/resources/manager_window.ui @@ -382,7 +382,6 @@ True False True - True @@ -499,7 +498,6 @@ True False True - True @@ -885,16 +883,7 @@ 6 12 - - True - False - start - - - True - True - 0 - + @@ -950,6 +939,7 @@ False True + end 1 diff --git a/resources/pamac.transaction.gresource.xml b/resources/pamac.transaction.gresource.xml index 551a936..3a0a65f 100644 --- a/resources/pamac.transaction.gresource.xml +++ b/resources/pamac.transaction.gresource.xml @@ -2,6 +2,7 @@ progress_dialog.ui + progress_box.ui history_dialog.ui choose_provider_dialog.ui transaction_sum_dialog.ui diff --git a/resources/progress_box.ui b/resources/progress_box.ui new file mode 100644 index 0000000..c9579c9 --- /dev/null +++ b/resources/progress_box.ui @@ -0,0 +1,34 @@ + + + + + + diff --git a/resources/progress_dialog.ui b/resources/progress_dialog.ui index 6761f5b..8018d30 100644 --- a/resources/progress_dialog.ui +++ b/resources/progress_dialog.ui @@ -58,29 +58,7 @@ - - True - False - 12 - - - False - True - 1 - - - - - True - True - True - end - - - False - True - 2 - + diff --git a/resources/updater_window.ui b/resources/updater_window.ui index b7f1fa6..c297a03 100644 --- a/resources/updater_window.ui +++ b/resources/updater_window.ui @@ -182,6 +182,7 @@ True + fixed 90 20 Repository @@ -306,7 +307,7 @@ - + True False 6 @@ -327,21 +328,12 @@ - + True False 12 - - True - False - start - - - True - True - 0 - + @@ -400,6 +392,7 @@ False True + end 1 @@ -424,6 +417,26 @@ True False True + + + True + True + False + start + + + + True + False + go-previous-symbolic + 1 + + + + + True diff --git a/src/Makefile b/src/Makefile index 1e8badd..dcd085e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -28,6 +28,7 @@ TRANSACTION_SOURCES = package.vala \ history_dialog.vala \ choose_provider_dialog.vala \ transaction_sum_dialog.vala \ + progress_box.vala \ progress_dialog.vala PREFERENCES_SOURCES = preferences_dialog.vala \ diff --git a/src/daemon.vala b/src/daemon.vala index f3b06cb..2f426ec 100644 --- a/src/daemon.vala +++ b/src/daemon.vala @@ -1641,7 +1641,7 @@ namespace Pamac { private void write_log_file (string event) { var now = new DateTime.now_local (); - string log = "%s [PAMAC] %s".printf (now.format ("[%Y-%m-%d %H:%M]"), event); + string log = "%s [PAMAC] %s\n".printf (now.format ("[%Y-%m-%d %H:%M]"), event); var file = GLib.File.new_for_path ("/var/log/pacman.log"); try { // creating a DataOutputStream to the file diff --git a/src/manager_window.vala b/src/manager_window.vala index 3596203..4624885 100644 --- a/src/manager_window.vala +++ b/src/manager_window.vala @@ -109,7 +109,7 @@ namespace Pamac { [GtkChild] Gtk.Box transaction_infobox; [GtkChild] - Gtk.Label transaction_infos_label; + Gtk.Button details_button; [GtkChild] Gtk.Button apply_button; [GtkChild] @@ -138,6 +138,7 @@ namespace Pamac { public Transaction transaction; bool refreshing; + bool important_details; public bool transaction_running; uint search_entry_timeout_id; @@ -149,6 +150,7 @@ namespace Pamac { button_back.visible = false; transaction_infobox.visible = false;; refreshing = false; + important_details = false; transaction_running = false; Timeout.add (100, populate_window); @@ -279,11 +281,15 @@ namespace Pamac { transaction = new Transaction (this as Gtk.ApplicationWindow); transaction.mode = Mode.MANAGER; transaction.start_transaction.connect (on_start_transaction); - transaction.emit_action.connect (on_emit_action); + transaction.important_details_outpout.connect (on_important_details_outpout); 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); + // integrate progress box and term widget + main_stack.add_named (transaction.term_grid, "term"); + transaction_infobox.pack_start (transaction.progress_box); + AlpmPackage pkg = transaction.find_installed_satisfier ("yaourt"); if (pkg.name != "") { support_aur (transaction.enable_aur, transaction.search_aur); @@ -335,11 +341,13 @@ namespace Pamac { if (!transaction_running) { uint total_pending = transaction.to_install.length + transaction.to_remove.length + transaction.to_build.length; if (total_pending == 0) { - transaction_infobox.visible = false; + transaction.progress_box.action_label.label = ""; + transaction_infobox.visible = important_details; } else { string info = dngettext (null, "%u pending operation", "%u pending operations", total_pending).printf (total_pending); - transaction_infos_label.label = info; - transaction_infobox.visible = true; + transaction.progress_box.action_label.label = info; + // fix an possible visibility issue + transaction_infobox.show_all (); } } } @@ -1436,6 +1444,7 @@ namespace Pamac { filters_stackswitcher.visible = true; break; case "details": + case "term": filters_stackswitcher.visible = false; button_back.visible = true; break; @@ -1508,29 +1517,36 @@ namespace Pamac { [GtkCallback] void on_details_button_clicked () { + details_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + important_details = false; if (transaction_running) { - transaction.show_progress (); + main_stack.visible_child_name = "term"; } else { - main_stack.visible_child_name = "browse"; - filters_stack.notify["visible-child"].disconnect (on_filters_stack_visible_child_changed); - filters_stack.visible_child_name = "states"; - filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed); - Gtk.TreeIter iter; - // show "Pending" in states_list - // "Pending" is at indice 3 - states_list.get_iter (out iter, new Gtk.TreePath.from_indices (3)); - Gtk.TreeSelection selection = states_treeview.get_selection (); - selection.changed.disconnect (on_states_treeview_selection_changed); - selection.select_iter (iter); - selection.changed.connect_after (on_states_treeview_selection_changed); - refresh_packages_list (); + uint total_pending = transaction.to_install.length + transaction.to_remove.length + transaction.to_build.length; + if (total_pending == 0) { + main_stack.visible_child_name = "term"; + } else { + main_stack.visible_child_name = "browse"; + filters_stack.notify["visible-child"].disconnect (on_filters_stack_visible_child_changed); + filters_stack.visible_child_name = "states"; + filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed); + Gtk.TreeIter iter; + // show "Pending" in states_list + // "Pending" is at indice 3 + states_list.get_iter (out iter, new Gtk.TreePath.from_indices (3)); + Gtk.TreeSelection selection = states_treeview.get_selection (); + selection.changed.disconnect (on_states_treeview_selection_changed); + selection.select_iter (iter); + selection.changed.connect_after (on_states_treeview_selection_changed); + refresh_packages_list (); + } } } [GtkCallback] void on_apply_button_clicked () { transaction_running = true; - apply_button.visible = false; + apply_button.sensitive = false; transaction.run (); } @@ -1545,6 +1561,9 @@ namespace Pamac { if (main_stack.visible_child_name == "details") { display_package_properties (current_package_displayed); } + while (Gtk.events_pending ()) { + Gtk.main_iteration (); + } } } @@ -1553,22 +1572,30 @@ namespace Pamac { this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); refreshing = true; transaction.start_refresh (false); - apply_button.visible = false; + apply_button.sensitive = false; transaction_infobox.visible = true; } void on_start_transaction () { - cancel_button.visible = false; + cancel_button.sensitive = false; } - void on_emit_action (string action) { - transaction_infos_label.label = action; + void on_important_details_outpout (bool must_show) { + if (must_show) { + main_stack.visible_child_name = "term"; + button_back.visible = false; + } else if (main_stack.visible_child_name != "term") { + important_details = true; + details_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + } } void on_transaction_finished (bool success) { refresh_packages_list (); if (main_stack.visible_child_name == "details") { display_package_properties (current_package_displayed); + } else if (main_stack.visible_child_name == "term") { + button_back.visible = true; } transaction.to_load.remove_all (); if (refreshing) { @@ -1579,8 +1606,8 @@ namespace Pamac { refreshing = false; } else { transaction_running = false; - cancel_button.visible = true; - apply_button.visible = true; + cancel_button.sensitive = true; + apply_button.sensitive = true; } set_pendings_operations (); } diff --git a/src/progress_box.vala b/src/progress_box.vala new file mode 100644 index 0000000..d8e72b7 --- /dev/null +++ b/src/progress_box.vala @@ -0,0 +1,36 @@ +/* + * pamac-vala + * + * Copyright (C) 2014-2016 Guillaume Benoit + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a get of the GNU General Public License + * along with this program. If not, see . + */ + +namespace Pamac { + + [GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_box.ui")] + public class ProgressBox : Gtk.Box { + + [GtkChild] + public Gtk.ProgressBar progressbar; + [GtkChild] + public Gtk.Label action_label; + + + public ProgressBox () { + Object (); + } + + } +} diff --git a/src/progress_dialog.vala b/src/progress_dialog.vala index fe93b1d..b713b62 100644 --- a/src/progress_dialog.vala +++ b/src/progress_dialog.vala @@ -22,10 +22,6 @@ namespace Pamac { [GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")] class ProgressDialog : Gtk.Dialog { - [GtkChild] - public Gtk.ProgressBar progressbar; - [GtkChild] - public Gtk.Label action_label; [GtkChild] public Gtk.Button cancel_button; [GtkChild] @@ -33,44 +29,10 @@ namespace Pamac { [GtkChild] public Gtk.Expander expander; - public Vte.Terminal term; - Vte.Pty pty; - public ProgressDialog (Gtk.ApplicationWindow? window) { Object (transient_for: window, use_header_bar: 1); - //creating terminal - term = new Vte.Terminal (); - term.scroll_on_output = false; - term.expand = true; - term.height_request = 200; - term.visible = true; - // creating pty for term - try { - pty = term.pty_new_sync (Vte.PtyFlags.NO_HELPER); - } catch (Error e) { - stderr.printf ("Error: %s\n", e.message); - } - // add term in a grid with a scrollbar - var grid = new Gtk.Grid (); - grid.expand = true; - grid.visible = true; - var sb = new Gtk.Scrollbar (Gtk.Orientation.VERTICAL, term.vadjustment); - sb.visible = true; - grid.attach (term, 0, 0, 1, 1); - grid.attach (sb, 1, 0, 1, 1); - this.expander.add (grid); } - public void spawn_in_term (string[] args, out Pid child_pid = null) { - Pid intern_pid; - try { - Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out intern_pid); - } catch (SpawnError e) { - stderr.printf ("SpawnError: %s\n", e.message); - } - child_pid = intern_pid; - term.set_pty (pty); - } } } diff --git a/src/transaction.vala b/src/transaction.vala index 893e585..bc9daaa 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -147,12 +147,15 @@ namespace Pamac { //dialogs TransactionSumDialog transaction_sum_dialog; - ProgressDialog progress_dialog; + public ProgressBox progress_box; + Vte.Terminal term; + Vte.Pty pty; + public Gtk.Grid term_grid; //parent window public Gtk.ApplicationWindow? application_window { get; private set; } public signal void start_transaction (); - public signal void emit_action (string action); + public signal void important_details_outpout (bool must_show); public signal void alpm_handle_refreshed (); public signal void finished (bool success); public signal void set_pkgreason_finished (); @@ -182,11 +185,30 @@ namespace Pamac { //creating dialogs this.application_window = application_window; transaction_sum_dialog = new TransactionSumDialog (application_window); - progress_dialog = new ProgressDialog (application_window); - progress_dialog.close_button.clicked.connect (hide_progress); - progress_dialog.cancel_button.clicked.connect (on_progress_dialog_cancel_button_clicked); + progress_box = new ProgressBox (); + progress_box.progressbar.text = ""; + //creating terminal + term = new Vte.Terminal (); + term.scroll_on_output = false; + term.expand = true; + term.height_request = 200; + term.visible = true; + // creating pty for term + try { + pty = term.pty_new_sync (Vte.PtyFlags.NO_HELPER); + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); + } + // add term in a grid with a scrollbar + term_grid = new Gtk.Grid (); + term_grid.expand = true; + term_grid.visible = true; + var sb = new Gtk.Scrollbar (Gtk.Orientation.VERTICAL, term.vadjustment); + sb.visible = true; + term_grid.attach (term, 0, 0, 1, 1); + term_grid.attach (sb, 1, 0, 1, 1); // connect to child_exited signal which will only be emit after a call to watch_child - progress_dialog.term.child_exited.connect (on_term_child_exited); + term.child_exited.connect (on_term_child_exited); // progress data previous_textbar = ""; previous_filename = ""; @@ -298,36 +320,27 @@ namespace Pamac { } } - public void show_progress () { - progress_dialog.show (); - } - - public void hide_progress () { - progress_dialog.hide (); - } - - void reset_progress_dialog (string action, - bool cancel_button_visible = true, - bool expander_expanded = false) { - progress_dialog.spawn_in_term ({"echo", action}); - progress_dialog.action_label.label = action; - progress_dialog.progressbar.fraction = 0; - progress_dialog.progressbar.text = ""; - progress_dialog.cancel_button.visible = cancel_button_visible; - progress_dialog.expander.expanded = expander_expanded; - if (expander_expanded) { - progress_dialog.width_request = 700; + void spawn_in_term (string[] args, out Pid child_pid = null) { + try { + Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out child_pid); + } catch (SpawnError e) { + stderr.printf ("SpawnError: %s\n", e.message); } + term.set_pty (pty); + } + + void reset_progress_box (string action) { + spawn_in_term ({"echo", action}); + progress_box.action_label.label = action; + progress_box.progressbar.fraction = 0; + progress_box.progressbar.text = ""; } public void start_generate_mirrors_list () { string action = dgettext (null, "Refreshing mirrors list") + "..."; - reset_progress_dialog (action, false, true); - pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse); - progress_dialog.show (); - while (Gtk.events_pending ()) { - Gtk.main_iteration (); - } + reset_progress_box (action); + pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_box.progressbar.pulse); + important_details_outpout (false); try { daemon.start_generate_mirrors_list (); } catch (IOError e) { @@ -346,8 +359,7 @@ namespace Pamac { public void start_refresh (bool force) { string action = dgettext (null, "Synchronizing package databases") + "..."; - reset_progress_dialog (action); - emit_action (action); + reset_progress_box (action); try { daemon.refresh_finished.connect (on_refresh_finished); daemon.start_refresh (force); @@ -664,8 +676,7 @@ namespace Pamac { } void sysupgrade_simple (bool enable_downgrade) { - progress_dialog.progressbar.fraction = 0; - progress_dialog.cancel_button.visible = true; + progress_box.progressbar.fraction = 0; success = init (0); if (success) { try { @@ -695,8 +706,7 @@ namespace Pamac { public void sysupgrade (bool enable_downgrade) { this.enable_downgrade = enable_downgrade; string action = dgettext (null, "Starting full system upgrade") + "..."; - reset_progress_dialog (action); - emit_action (action); + reset_progress_box (action); start_get_updates_for_sysupgrade (); } @@ -748,8 +758,7 @@ namespace Pamac { public void run () { string action = dgettext (null, "Preparing") + "..."; - reset_progress_dialog (action); - emit_action (action); + reset_progress_box (action); // run if (to_install.length == 0 && to_remove.length == 0 @@ -962,7 +971,6 @@ namespace Pamac { } public void start_commit () { - progress_dialog.cancel_button.visible = false; try { daemon.start_trans_commit (); } catch (IOError e) { @@ -974,15 +982,10 @@ namespace Pamac { public void build_aur_packages () { string action = dgettext (null, "Building packages") + "..."; - reset_progress_dialog (action, false, true); - emit_action (action); - progress_dialog.term.grab_focus (); - pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse); - progress_dialog.close_button.visible = false; - progress_dialog.show (); - while (Gtk.events_pending ()) { - Gtk.main_iteration (); - } + reset_progress_box (action); + term.grab_focus (); + pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_box.progressbar.pulse); + important_details_outpout (true); start_transaction (); string[] cmds = {"yaourt", "-S"}; if (pamac_config.no_confirm_build) { @@ -992,9 +995,9 @@ namespace Pamac { cmds += name; } Pid child_pid; - progress_dialog.spawn_in_term (cmds, out child_pid); + spawn_in_term (cmds, out child_pid); // watch_child is needed in order to have the child_exited signal emitted - progress_dialog.term.watch_child (child_pid); + term.watch_child (child_pid); //~ foreach (unowned string pkgname in to_build) { //~ stdout.printf("aur deps for %s:\n", pkgname); //~ get_aur_build_list.begin (pkgname, (obj, res) => { @@ -1012,9 +1015,8 @@ namespace Pamac { } catch (IOError e) { stderr.printf ("IOError: %s\n", e.message); } - progress_dialog.hide (); - progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"}); - progress_dialog.expander.expanded = false; + progress_box.hide (); + spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"}); dialog_textbuffer = new StringBuilder (); } @@ -1054,46 +1056,40 @@ namespace Pamac { action = dgettext (null, "Checking inter-conflicts") + "..."; break; case 9: //Alpm.Event.Type.TRANSACTION_START - progress_dialog.cancel_button.visible = false; start_transaction (); break; case 11: //Alpm.Event.Type.PACKAGE_OPERATION_START switch (secondary_event) { - // special cases handle differently + // special case handle differently case 1: //Alpm.Package.Operation.INSTALL previous_filename = details[0]; string msg = dgettext (null, "Installing %s").printf (details[0]) + "..."; - progress_dialog.action_label.label = msg; - emit_action (msg); - progress_dialog.spawn_in_term ({"echo", dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "..."}); + progress_box.action_label.label = msg; + spawn_in_term ({"echo", dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1])) + "..."}); break; case 2: //Alpm.Package.Operation.UPGRADE previous_filename = details[0]; string msg = dgettext (null, "Upgrading %s").printf (details[0]) + "..."; - progress_dialog.action_label.label = msg; - emit_action (msg); - progress_dialog.spawn_in_term ({"echo", dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "..."}); + progress_box.action_label.label = msg; + spawn_in_term ({"echo", dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2])) + "..."}); break; case 3: //Alpm.Package.Operation.REINSTALL previous_filename = details[0]; string msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "..."; - progress_dialog.action_label.label = msg; - emit_action (msg); - progress_dialog.spawn_in_term ({"echo", dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1]))+ "..."}); + progress_box.action_label.label = msg; + spawn_in_term ({"echo", dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1])) + "..."}); break; case 4: //Alpm.Package.Operation.DOWNGRADE previous_filename = details[0]; string msg = dgettext (null, "Downgrading %s").printf (details[0]) + "..."; - progress_dialog.action_label.label = msg; - emit_action (msg); - progress_dialog.spawn_in_term ({"echo", dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "..."}); + progress_box.action_label.label = msg; + spawn_in_term ({"echo", dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2])) + "..."}); break; case 5: //Alpm.Package.Operation.REMOVE previous_filename = details[0]; string msg = dgettext (null, "Removing %s").printf (details[0]) + "..."; - progress_dialog.action_label.label = msg; - emit_action (msg); - progress_dialog.spawn_in_term ({"echo", dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "..."}); + progress_box.action_label.label = msg; + spawn_in_term ({"echo", dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1])) + "..."}); break; } break; @@ -1119,19 +1115,20 @@ namespace Pamac { detailed_action = dgettext (null, "Generation failed") + "..."; break; case 24: //Alpm.Event.Type.SCRIPTLET_INFO - progress_dialog.expander.expanded = true; action = dgettext (null, "Configuring %s").printf (previous_filename) + "..."; detailed_action = details[0].replace ("\n", ""); + important_details_outpout (false); break; case 25: //Alpm.Event.Type.RETRIEVE_START - progress_dialog.cancel_button.visible = true; action = dgettext (null, "Downloading") + "..."; break; case 28: //Alpm.Event.Type.PKGDOWNLOAD_START + // special case handle differently + spawn_in_term ({"echo", dgettext (null, "Downloading %s").printf (details[0]) + "..."}); string name_version_release = details[0].slice (0, details[0].last_index_of_char ('-')); string name_version = name_version_release.slice (0, name_version_release.last_index_of_char ('-')); string name = name_version.slice (0, name_version.last_index_of_char ('-')); - action = dgettext (null, "Downloading %s").printf (name) + "..."; + progress_box.action_label.label = dgettext (null, "Downloading %s").printf (name) + "..."; break; case 31: //Alpm.Event.Type.DISKSPACE_START action = dgettext (null, "Checking available disk space") + "..."; @@ -1144,7 +1141,6 @@ namespace Pamac { detailed_action = dgettext (null, "Database file for %s does not exist").printf (details[0]); break; case 35: //Alpm.Event.Type.KEYRING_START - progress_dialog.cancel_button.visible = true; action = dgettext (null, "Checking keyring") + "..."; break; case 37: //Alpm.Event.Type.KEY_DOWNLOAD_START @@ -1169,33 +1165,26 @@ namespace Pamac { } break; case 43: // Alpm.Event.Type.HOOK_RUN_START - string textbar = "%s/%s".printf (details[2], details[3]); - if (textbar != previous_textbar) { - previous_textbar = textbar; - progress_dialog.progressbar.text = textbar; - } float fraction = (float) int.parse (details[2]) / int.parse (details[3]); if (fraction != previous_percent) { previous_percent = fraction; - progress_dialog.progressbar.fraction = fraction; + progress_box.progressbar.fraction = fraction; } if (details[1] != "") { - detailed_action = details[1] + ":"; + detailed_action = details[1]; } else { - detailed_action = details[0] + ":"; + detailed_action = details[0]; } - break; default: break; } if (action != null) { - progress_dialog.action_label.label = action; - progress_dialog.spawn_in_term ({"echo", action}); - emit_action (action); + progress_box.action_label.label = action; + spawn_in_term ({"echo", action}); } if (detailed_action != null) { - progress_dialog.spawn_in_term ({"echo", detailed_action}); + spawn_in_term ({"echo", detailed_action}); } } @@ -1225,11 +1214,11 @@ namespace Pamac { string textbar = "%lu/%lu".printf (current_target, n_targets); if (textbar != previous_textbar) { previous_textbar = textbar; - progress_dialog.progressbar.text = textbar; + progress_box.progressbar.text = textbar; } if (fraction != previous_percent) { previous_percent = fraction; - progress_dialog.progressbar.fraction = fraction; + progress_box.progressbar.fraction = fraction; } } @@ -1238,6 +1227,7 @@ namespace Pamac { float fraction; if (total_download > 0) { if (xfered == 0) { + // start download pkg is handled by Alpm.Event.Type.PKGDOWNLOAD_START previous_xfered = 0; fraction = previous_percent; text.append (previous_textbar); @@ -1283,12 +1273,10 @@ namespace Pamac { rates_nb = 0; fraction = 0; timer.start (); - // start download pkg is handled by Alpm.Event.Type.PKGDOWNLOAD_START if (filename.has_suffix (".db")) { string action = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "..."; - progress_dialog.action_label.label = action; - progress_dialog.spawn_in_term ({"echo", action}); - emit_action (action); + progress_box.action_label.label = action; + spawn_in_term ({"echo", action}); } } else if (xfered == total) { timer.stop (); @@ -1326,11 +1314,11 @@ namespace Pamac { } if (fraction != previous_percent) { previous_percent = fraction; - progress_dialog.progressbar.fraction = fraction; + progress_box.progressbar.fraction = fraction; } if (text.str != previous_textbar) { previous_textbar = text.str; - progress_dialog.progressbar.text = text.str; + progress_box.progressbar.text = text.str; } } @@ -1344,6 +1332,7 @@ namespace Pamac { // with the value 0 so stop our timer if (total == 0) { timer.stop (); + progress_box.progressbar.text = ""; } } @@ -1356,6 +1345,7 @@ namespace Pamac { } else { line = dgettext (null, "Error") + ": " + msg; } + important_details_outpout (false); } else if (level == (1 << 1)) { //Alpm.LogLevel.WARNING // do not show warning when manjaro-system remove db.lck if (previous_filename != "manjaro-system") { @@ -1368,7 +1358,7 @@ namespace Pamac { } } if (line != null) { - progress_dialog.spawn_in_term ({"echo", "-n", line}); + spawn_in_term ({"echo", "-n", line}); } } @@ -1401,7 +1391,7 @@ namespace Pamac { } void display_error (string message, string[] details) { - progress_dialog.spawn_in_term ({"echo", "-n", message}); + spawn_in_term ({"echo", "-n", message}); var dialog = new Gtk.MessageDialog (application_window, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, @@ -1409,9 +1399,9 @@ namespace Pamac { message); if (details.length != 0) { var textbuffer = new StringBuilder (); - progress_dialog.spawn_in_term ({"echo", ":"}); + spawn_in_term ({"echo", ":"}); foreach (unowned string detail in details) { - progress_dialog.spawn_in_term ({"echo", detail}); + spawn_in_term ({"echo", detail}); textbuffer.append (detail + "\n"); } dialog.secondary_text = textbuffer.str; @@ -1422,24 +1412,17 @@ namespace Pamac { void handle_error (ErrorInfos error) { if (error.message != "") { - progress_dialog.action_label.label = ""; - progress_dialog.progressbar.fraction = 0; + reset_progress_box (""); display_error (error.message, error.details); - progress_dialog.spawn_in_term ({"echo"}); - progress_dialog.spawn_in_term ({"echo"}); } finish_transaction (); } void finish_transaction () { transaction_summary.remove_all (); - if (progress_dialog.expander.expanded) { - progress_dialog.show (); - progress_dialog.cancel_button.visible = false; - progress_dialog.close_button.clicked.connect (hide_progress_and_finish); - } else { - hide_progress_and_finish (); - } + reset_progress_box (""); + finished (success); + success = false; } void on_refresh_finished (bool success) { @@ -1447,7 +1430,7 @@ namespace Pamac { clear_lists (); if (success) { finished (success); - progress_dialog.hide (); + reset_progress_box (""); success = false; } else { handle_error (get_current_error ()); @@ -1456,18 +1439,6 @@ namespace Pamac { daemon.refresh_finished.disconnect (on_refresh_finished); } - void hide_progress_and_finish () { - finished (success); - progress_dialog.hide (); - progress_dialog.expander.expanded = false; - success = false; - progress_dialog.close_button.clicked.connect (hide_progress); - } - - void on_progress_dialog_cancel_button_clicked () { - cancel (); - } - void on_trans_prepare_finished (bool success) { this.success = success; if (success) { @@ -1501,8 +1472,8 @@ namespace Pamac { } else { transaction_sum_dialog.hide (); unowned string action = dgettext (null, "Transaction cancelled"); - progress_dialog.spawn_in_term ({"echo", action + ".\n"}); - progress_dialog.action_label.label = action; + spawn_in_term ({"echo", action + ".\n"}); + progress_box.action_label.label = action; release (); transaction_summary.remove_all (); sysupgrade_after_trans = false; @@ -1512,7 +1483,7 @@ namespace Pamac { } else { //var err = ErrorInfos (); //err.message = dgettext (null, "Nothing to do") + "\n"; - progress_dialog.spawn_in_term ({"echo", dgettext (null, "Nothing to do") + ".\n"}); + spawn_in_term ({"echo", dgettext (null, "Nothing to do") + ".\n"}); release (); clear_lists (); finish_transaction (); @@ -1530,7 +1501,7 @@ namespace Pamac { if (previous_to_install.length != 0 || previous_to_remove.length != 0 || to_load.length != 0) { - progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"}); + spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"}); } build_aur_packages (); } else { @@ -1541,8 +1512,8 @@ namespace Pamac { sysupgrade (false); } else { unowned string action = dgettext (null, "Transaction successfully finished"); - progress_dialog.spawn_in_term ({"echo", action + ".\n"}); - progress_dialog.action_label.label = action; + spawn_in_term ({"echo", action + ".\n"}); + progress_box.action_label.label = action; finish_transaction (); } } @@ -1576,16 +1547,12 @@ namespace Pamac { if (status == 0) { success = true; unowned string action = dgettext (null, "Transaction successfully finished"); - progress_dialog.spawn_in_term ({"echo", action + ".\n"}); - progress_dialog.action_label.label = action; + spawn_in_term ({"echo", action + "."}); + progress_box.action_label.label = action; } else { success = false; - progress_dialog.spawn_in_term ({"echo"}); } - transaction_summary.remove_all (); - progress_dialog.progressbar.fraction = 1; - progress_dialog.close_button.clicked.connect (hide_progress_and_finish); - progress_dialog.close_button.visible = true; + finish_transaction (); return false; }); } @@ -1615,12 +1582,12 @@ namespace Pamac { } void on_generate_mirrors_list_data (string line) { - progress_dialog.spawn_in_term ({"echo", "-n", line}); + spawn_in_term ({"echo", "-n", line}); } void on_generate_mirrors_list_finished () { Source.remove (pulse_timeout_id); - progress_dialog.spawn_in_term ({"echo"}); + spawn_in_term ({"echo"}); // force a dbs refresh start_refresh (true); } diff --git a/src/updater_window.vala b/src/updater_window.vala index b19be4a..6512a02 100644 --- a/src/updater_window.vala +++ b/src/updater_window.vala @@ -25,8 +25,12 @@ namespace Pamac { [GtkChild] Gtk.HeaderBar headerbar; [GtkChild] + Gtk.Button button_back; + [GtkChild] Gtk.ModelButton preferences_button; [GtkChild] + Gtk.Stack stack; + [GtkChild] Gtk.StackSwitcher stackswitcher; [GtkChild] Gtk.ScrolledWindow repos_scrolledwindow; @@ -45,8 +49,6 @@ namespace Pamac { [GtkChild] Gtk.Box transaction_infobox; [GtkChild] - Gtk.Label transaction_infos_label; - [GtkChild] Gtk.Button details_button; [GtkChild] Gtk.Button apply_button; @@ -59,16 +61,19 @@ namespace Pamac { public Pamac.Transaction transaction; public bool transaction_running; + bool important_details; public UpdaterWindow (Gtk.Application application) { Object (application: application); + button_back.visible = false; bottom_label.visible = false; apply_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); - apply_button.visible = false; + apply_button.sensitive = false; stackswitcher.visible = false; aur_scrolledwindow.visible = false; transaction_running = false; + important_details = false; Timeout.add (100, populate_window); } @@ -84,12 +89,18 @@ namespace Pamac { transaction = new Transaction (this as Gtk.ApplicationWindow); transaction.mode = Mode.UPDATER; transaction.start_transaction.connect (on_start_transaction); - transaction.emit_action.connect (on_emit_action); + transaction.important_details_outpout.connect (on_important_details_outpout); transaction.finished.connect (populate_updates_list); transaction.get_updates_finished.connect (on_get_updates_finished); + // integrate progress box and term widget + stack.add_named (transaction.term_grid, "term"); + transaction_infobox.pack_start (transaction.progress_box); + on_refresh_button_clicked (); + stack.notify["visible-child"].connect (on_stack_visible_child_changed); + return false; } @@ -110,6 +121,10 @@ namespace Pamac { }); } transaction_infobox.visible = visible; + if (visible) { + // fix an possible visibility issue + transaction_infobox.show_all (); + } } [GtkCallback] @@ -150,6 +165,17 @@ namespace Pamac { } } + [GtkCallback] + void on_button_back_clicked () { + stack.visible_child_name = "repos"; + } + + void on_stack_visible_child_changed () { + if (stack.visible_child_name == "term") { + button_back.visible = true; + } + } + [GtkCallback] void on_menu_button_toggled () { preferences_button.sensitive = !transaction_running; @@ -166,18 +192,18 @@ namespace Pamac { void on_apply_button_clicked () { transaction_running = true; transaction.sysupgrade (false); - apply_button.visible = false; - details_button.visible = true; - cancel_button.visible = true; + apply_button.sensitive = false; + details_button.sensitive = true; + cancel_button.sensitive = true; } [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; - apply_button.visible = false; - details_button.visible = true; - cancel_button.visible = true; + apply_button.sensitive = false; + details_button.sensitive = true; + cancel_button.sensitive = true; transaction.start_refresh (false); } @@ -193,7 +219,9 @@ namespace Pamac { [GtkCallback] void on_details_button_clicked () { - transaction.show_progress (); + details_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + important_details = false; + stack.visible_child_name = "term"; } [GtkCallback] @@ -202,21 +230,30 @@ namespace Pamac { } void on_start_transaction () { - cancel_button.visible = false; + cancel_button.sensitive = false; } - void on_emit_action (string action) { - transaction_infos_label.label = action; + void on_important_details_outpout (bool must_show) { + if (must_show) { + stack.visible_child_name = "term"; + button_back.visible = false; + } else if (stack.visible_child_name != "term") { + important_details = true; + details_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + } } void populate_updates_list () { transaction_running = false; - apply_button.visible = true; + apply_button.sensitive = true; apply_button.grab_default (); - details_button.visible = false; - cancel_button.visible = false; + details_button.sensitive = false; + cancel_button.sensitive = false; + if (stack.visible_child_name == "term") { + button_back.visible = true; + } this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); - transaction_infos_label.label = ""; + transaction.progress_box.action_label.label = ""; transaction.start_get_updates (); }