v4.1.0-beta2

This commit is contained in:
guinux 2016-05-17 19:11:49 +02:00
parent 86f7f243e9
commit 92191382bc
13 changed files with 316 additions and 269 deletions

View File

@ -12,6 +12,7 @@ MANAGER_RESOURCES_FILES = manager_window.ui \
UPDATER_RESOURCES_FILES = updater_window.ui UPDATER_RESOURCES_FILES = updater_window.ui
TRANSACTION_RESOURCES_FILES = progress_dialog.ui \ TRANSACTION_RESOURCES_FILES = progress_dialog.ui \
progress_box.ui \
choose_provider_dialog.ui \ choose_provider_dialog.ui \
transaction_sum_dialog.ui \ transaction_sum_dialog.ui \
preferences_dialog.ui \ preferences_dialog.ui \

View File

@ -382,7 +382,6 @@
<property name="fixed_height_mode">True</property> <property name="fixed_height_mode">True</property>
<property name="show_expanders">False</property> <property name="show_expanders">False</property>
<property name="rubber_banding">True</property> <property name="rubber_banding">True</property>
<property name="activate_on_single_click">True</property>
<signal name="button-press-event" handler="on_packages_treeview_button_press_event" swapped="no"/> <signal name="button-press-event" handler="on_packages_treeview_button_press_event" swapped="no"/>
<signal name="row-activated" handler="on_packages_treeview_row_activated" swapped="no"/> <signal name="row-activated" handler="on_packages_treeview_row_activated" swapped="no"/>
<child internal-child="selection"> <child internal-child="selection">
@ -499,7 +498,6 @@
<property name="fixed_height_mode">True</property> <property name="fixed_height_mode">True</property>
<property name="show_expanders">False</property> <property name="show_expanders">False</property>
<property name="rubber_banding">True</property> <property name="rubber_banding">True</property>
<property name="activate_on_single_click">True</property>
<signal name="button-press-event" handler="on_aur_treeview_button_press_event" swapped="no"/> <signal name="button-press-event" handler="on_aur_treeview_button_press_event" swapped="no"/>
<signal name="row-activated" handler="on_aur_treeview_row_activated" swapped="no"/> <signal name="row-activated" handler="on_aur_treeview_row_activated" swapped="no"/>
<child internal-child="selection"> <child internal-child="selection">
@ -885,16 +883,7 @@
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkLabel" id="transaction_infos_label"> <placeholder/>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkButtonBox" id="transaction_infos_buttonbox"> <object class="GtkButtonBox" id="transaction_infos_buttonbox">
@ -950,6 +939,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>

View File

@ -2,6 +2,7 @@
<gresources> <gresources>
<gresource prefix="/org/manjaro/pamac/transaction"> <gresource prefix="/org/manjaro/pamac/transaction">
<file preprocess="xml-stripblanks">progress_dialog.ui</file> <file preprocess="xml-stripblanks">progress_dialog.ui</file>
<file preprocess="xml-stripblanks">progress_box.ui</file>
<file preprocess="xml-stripblanks">history_dialog.ui</file> <file preprocess="xml-stripblanks">history_dialog.ui</file>
<file preprocess="xml-stripblanks">choose_provider_dialog.ui</file> <file preprocess="xml-stripblanks">choose_provider_dialog.ui</file>
<file preprocess="xml-stripblanks">transaction_sum_dialog.ui</file> <file preprocess="xml-stripblanks">transaction_sum_dialog.ui</file>

34
resources/progress_box.ui Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<template class="PamacProgressBox" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="action_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_text">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</template>
</interface>

View File

@ -58,29 +58,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="action_label"> <placeholder/>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">12</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_text">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkExpander" id="expander"> <object class="GtkExpander" id="expander">

View File

