fix installer not being able to run while a pamac window is open
This commit is contained in:
@@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac-classic")
|
||||
set (RELEASE_NAME "pamac-classic")
|
||||
set (CMAKE_C_FLAGS "")
|
||||
set (PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
set (VERSION "6.6.1")
|
||||
set (VERSION "6.6.2")
|
||||
set (TESTSRCDIR "${CMAKE_SOURCE_DIR}")
|
||||
set (DOLLAR "$")
|
||||
|
||||
configure_file (${CMAKE_SOURCE_DIR}/src/pamac-install/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-install/Config.vala)
|
||||
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
|
||||
set (VERSION "6.6.1")
|
||||
set (VERSION "6.6.2")
|
||||
add_definitions (${DEPS_CFLAGS})
|
||||
include_directories ( ${CMAKE_BINARY_DIR}/src )
|
||||
link_libraries ( ${DEPS_LIBRARIES} -lpamacclassic )
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -4,7 +4,7 @@ cfg_pamac_install.set('PKGDATADIR', join_paths(get_option('prefix'),get_option('
|
||||
cfg_pamac_install.set('GETTEXT_PACKAGE', 'pamac-classic')
|
||||
cfg_pamac_install.set('RELEASE_NAME', 'pamac-classic')
|
||||
cfg_pamac_install.set('PREFIX', get_option('prefix'))
|
||||
cfg_pamac_install.set('VERSION', '6.6.1')
|
||||
cfg_pamac_install.set('VERSION', '6.6.2')
|
||||
cfg_pamac_install.set('TESTSRCDIR', meson.source_root())
|
||||
|
||||
cfgfile_5 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_install)
|
||||
|
||||
Reference in New Issue
Block a user