forked from cromer/pamac-classic
fix installer not being able to run while a pamac window is open
This commit is contained in:
@@ -23,7 +23,6 @@ namespace Pamac {
|
||||
public class Installer: Gtk.Application {
|
||||
Transaction transaction;
|
||||
ProgressDialog progress_dialog;
|
||||
bool pamac_run;
|
||||
bool important_details;
|
||||
|
||||
public Installer () {
|
||||
@@ -38,75 +37,41 @@ namespace Pamac {
|
||||
|
||||
base.startup ();
|
||||
|
||||
pamac_run = check_pamac_running ();
|
||||
if (pamac_run) {
|
||||
var msg = new Gtk.MessageDialog (null,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.OK,
|
||||
dgettext (null, "Pamac is already running"));
|
||||
msg.run ();
|
||||
msg.destroy ();
|
||||
} else {
|
||||
important_details = false;
|
||||
// integrate progress box and term widget
|
||||
progress_dialog = new ProgressDialog ();
|
||||
transaction = new Transaction (progress_dialog as Gtk.ApplicationWindow);
|
||||
transaction.mode = Transaction.Mode.INSTALLER;
|
||||
transaction.finished.connect (on_transaction_finished);
|
||||
transaction.important_details_outpout.connect (on_important_details_outpout);
|
||||
progress_dialog.box.pack_start (transaction.progress_box);
|
||||
progress_dialog.box.reorder_child (transaction.progress_box, 0);
|
||||
transaction.term_window.height_request = 200;
|
||||
progress_dialog.expander.add (transaction.term_window);
|
||||
progress_dialog.close_button.clicked.connect (on_close_button_clicked);
|
||||
progress_dialog.close_button.visible = false;
|
||||
this.hold ();
|
||||
}
|
||||
important_details = false;
|
||||
// integrate progress box and term widget
|
||||
progress_dialog = new ProgressDialog ();
|
||||
transaction = new Transaction (progress_dialog as Gtk.ApplicationWindow);
|
||||
transaction.mode = Transaction.Mode.INSTALLER;
|
||||
transaction.finished.connect (on_transaction_finished);
|
||||
transaction.important_details_outpout.connect (on_important_details_outpout);
|
||||
progress_dialog.box.pack_start (transaction.progress_box);
|
||||
progress_dialog.box.reorder_child (transaction.progress_box, 0);
|
||||
transaction.term_window.height_request = 200;
|
||||
progress_dialog.expander.add (transaction.term_window);
|
||||
progress_dialog.close_button.clicked.connect (on_close_button_clicked);
|
||||
progress_dialog.close_button.visible = false;
|
||||
this.hold ();
|
||||
}
|
||||
|
||||
public override void activate () {
|
||||
if (!pamac_run) {
|
||||
print ("\nError: Path(s) of tarball(s) to install is needed\n");
|
||||
transaction.stop_daemon ();
|
||||
this.release ();
|
||||
}
|
||||
this.release ();
|
||||
}
|
||||
|
||||
public override void open (File[] files, string hint) {
|
||||
if (!pamac_run) {
|
||||
foreach (unowned File file in files) {
|
||||
transaction.to_load.add (file.get_path ());
|
||||
}
|
||||
progress_dialog.show ();
|
||||
if (transaction.get_lock ()) {
|
||||
transaction.run ();
|
||||
} else {
|
||||
transaction.progress_box.action_label.label = dgettext (null, "Waiting for another package manager to quit") + "...";
|
||||
transaction.start_progressbar_pulse ();
|
||||
Timeout.add (5000, () => {
|
||||
bool locked = transaction.get_lock ();
|
||||
if (locked) {
|
||||
transaction.stop_progressbar_pulse ();
|
||||
transaction.run ();
|
||||
}
|
||||
return !locked;
|
||||
});
|
||||
}
|
||||
foreach (unowned File file in files) {
|
||||
transaction.to_load.add (file.get_path ());
|
||||
}
|
||||
}
|
||||
|
||||
bool check_pamac_running () {
|
||||
Application app;
|
||||
bool run = false;
|
||||
app = new Application ("org.pamac.manager", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
progress_dialog.show ();
|
||||
if (transaction.get_lock ()) {
|
||||
transaction.run ();
|
||||
} else {
|
||||
Gtk.MessageDialog msg = new Gtk.MessageDialog (this as Gtk.ApplicationWindow, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, dgettext (null, "Unable to lock database!"));
|
||||
msg.response.connect ((response_id) => {
|
||||
msg.destroy();
|
||||
this.release ();
|
||||
});
|
||||
msg.show ();
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
return run;
|
||||
}
|
||||
|
||||
void on_important_details_outpout (bool must_show) {
|
||||
|
Reference in New Issue
Block a user