@ -182,6 +182,7 @@
<child> <child>
<object class="GtkTreeViewColumn" id="treeviewcolumn10"> <object class="GtkTreeViewColumn" id="treeviewcolumn10">
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">90</property> <property name="fixed_width">90</property>
<property name="min_width">20</property> <property name="min_width">20</property>
<property name="title" translatable="yes">Repository</property> <property name="title" translatable="yes">Repository</property>
@ -306,7 +307,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox" id="transaction_infobox"> <object class="GtkBox" id="box2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">6</property> <property name="margin_left">6</property>
@ -327,21 +328,12 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox" id="box2"> <object class="GtkBox" id="transaction_infobox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkLabel" id="transaction_infos_label"> <placeholder/>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkButtonBox" id="transaction_infos_buttonbox"> <object class="GtkButtonBox" id="transaction_infos_buttonbox">
@ -400,6 +392,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
@ -424,6 +417,26 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="show_close_button">True</property> <property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="button_back">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<signal name="clicked" handler="on_button_back_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="back_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-previous-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
</child>
<child> <child>
<object class="GtkMenuButton" id="menu_button"> <object class="GtkMenuButton" id="menu_button">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -28,6 +28,7 @@ TRANSACTION_SOURCES = package.vala \
history_dialog.vala \ history_dialog.vala \
choose_provider_dialog.vala \ choose_provider_dialog.vala \
transaction_sum_dialog.vala \ transaction_sum_dialog.vala \
progress_box.vala \
progress_dialog.vala progress_dialog.vala
PREFERENCES_SOURCES = preferences_dialog.vala \ PREFERENCES_SOURCES = preferences_dialog.vala \

View File

@ -1641,7 +1641,7 @@ namespace Pamac {
private void write_log_file (string event) { private void write_log_file (string event) {
var now = new DateTime.now_local (); 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"); var file = GLib.File.new_for_path ("/var/log/pacman.log");
try { try {
// creating a DataOutputStream to the file // creating a DataOutputStream to the file

View File

@ -109,7 +109,7 @@ namespace Pamac {
[GtkChild] [GtkChild]
Gtk.Box transaction_infobox; Gtk.Box transaction_infobox;
[GtkChild] [GtkChild]
Gtk.Label transaction_infos_label; Gtk.Button details_button;
[GtkChild] [GtkChild]
Gtk.Button apply_button; Gtk.Button apply_button;
[GtkChild] [GtkChild]
@ -138,6 +138,7 @@ namespace Pamac {
public Transaction transaction; public Transaction transaction;
bool refreshing; bool refreshing;
bool important_details;
public bool transaction_running; public bool transaction_running;
uint search_entry_timeout_id; uint search_entry_timeout_id;
@ -149,6 +150,7 @@ namespace Pamac {
button_back.visible = false; button_back.visible = false;
transaction_infobox.visible = false;; transaction_infobox.visible = false;;
refreshing = false; refreshing = false;
important_details = false;
transaction_running = false; transaction_running = false;
Timeout.add (100, populate_window); Timeout.add (100, populate_window);
@ -279,11 +281,15 @@ namespace Pamac {
transaction = new Transaction (this as Gtk.ApplicationWindow); transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.MANAGER; transaction.mode = Mode.MANAGER;
transaction.start_transaction.connect (on_start_transaction); 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.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);
// 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"); AlpmPackage pkg = transaction.find_installed_satisfier ("yaourt");
if (pkg.name != "") { if (pkg.name != "") {
support_aur (transaction.enable_aur, transaction.search_aur); support_aur (transaction.enable_aur, transaction.search_aur);
@ -335,11 +341,13 @@ namespace Pamac {
if (!transaction_running) { if (!transaction_running) {
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_infobox.visible = false; transaction.progress_box.action_label.label = "";
transaction_infobox.visible = important_details;
} 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_infos_label.label = info; transaction.progress_box.action_label.label = info;
transaction_infobox.visible = true; // fix an possible visibility issue
transaction_infobox.show_all ();
} }
} }
} }
@ -1436,6 +1444,7 @@ namespace Pamac {
filters_stackswitcher.visible = true; filters_stackswitcher.visible = true;
break; break;
case "details": case "details":
case "term":
filters_stackswitcher.visible = false; filters_stackswitcher.visible = false;
button_back.visible = true; button_back.visible = true;
break; break;
@ -1508,8 +1517,14 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
void on_details_button_clicked () { void on_details_button_clicked () {
details_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
important_details = false;
if (transaction_running) { if (transaction_running) {
transaction.show_progress (); main_stack.visible_child_name = "term";
} else {
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 { } else {
main_stack.visible_child_name = "browse"; main_stack.visible_child_name = "browse";
filters_stack.notify["visible-child"].disconnect (on_filters_stack_visible_child_changed); filters_stack.notify["visible-child"].disconnect (on_filters_stack_visible_child_changed);
@ -1526,11 +1541,12 @@ namespace Pamac {
refresh_packages_list (); refresh_packages_list ();
} }
} }
}
[GtkCallback] [GtkCallback]
void on_apply_button_clicked () { void on_apply_button_clicked () {
transaction_running = true; transaction_running = true;
apply_button.visible = false; apply_button.sensitive = false;
transaction.run (); transaction.run ();
} }
@ -1545,6 +1561,9 @@ namespace Pamac {
if (main_stack.visible_child_name == "details") { if (main_stack.visible_child_name == "details") {
display_package_properties (current_package_displayed); 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)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
refreshing = true; refreshing = true;
transaction.start_refresh (false); transaction.start_refresh (false);
apply_button.visible = false; apply_button.sensitive = false;
transaction_infobox.visible = true; transaction_infobox.visible = true;
} }
void on_start_transaction () { void on_start_transaction () {
cancel_button.visible = false; cancel_button.sensitive = false;
} }
void on_emit_action (string action) { void on_important_details_outpout (bool must_show) {
transaction_infos_label.label = action; 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) { 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") {
display_package_properties (current_package_displayed); display_package_properties (current_package_displayed);
} else if (main_stack.visible_child_name == "term") {
button_back.visible = true;
} }
transaction.to_load.remove_all (); transaction.to_load.remove_all ();
if (refreshing) { if (refreshing) {
@ -1579,8 +1606,8 @@ namespace Pamac {
refreshing = false; refreshing = false;
} else { } else {
transaction_running = false; transaction_running = false;
cancel_button.visible = true; cancel_button.sensitive = true;
apply_button.visible = true; apply_button.sensitive = true;
} }
set_pendings_operations (); set_pendings_operations ();
} }

36
src/progress_box.vala Normal file
View File

@ -0,0 +1,36 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 ();
}
}
}

View File

@ -22,10 +22,6 @@ namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")]
class ProgressDialog : Gtk.Dialog { class ProgressDialog : Gtk.Dialog {
[GtkChild]
public Gtk.ProgressBar progressbar;
[GtkChild]
public Gtk.Label action_label;
[GtkChild] [GtkChild]
public Gtk.Button cancel_button; public Gtk.Button cancel_button;
[GtkChild] [GtkChild]
@ -33,44 +29,10 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.Expander expander; public Gtk.Expander expander;
public Vte.Terminal term;
Vte.Pty pty;
public ProgressDialog (Gtk.ApplicationWindow? window) { public ProgressDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 1); 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);
}
} }
} }

