forked from cromer/pamac-classic
improve finish transaction handling
This commit is contained in:
parent
84bd81d417
commit
85731c3a9f
@ -1,12 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.19.0 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.12"/>
|
<requires lib="gtk+" version="3.12"/>
|
||||||
<template class="PamacProgressDialog" parent="GtkDialog">
|
<template class="PamacProgressDialog" parent="GtkDialog">
|
||||||
|
<property name="width_request">500</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
<property name="title" translatable="yes">Progress</property>
|
<property name="title" translatable="yes">Progress</property>
|
||||||
<property name="modal">True</property>
|
<property name="modal">True</property>
|
||||||
<property name="window_position">center-on-parent</property>
|
<property name="window_position">center-on-parent</property>
|
||||||
<property name="width_request">500</property>
|
|
||||||
<property name="icon_name">system-software-install</property>
|
<property name="icon_name">system-software-install</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
<property name="deletable">False</property>
|
<property name="deletable">False</property>
|
||||||
@ -14,44 +16,46 @@
|
|||||||
<object class="GtkBox" id="dialog-vbox1">
|
<object class="GtkBox" id="dialog-vbox1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">0</property>
|
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<child internal-child="action_area">
|
<child internal-child="action_area">
|
||||||
<object class="GtkButtonBox" id="dialog-action_area1">
|
<object class="GtkButtonBox" id="dialog-action_area1">
|
||||||
<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">6</property>
|
|
||||||
<property name="layout_style">end</property>
|
<property name="layout_style">end</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="cancel_button">
|
<object class="GtkButton" id="cancel_button">
|
||||||
<property name="label" translatable="yes">_Cancel</property>
|
<property name="label" translatable="yes">_Cancel</property>
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="close_button">
|
<object class="GtkButton" id="close_button">
|
||||||
<property name="label" translatable="yes">_Close</property>
|
<property name="label" translatable="yes">_Close</property>
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<signal name="clicked" handler="on_close_button_clicked" swapped="no"/>
|
<property name="receives_default">False</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -62,6 +66,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="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -74,6 +79,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="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -95,6 +101,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -75,7 +75,7 @@ pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi ../vapi/libcurl
|
|||||||
mirrors_config.vala \
|
mirrors_config.vala \
|
||||||
daemon.vala
|
daemon.vala
|
||||||
|
|
||||||
libpamac.so: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../resources/manager_resources.c
|
libpamac.so: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../resources/transaction_resources.c
|
||||||
valac -o libpamac.so \
|
valac -o libpamac.so \
|
||||||
-X -fPIC \
|
-X -fPIC \
|
||||||
-X --shared \
|
-X --shared \
|
||||||
|
@ -62,14 +62,6 @@ namespace Pamac {
|
|||||||
this.expander.add (grid);
|
this.expander.add (grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
[GtkCallback]
|
|
||||||
void on_close_button_clicked () {
|
|
||||||
this.hide ();
|
|
||||||
while (Gtk.events_pending ()) {
|
|
||||||
Gtk.main_iteration ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawn_in_term (string[] args, out Pid child_pid = null) {
|
public void spawn_in_term (string[] args, out Pid child_pid = null) {
|
||||||
Pid intern_pid;
|
Pid intern_pid;
|
||||||
try {
|
try {
|
||||||
|
@ -112,6 +112,7 @@ namespace Pamac {
|
|||||||
uint64 download_rate;
|
uint64 download_rate;
|
||||||
uint64 rates_nb;
|
uint64 rates_nb;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
|
bool database_modified;
|
||||||
|
|
||||||
//dialogs
|
//dialogs
|
||||||
TransactionSumDialog transaction_sum_dialog;
|
TransactionSumDialog transaction_sum_dialog;
|
||||||
@ -150,7 +151,8 @@ namespace Pamac {
|
|||||||
transaction_sum_dialog = new TransactionSumDialog (application_window);
|
transaction_sum_dialog = new TransactionSumDialog (application_window);
|
||||||
transaction_info_dialog = new TransactionInfoDialog (application_window);
|
transaction_info_dialog = new TransactionInfoDialog (application_window);
|
||||||
progress_dialog = new ProgressDialog (application_window);
|
progress_dialog = new ProgressDialog (application_window);
|
||||||
progress_dialog.cancel_button.clicked.connect (on_cancel_button_clicked);
|
progress_dialog.close_button.clicked.connect (on_progress_dialog_close_button_clicked);
|
||||||
|
progress_dialog.cancel_button.clicked.connect (on_progress_dialog_cancel_button_clicked);
|
||||||
// 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);
|
progress_dialog.term.child_exited.connect (on_term_child_exited);
|
||||||
// progress data
|
// progress data
|
||||||
@ -159,6 +161,7 @@ namespace Pamac {
|
|||||||
previous_filename = "";
|
previous_filename = "";
|
||||||
sysupgrade_after_trans = false;
|
sysupgrade_after_trans = false;
|
||||||
timer = new Timer ();
|
timer = new Timer ();
|
||||||
|
database_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void run_preferences_dialog () {
|
public async void run_preferences_dialog () {
|
||||||
@ -276,8 +279,8 @@ namespace Pamac {
|
|||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
stderr.printf ("IOError: %s\n", e.message);
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
daemon.refresh_finished.disconnect (on_refresh_finished);
|
daemon.refresh_finished.disconnect (on_refresh_finished);
|
||||||
refresh_handle ();
|
database_modified = true;
|
||||||
finished (true);
|
finish_transaction ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +289,7 @@ namespace Pamac {
|
|||||||
daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
|
daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
stderr.printf ("IOError: %s\n", e.message);
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
finished (false);
|
finish_transaction ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,15 +342,14 @@ namespace Pamac {
|
|||||||
daemon.start_trans_prepare ();
|
daemon.start_trans_prepare ();
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
stderr.printf ("IOError: %s\n", e.message);
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
finished (false);
|
release ();
|
||||||
|
finish_transaction ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
release ();
|
release ();
|
||||||
finished (false);
|
|
||||||
handle_error (get_current_error ());
|
handle_error (get_current_error ());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finished (false);
|
|
||||||
handle_error (get_current_error ());
|
handle_error (get_current_error ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,15 +475,14 @@ namespace Pamac {
|
|||||||
daemon.start_trans_prepare ();
|
daemon.start_trans_prepare ();
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
stderr.printf ("IOError: %s\n", e.message);
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
finished (false);
|
release ();
|
||||||
|
finish_transaction ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
release ();
|
release ();
|
||||||
finished (false);
|
|
||||||
handle_error (get_current_error ());
|
handle_error (get_current_error ());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finished (false);
|
|
||||||
handle_error (get_current_error ());
|
handle_error (get_current_error ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -645,8 +646,8 @@ namespace Pamac {
|
|||||||
daemon.start_trans_commit ();
|
daemon.start_trans_commit ();
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
stderr.printf ("IOError: %s\n", e.message);
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
refresh_handle ();
|
database_modified = true;
|
||||||
finished (true);
|
finish_transaction ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1139,37 +1140,57 @@ namespace Pamac {
|
|||||||
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
||||||
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
|
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
|
||||||
progress_dialog.progressbar.set_fraction (0);
|
progress_dialog.progressbar.set_fraction (0);
|
||||||
progress_dialog.cancel_button.set_visible (false);
|
|
||||||
progress_dialog.close_button.set_visible (true);
|
|
||||||
progress_dialog.spawn_in_term ({"echo"});
|
progress_dialog.spawn_in_term ({"echo"});
|
||||||
while (Gtk.events_pending ()) {
|
while (Gtk.events_pending ()) {
|
||||||
Gtk.main_iteration ();
|
Gtk.main_iteration ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finish_transaction ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_refresh_finished (bool success) {
|
void finish_transaction () {
|
||||||
|
if (database_modified) {
|
||||||
refresh_handle ();
|
refresh_handle ();
|
||||||
if (success) {
|
}
|
||||||
if (mode == Mode.UPDATER) {
|
if (progress_dialog.expander.get_expanded ()) {
|
||||||
finished (true);
|
progress_dialog.cancel_button.set_visible (false);
|
||||||
|
progress_dialog.close_button.set_visible (true);
|
||||||
|
} else {
|
||||||
|
finished (database_modified);
|
||||||
progress_dialog.hide ();
|
progress_dialog.hide ();
|
||||||
while (Gtk.events_pending ()) {
|
while (Gtk.events_pending ()) {
|
||||||
Gtk.main_iteration ();
|
Gtk.main_iteration ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
database_modified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_refresh_finished (bool success) {
|
||||||
|
database_modified = true;
|
||||||
|
if (success) {
|
||||||
|
if (mode == Mode.UPDATER) {
|
||||||
|
finish_transaction ();
|
||||||
} else {
|
} else {
|
||||||
|
refresh_handle ();
|
||||||
clear_lists ();
|
clear_lists ();
|
||||||
sysupgrade (false);
|
sysupgrade (false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finished (true);
|
|
||||||
handle_error (get_current_error ());
|
handle_error (get_current_error ());
|
||||||
}
|
}
|
||||||
previous_filename = "";
|
previous_filename = "";
|
||||||
daemon.refresh_finished.disconnect (on_refresh_finished);
|
daemon.refresh_finished.disconnect (on_refresh_finished);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_cancel_button_clicked () {
|
void on_progress_dialog_close_button_clicked () {
|
||||||
|
finished (database_modified);
|
||||||
|
progress_dialog.hide ();
|
||||||
|
while (Gtk.events_pending ()) {
|
||||||
|
Gtk.main_iteration ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_progress_dialog_cancel_button_clicked () {
|
||||||
cancel ();
|
cancel ();
|
||||||
clear_lists ();
|
clear_lists ();
|
||||||
progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
||||||
@ -1200,32 +1221,25 @@ namespace Pamac {
|
|||||||
start_commit ();
|
start_commit ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
|
||||||
progress_dialog.hide ();
|
|
||||||
transaction_sum_dialog.hide ();
|
transaction_sum_dialog.hide ();
|
||||||
while (Gtk.events_pending ()) {
|
unowned string action = dgettext (null, "Transaction cancelled");
|
||||||
Gtk.main_iteration ();
|
progress_dialog.spawn_in_term ({"echo", action + ".\n"});
|
||||||
}
|
progress_dialog.action_label.set_text (action);
|
||||||
release ();
|
release ();
|
||||||
//to_build.remove_all ();
|
//to_build.remove_all ();
|
||||||
sysupgrade_after_trans = false;
|
sysupgrade_after_trans = false;
|
||||||
finished (false);
|
finish_transaction ();
|
||||||
}
|
}
|
||||||
} 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"});
|
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Nothing to do") + ".\n"});
|
||||||
progress_dialog.hide ();
|
|
||||||
while (Gtk.events_pending ()) {
|
|
||||||
Gtk.main_iteration ();
|
|
||||||
}
|
|
||||||
release ();
|
release ();
|
||||||
clear_lists ();
|
clear_lists ();
|
||||||
finished (false);
|
finish_transaction ();
|
||||||
//handle_error (err);
|
//handle_error (err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finished (false);
|
|
||||||
handle_error (get_current_error ());
|
handle_error (get_current_error ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1246,33 +1260,24 @@ namespace Pamac {
|
|||||||
sysupgrade_after_trans = false;
|
sysupgrade_after_trans = false;
|
||||||
sysupgrade (false);
|
sysupgrade (false);
|
||||||
} else {
|
} else {
|
||||||
refresh_handle ();
|
unowned string action = dgettext (null, "Transaction successfully finished");
|
||||||
finished (true);
|
progress_dialog.spawn_in_term ({"echo", action + ".\n"});
|
||||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
progress_dialog.action_label.set_text (action);
|
||||||
if (progress_dialog.expander.get_expanded ()) {
|
database_modified = true;
|
||||||
progress_dialog.action_label.set_text (dgettext (null, "Transaction successfully finished"));
|
finish_transaction ();
|
||||||
progress_dialog.cancel_button.set_visible (false);
|
|
||||||
progress_dialog.close_button.set_visible (true);
|
|
||||||
} else {
|
|
||||||
progress_dialog.hide ();
|
|
||||||
}
|
|
||||||
while (Gtk.events_pending ()) {
|
|
||||||
Gtk.main_iteration ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if it is an authentication error, database was not modified
|
// if it is an authentication error, database was not modified
|
||||||
var err = get_current_error ();
|
var err = get_current_error ();
|
||||||
if (err.message == dgettext (null, "Authentication failed")) {
|
if (err.message == dgettext (null, "Authentication failed")) {
|
||||||
finished (false);
|
handle_error (err);
|
||||||
} else {
|
} else {
|
||||||
clear_lists ();
|
clear_lists ();
|
||||||
refresh_handle ();
|
database_modified = true;
|
||||||
finished (true);
|
|
||||||
}
|
|
||||||
handle_error (err);
|
handle_error (err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
total_download = 0;
|
total_download = 0;
|
||||||
already_downloaded = 0;
|
already_downloaded = 0;
|
||||||
previous_filename = "";
|
previous_filename = "";
|
||||||
@ -1283,21 +1288,16 @@ namespace Pamac {
|
|||||||
clear_lists ();
|
clear_lists ();
|
||||||
// let the time to the daemon to update databases
|
// let the time to the daemon to update databases
|
||||||
Timeout.add (1000, () => {
|
Timeout.add (1000, () => {
|
||||||
refresh_handle ();
|
|
||||||
finished (true);
|
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
string action = dgettext (null, "Transaction successfully finished");
|
unowned string action = dgettext (null, "Transaction successfully finished");
|
||||||
progress_dialog.spawn_in_term ({"echo", action + ".\n"});
|
progress_dialog.spawn_in_term ({"echo", action + ".\n"});
|
||||||
progress_dialog.action_label.set_text (action);
|
progress_dialog.action_label.set_text (action);
|
||||||
} else {
|
} else {
|
||||||
progress_dialog.spawn_in_term ({"echo"});
|
progress_dialog.spawn_in_term ({"echo"});
|
||||||
}
|
}
|
||||||
progress_dialog.progressbar.set_fraction (1);
|
progress_dialog.progressbar.set_fraction (1);
|
||||||
progress_dialog.cancel_button.set_visible (false);
|
database_modified = true;
|
||||||
progress_dialog.close_button.set_visible (true);
|
finish_transaction ();
|
||||||
while (Gtk.events_pending ()) {
|
|
||||||
Gtk.main_iteration ();
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user