View File

@ -147,12 +147,15 @@ namespace Pamac {
//dialogs //dialogs
TransactionSumDialog transaction_sum_dialog; TransactionSumDialog transaction_sum_dialog;
ProgressDialog progress_dialog; public ProgressBox progress_box;
Vte.Terminal term;
Vte.Pty pty;
public Gtk.Grid term_grid;
//parent window //parent window
public Gtk.ApplicationWindow? application_window { get; private set; } public Gtk.ApplicationWindow? application_window { get; private set; }
public signal void start_transaction (); 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 alpm_handle_refreshed ();
public signal void finished (bool success); public signal void finished (bool success);
public signal void set_pkgreason_finished (); public signal void set_pkgreason_finished ();
@ -182,11 +185,30 @@ namespace Pamac {
//creating dialogs //creating dialogs
this.application_window = application_window; this.application_window = application_window;
transaction_sum_dialog = new TransactionSumDialog (application_window); transaction_sum_dialog = new TransactionSumDialog (application_window);
progress_dialog = new ProgressDialog (application_window); progress_box = new ProgressBox ();
progress_dialog.close_button.clicked.connect (hide_progress); progress_box.progressbar.text = "";
progress_dialog.cancel_button.clicked.connect (on_progress_dialog_cancel_button_clicked); //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 // 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 // progress data
previous_textbar = ""; previous_textbar = "";
previous_filename = ""; previous_filename = "";
@ -298,36 +320,27 @@ namespace Pamac {
} }
} }
public void show_progress () { void spawn_in_term (string[] args, out Pid child_pid = null) {
progress_dialog.show (); 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);
} }
public void hide_progress () { void reset_progress_box (string action) {
progress_dialog.hide (); spawn_in_term ({"echo", action});
} progress_box.action_label.label = action;
progress_box.progressbar.fraction = 0;
void reset_progress_dialog (string action, progress_box.progressbar.text = "";
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;
}
} }
public void start_generate_mirrors_list () { public void start_generate_mirrors_list () {
string action = dgettext (null, "Refreshing mirrors list") + "..."; string action = dgettext (null, "Refreshing mirrors list") + "...";
reset_progress_dialog (action, false, true); reset_progress_box (action);
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse); pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_box.progressbar.pulse);
progress_dialog.show (); important_details_outpout (false);
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
try { try {
daemon.start_generate_mirrors_list (); daemon.start_generate_mirrors_list ();
} catch (IOError e) { } catch (IOError e) {
@ -346,8 +359,7 @@ namespace Pamac {
public void start_refresh (bool force) { public void start_refresh (bool force) {
string action = dgettext (null, "Synchronizing package databases") + "..."; string action = dgettext (null, "Synchronizing package databases") + "...";
reset_progress_dialog (action); reset_progress_box (action);
emit_action (action);
try { try {
daemon.refresh_finished.connect (on_refresh_finished); daemon.refresh_finished.connect (on_refresh_finished);
daemon.start_refresh (force); daemon.start_refresh (force);
@ -664,8 +676,7 @@ namespace Pamac {
} }
void sysupgrade_simple (bool enable_downgrade) { void sysupgrade_simple (bool enable_downgrade) {
progress_dialog.progressbar.fraction = 0; progress_box.progressbar.fraction = 0;
progress_dialog.cancel_button.visible = true;
success = init (0); success = init (0);
if (success) { if (success) {
try { try {
@ -695,8 +706,7 @@ namespace Pamac {
public void sysupgrade (bool enable_downgrade) { public void sysupgrade (bool enable_downgrade) {
this.enable_downgrade = enable_downgrade; this.enable_downgrade = enable_downgrade;
string action = dgettext (null, "Starting full system upgrade") + "..."; string action = dgettext (null, "Starting full system upgrade") + "...";
reset_progress_dialog (action); reset_progress_box (action);
emit_action (action);
start_get_updates_for_sysupgrade (); start_get_updates_for_sysupgrade ();
} }
@ -748,8 +758,7 @@ namespace Pamac {
public void run () { public void run () {
string action = dgettext (null, "Preparing") + "..."; string action = dgettext (null, "Preparing") + "...";
reset_progress_dialog (action); reset_progress_box (action);
emit_action (action);
// run // run
if (to_install.length == 0 if (to_install.length == 0
&& to_remove.length == 0 && to_remove.length == 0
@ -962,7 +971,6 @@ namespace Pamac {
} }
public void start_commit () { public void start_commit () {
progress_dialog.cancel_button.visible = false;
try { try {
daemon.start_trans_commit (); daemon.start_trans_commit ();
} catch (IOError e) { } catch (IOError e) {
@ -974,15 +982,10 @@ namespace Pamac {
public void build_aur_packages () { public void build_aur_packages () {
string action = dgettext (null, "Building packages") + "..."; string action = dgettext (null, "Building packages") + "...";
reset_progress_dialog (action, false, true); reset_progress_box (action);
emit_action (action); term.grab_focus ();
progress_dialog.term.grab_focus (); pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_box.progressbar.pulse);
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse); important_details_outpout (true);
progress_dialog.close_button.visible = false;
progress_dialog.show ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
start_transaction (); start_transaction ();
string[] cmds = {"yaourt", "-S"}; string[] cmds = {"yaourt", "-S"};
if (pamac_config.no_confirm_build) { if (pamac_config.no_confirm_build) {
@ -992,9 +995,9 @@ namespace Pamac {
cmds += name; cmds += name;
} }
Pid child_pid; 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 // 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) { //~ foreach (unowned string pkgname in to_build) {
//~ stdout.printf("aur deps for %s:\n", pkgname); //~ stdout.printf("aur deps for %s:\n", pkgname);
//~ get_aur_build_list.begin (pkgname, (obj, res) => { //~ get_aur_build_list.begin (pkgname, (obj, res) => {
@ -1012,9 +1015,8 @@ namespace Pamac {
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
progress_dialog.hide (); progress_box.hide ();
progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"}); spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
progress_dialog.expander.expanded = false;
dialog_textbuffer = new StringBuilder (); dialog_textbuffer = new StringBuilder ();
} }
@ -1054,46 +1056,40 @@ namespace Pamac {
action = dgettext (null, "Checking inter-conflicts") + "..."; action = dgettext (null, "Checking inter-conflicts") + "...";
break; break;
case 9: //Alpm.Event.Type.TRANSACTION_START case 9: //Alpm.Event.Type.TRANSACTION_START
progress_dialog.cancel_button.visible = false;
start_transaction (); start_transaction ();
break; break;
case 11: //Alpm.Event.Type.PACKAGE_OPERATION_START case 11: //Alpm.Event.Type.PACKAGE_OPERATION_START
switch (secondary_event) { switch (secondary_event) {
// special cases handle differently // special case handle differently
case 1: //Alpm.Package.Operation.INSTALL case 1: //Alpm.Package.Operation.INSTALL
previous_filename = details[0]; previous_filename = details[0];
string msg = dgettext (null, "Installing %s").printf (details[0]) + "..."; string msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
progress_dialog.action_label.label = msg; progress_box.action_label.label = msg;
emit_action (msg); spawn_in_term ({"echo", dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1])) + "..."});
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "..."});
break; break;
case 2: //Alpm.Package.Operation.UPGRADE case 2: //Alpm.Package.Operation.UPGRADE
previous_filename = details[0]; previous_filename = details[0];
string msg = dgettext (null, "Upgrading %s").printf (details[0]) + "..."; string msg = dgettext (null, "Upgrading %s").printf (details[0]) + "...";
progress_dialog.action_label.label = msg; progress_box.action_label.label = msg;
emit_action (msg); spawn_in_term ({"echo", dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2])) + "..."});
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "..."});
break; break;
case 3: //Alpm.Package.Operation.REINSTALL case 3: //Alpm.Package.Operation.REINSTALL
previous_filename = details[0]; previous_filename = details[0];
string msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "..."; string msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "...";
progress_dialog.action_label.label = msg; progress_box.action_label.label = msg;
emit_action (msg); spawn_in_term ({"echo", dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1])) + "..."});
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1]))+ "..."});
break; break;
case 4: //Alpm.Package.Operation.DOWNGRADE case 4: //Alpm.Package.Operation.DOWNGRADE
previous_filename = details[0]; previous_filename = details[0];
string msg = dgettext (null, "Downgrading %s").printf (details[0]) + "..."; string msg = dgettext (null, "Downgrading %s").printf (details[0]) + "...";
progress_dialog.action_label.label = msg; progress_box.action_label.label = msg;
emit_action (msg); spawn_in_term ({"echo", dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2])) + "..."});
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "..."});
break; break;
case 5: //Alpm.Package.Operation.REMOVE case 5: //Alpm.Package.Operation.REMOVE
previous_filename = details[0]; previous_filename = details[0];
string msg = dgettext (null, "Removing %s").printf (details[0]) + "..."; string msg = dgettext (null, "Removing %s").printf (details[0]) + "...";
progress_dialog.action_label.label = msg; progress_box.action_label.label = msg;
emit_action (msg); spawn_in_term ({"echo", dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1])) + "..."});
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "..."});
break; break;
} }
break; break;
@ -1119,19 +1115,20 @@ 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
progress_dialog.expander.expanded = true;
action = dgettext (null, "Configuring %s").printf (previous_filename) + "..."; action = dgettext (null, "Configuring %s").printf (previous_filename) + "...";
detailed_action = details[0].replace ("\n", ""); detailed_action = details[0].replace ("\n", "");
important_details_outpout (false);
break; break;
case 25: //Alpm.Event.Type.RETRIEVE_START case 25: //Alpm.Event.Type.RETRIEVE_START
progress_dialog.cancel_button.visible = true;
action = dgettext (null, "Downloading") + "..."; action = dgettext (null, "Downloading") + "...";
break; break;
case 28: //Alpm.Event.Type.PKGDOWNLOAD_START 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_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_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 ('-')); 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; break;
case 31: //Alpm.Event.Type.DISKSPACE_START case 31: //Alpm.Event.Type.DISKSPACE_START
action = dgettext (null, "Checking available disk space") + "..."; 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]); detailed_action = dgettext (null, "Database file for %s does not exist").printf (details[0]);
break; break;
case 35: //Alpm.Event.Type.KEYRING_START case 35: //Alpm.Event.Type.KEYRING_START
progress_dialog.cancel_button.visible = true;
action = dgettext (null, "Checking keyring") + "..."; action = dgettext (null, "Checking keyring") + "...";
break; break;
case 37: //Alpm.Event.Type.KEY_DOWNLOAD_START case 37: //Alpm.Event.Type.KEY_DOWNLOAD_START
@ -1169,33 +1165,26 @@ namespace Pamac {
} }
break; break;
case 43: // Alpm.Event.Type.HOOK_RUN_START 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]); float fraction = (float) int.parse (details[2]) / int.parse (details[3]);
if (fraction != previous_percent) { if (fraction != previous_percent) {
previous_percent = fraction; previous_percent = fraction;
progress_dialog.progressbar.fraction = fraction; progress_box.progressbar.fraction = fraction;
} }
if (details[1] != "") { if (details[1] != "") {
detailed_action = details[1] + ":"; detailed_action = details[1];
} else { } else {
detailed_action = details[0] + ":"; detailed_action = details[0];
} }
break; break;
default: default:
break; break;
} }
if (action != null) { if (action != null) {
progress_dialog.action_label.label = action; progress_box.action_label.label = action;
progress_dialog.spawn_in_term ({"echo", action}); spawn_in_term ({"echo", action});
emit_action (action);
} }
if (detailed_action != null) { 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); string textbar = "%lu/%lu".printf (current_target, n_targets);
if (textbar != previous_textbar) { if (textbar != previous_textbar) {
previous_textbar = textbar; previous_textbar = textbar;
progress_dialog.progressbar.text = textbar; progress_box.progressbar.text = textbar;
} }
if (fraction != previous_percent) { if (fraction != previous_percent) {
previous_percent = fraction; previous_percent = fraction;
progress_dialog.progressbar.fraction = fraction; progress_box.progressbar.fraction = fraction;
} }
} }
@ -1238,6 +1227,7 @@ namespace Pamac {
float fraction; float fraction;
if (total_download > 0) { if (total_download > 0) {
if (xfered == 0) { if (xfered == 0) {
// start download pkg is handled by Alpm.Event.Type.PKGDOWNLOAD_START
previous_xfered = 0; previous_xfered = 0;
fraction = previous_percent; fraction = previous_percent;
text.append (previous_textbar); text.append (previous_textbar);
@ -1283,12 +1273,10 @@ namespace Pamac {
rates_nb = 0; rates_nb = 0;
fraction = 0; fraction = 0;
timer.start (); timer.start ();
// start download pkg is handled by Alpm.Event.Type.PKGDOWNLOAD_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_dialog.action_label.label = action; progress_box.action_label.label = action;
progress_dialog.spawn_in_term ({"echo", action}); spawn_in_term ({"echo", action});
emit_action (action);
} }
} else if (xfered == total) { } else if (xfered == total) {
timer.stop (); timer.stop ();
@ -1326,11 +1314,11 @@ namespace Pamac {
} }
if (fraction != previous_percent) { if (fraction != previous_percent) {
previous_percent = fraction; previous_percent = fraction;
progress_dialog.progressbar.fraction = fraction; progress_box.progressbar.fraction = fraction;
} }
if (text.str != previous_textbar) { if (text.str != previous_textbar) {
previous_textbar = text.str; 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 // with the value 0 so stop our timer
if (total == 0) { if (total == 0) {
timer.stop (); timer.stop ();
progress_box.progressbar.text = "";
} }
} }
@ -1356,6 +1345,7 @@ namespace Pamac {
} else { } else {
line = dgettext (null, "Error") + ": " + msg; line = dgettext (null, "Error") + ": " + msg;
} }
important_details_outpout (false);
} else if (level == (1 << 1)) { //Alpm.LogLevel.WARNING } else if (level == (1 << 1)) { //Alpm.LogLevel.WARNING
// do not show warning when manjaro-system remove db.lck // do not show warning when manjaro-system remove db.lck
if (previous_filename != "manjaro-system") { if (previous_filename != "manjaro-system") {
@ -1368,7 +1358,7 @@ namespace Pamac {
} }
} }
if (line != null) { 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) { 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, var dialog = new Gtk.MessageDialog (application_window,
Gtk.DialogFlags.MODAL, Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR, Gtk.MessageType.ERROR,
@ -1409,9 +1399,9 @@ namespace Pamac {
message); message);
if (details.length != 0) { if (details.length != 0) {
var textbuffer = new StringBuilder (); var textbuffer = new StringBuilder ();
progress_dialog.spawn_in_term ({"echo", ":"}); spawn_in_term ({"echo", ":"});
foreach (unowned string detail in details) { foreach (unowned string detail in details) {
progress_dialog.spawn_in_term ({"echo", detail}); spawn_in_term ({"echo", detail});
textbuffer.append (detail + "\n"); textbuffer.append (detail + "\n");
} }
dialog.secondary_text = textbuffer.str; dialog.secondary_text = textbuffer.str;
@ -1422,24 +1412,17 @@ namespace Pamac {
void handle_error (ErrorInfos error) { void handle_error (ErrorInfos error) {
if (error.message != "") { if (error.message != "") {
progress_dialog.action_label.label = ""; reset_progress_box ("");
progress_dialog.progressbar.fraction = 0;
display_error (error.message, error.details); display_error (error.message, error.details);
progress_dialog.spawn_in_term ({"echo"});
progress_dialog.spawn_in_term ({"echo"});
} }
finish_transaction (); finish_transaction ();
} }
void finish_transaction () { void finish_transaction () {
transaction_summary.remove_all (); transaction_summary.remove_all ();
if (progress_dialog.expander.expanded) { reset_progress_box ("");
progress_dialog.show (); finished (success);
progress_dialog.cancel_button.visible = false; success = false;
progress_dialog.close_button.clicked.connect (hide_progress_and_finish);
} else {
hide_progress_and_finish ();
}
} }
void on_refresh_finished (bool success) { void on_refresh_finished (bool success) {
@ -1447,7 +1430,7 @@ namespace Pamac {
clear_lists (); clear_lists ();
if (success) { if (success) {
finished (success); finished (success);
progress_dialog.hide (); reset_progress_box ("");
success = false; success = false;
} else { } else {
handle_error (get_current_error ()); handle_error (get_current_error ());
@ -1456,18 +1439,6 @@ namespace Pamac {
daemon.refresh_finished.disconnect (on_refresh_finished); 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) { void on_trans_prepare_finished (bool success) {
this.success = success; this.success = success;
if (success) { if (success) {
@ -1501,8 +1472,8 @@ namespace Pamac {
} else { } else {
transaction_sum_dialog.hide (); transaction_sum_dialog.hide ();
unowned string action = dgettext (null, "Transaction cancelled"); unowned string action = dgettext (null, "Transaction cancelled");
progress_dialog.spawn_in_term ({"echo", action + ".\n"}); spawn_in_term ({"echo", action + ".\n"});
progress_dialog.action_label.label = action; progress_box.action_label.label = action;
release (); release ();
transaction_summary.remove_all (); transaction_summary.remove_all ();
sysupgrade_after_trans = false; sysupgrade_after_trans = false;
@ -1512,7 +1483,7 @@ namespace Pamac {
} else { } else {
//var err = ErrorInfos (); //var err = ErrorInfos ();
//err.message = dgettext (null, "Nothing to do") + "\n"; //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 (); release ();
clear_lists (); clear_lists ();
finish_transaction (); finish_transaction ();
@ -1530,7 +1501,7 @@ namespace Pamac {
if (previous_to_install.length != 0 if (previous_to_install.length != 0
|| previous_to_remove.length != 0 || previous_to_remove.length != 0
|| to_load.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 (); build_aur_packages ();
} else { } else {
@ -1541,8 +1512,8 @@ namespace Pamac {
sysupgrade (false); sysupgrade (false);
} else { } else {
unowned string action = dgettext (null, "Transaction successfully finished"); unowned string action = dgettext (null, "Transaction successfully finished");
progress_dialog.spawn_in_term ({"echo", action + ".\n"}); spawn_in_term ({"echo", action + ".\n"});
progress_dialog.action_label.label = action; progress_box.action_label.label = action;
finish_transaction (); finish_transaction ();
} }
} }
@ -1576,16 +1547,12 @@ namespace Pamac {
if (status == 0) { if (status == 0) {
success = true; success = true;
unowned string action = dgettext (null, "Transaction successfully finished"); unowned string action = dgettext (null, "Transaction successfully finished");
progress_dialog.spawn_in_term ({"echo", action + ".\n"}); spawn_in_term ({"echo", action + "."});
progress_dialog.action_label.label = action; progress_box.action_label.label = action;
} else { } else {
success = false; success = false;
progress_dialog.spawn_in_term ({"echo"});
} }
transaction_summary.remove_all (); finish_transaction ();
progress_dialog.progressbar.fraction = 1;
progress_dialog.close_button.clicked.connect (hide_progress_and_finish);
progress_dialog.close_button.visible = true;
return false; return false;
}); });
} }
@ -1615,12 +1582,12 @@ namespace Pamac {
} }
void on_generate_mirrors_list_data (string line) { 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 () { void on_generate_mirrors_list_finished () {
Source.remove (pulse_timeout_id); Source.remove (pulse_timeout_id);
progress_dialog.spawn_in_term ({"echo"}); spawn_in_term ({"echo"});
// force a dbs refresh // force a dbs refresh
start_refresh (true); start_refresh (true);
} }

View File

@ -25,8 +25,12 @@ namespace Pamac {
[GtkChild] [GtkChild]
Gtk.HeaderBar headerbar; Gtk.HeaderBar headerbar;
[GtkChild] [GtkChild]
Gtk.Button button_back;
[GtkChild]
Gtk.ModelButton preferences_button; Gtk.ModelButton preferences_button;
[GtkChild] [GtkChild]
Gtk.Stack stack;
[GtkChild]
Gtk.StackSwitcher stackswitcher; Gtk.StackSwitcher stackswitcher;
[GtkChild] [GtkChild]
Gtk.ScrolledWindow repos_scrolledwindow; Gtk.ScrolledWindow repos_scrolledwindow;
@ -45,8 +49,6 @@ namespace Pamac {
[GtkChild] [GtkChild]
Gtk.Box transaction_infobox; Gtk.Box transaction_infobox;
[GtkChild] [GtkChild]
Gtk.Label transaction_infos_label;
[GtkChild]
Gtk.Button details_button; Gtk.Button details_button;
[GtkChild] [GtkChild]
Gtk.Button apply_button; Gtk.Button apply_button;
@ -59,16 +61,19 @@ namespace Pamac {
public Pamac.Transaction transaction; public Pamac.Transaction transaction;
public bool transaction_running; public bool transaction_running;
bool important_details;
public UpdaterWindow (Gtk.Application application) { public UpdaterWindow (Gtk.Application application) {
Object (application: application); Object (application: application);
button_back.visible = false;
bottom_label.visible = false; bottom_label.visible = false;
apply_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); apply_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
apply_button.visible = false; apply_button.sensitive = false;
stackswitcher.visible = false; stackswitcher.visible = false;
aur_scrolledwindow.visible = false; aur_scrolledwindow.visible = false;
transaction_running = false; transaction_running = false;
important_details = false;
Timeout.add (100, populate_window); Timeout.add (100, populate_window);
} }
@ -84,12 +89,18 @@ namespace Pamac {
transaction = new Transaction (this as Gtk.ApplicationWindow); transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.UPDATER; transaction.mode = Mode.UPDATER;
transaction.start_transaction.connect (on_start_transaction); 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.finished.connect (populate_updates_list);
transaction.get_updates_finished.connect (on_get_updates_finished); 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 (); on_refresh_button_clicked ();
stack.notify["visible-child"].connect (on_stack_visible_child_changed);
return false; return false;
} }
@ -110,6 +121,10 @@ namespace Pamac {
}); });
} }
transaction_infobox.visible = visible; transaction_infobox.visible = visible;
if (visible) {
// fix an possible visibility issue
transaction_infobox.show_all ();
}
} }
[GtkCallback] [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] [GtkCallback]
void on_menu_button_toggled () { void on_menu_button_toggled () {
preferences_button.sensitive = !transaction_running; preferences_button.sensitive = !transaction_running;
@ -166,18 +192,18 @@ namespace Pamac {
void on_apply_button_clicked () { void on_apply_button_clicked () {
transaction_running = true; transaction_running = true;
transaction.sysupgrade (false); transaction.sysupgrade (false);
apply_button.visible = false; apply_button.sensitive = false;
details_button.visible = true; details_button.sensitive = true;
cancel_button.visible = true; cancel_button.sensitive = true;
} }
[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.visible = true;
apply_button.visible = false; apply_button.sensitive = false;
details_button.visible = true; details_button.sensitive = true;
cancel_button.visible = true; cancel_button.sensitive = true;
transaction.start_refresh (false); transaction.start_refresh (false);
} }
@ -193,7 +219,9 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
void on_details_button_clicked () { 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] [GtkCallback]
@ -202,21 +230,30 @@ namespace Pamac {
} }
void on_start_transaction () { void on_start_transaction () {
cancel_button.visible = false; cancel_button.sensitive = false;
} }
void on_emit_action (string action) { void on_important_details_outpout (bool must_show) {
transaction_infos_label.label = action; 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 () { void populate_updates_list () {
transaction_running = false; transaction_running = false;
apply_button.visible = true; apply_button.sensitive = true;
apply_button.grab_default (); apply_button.grab_default ();
details_button.visible = false; details_button.sensitive = false;
cancel_button.visible = 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)); 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 (); transaction.start_get_updates ();
} }