fix #1
This commit is contained in:
@@ -21,7 +21,8 @@ namespace Pamac {
|
||||
|
||||
public class Installer: Gtk.Application {
|
||||
Transaction transaction;
|
||||
Pamac.Config pamac_config;
|
||||
Pamac.Config pamac_config;
|
||||
bool pamac_run;
|
||||
|
||||
public Installer () {
|
||||
application_id = "org.manjaro.pamac.install";
|
||||
@@ -35,25 +36,63 @@ namespace Pamac {
|
||||
|
||||
base.startup ();
|
||||
|
||||
pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
transaction = new Pamac.Transaction (null, pamac_config);
|
||||
transaction.finished.connect (on_emit_trans_finished);
|
||||
|
||||
this.hold ();
|
||||
pamac_run = check_pamac_running ();
|
||||
if (pamac_run) {
|
||||
var transaction_info_dialog = new TransactionInfoDialog (null);
|
||||
transaction_info_dialog.set_title (dgettext (null, "Error"));
|
||||
transaction_info_dialog.label.set_visible (true);
|
||||
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running"));
|
||||
transaction_info_dialog.expander.set_visible (false);
|
||||
transaction_info_dialog.run ();
|
||||
transaction_info_dialog.hide ();
|
||||
} else {
|
||||
pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
transaction = new Pamac.Transaction (null, pamac_config);
|
||||
transaction.finished.connect (on_emit_trans_finished);
|
||||
this.hold ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void activate () {
|
||||
print ("\nError: Path(s) of tarball(s) to install is needed\n");
|
||||
transaction.stop_daemon ();
|
||||
this.release ();
|
||||
if (pamac_run == false) {
|
||||
print ("\nError: Path(s) of tarball(s) to install is needed\n");
|
||||
transaction.stop_daemon ();
|
||||
this.release ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void open (File[] files, string hint) {
|
||||
foreach (File file in files) {
|
||||
string? path = file.get_path ();
|
||||
transaction.to_load.insert (path, path);
|
||||
if (pamac_run == false) {
|
||||
foreach (File file in files) {
|
||||
string? path = file.get_path ();
|
||||
transaction.to_load.insert (path, path);
|
||||
}
|
||||
transaction.run ();
|
||||
}
|
||||
}
|
||||
|
||||
bool check_pamac_running () {
|
||||
Application app;
|
||||
bool run = false;
|
||||
app = new Application ("org.manjaro.pamac.manager", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
if (run)
|
||||
return run;
|
||||
else {
|
||||
app = new Application ("org.manjaro.pamac.updater", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
return run;
|
||||
}
|
||||
transaction.run ();
|
||||
}
|
||||
|
||||
public void on_emit_trans_finished (bool error) {
|
||||
|
@@ -20,8 +20,8 @@
|
||||
namespace Pamac {
|
||||
|
||||
public class Manager : Gtk.Application {
|
||||
|
||||
ManagerWindow manager_window;
|
||||
bool pamac_run;
|
||||
|
||||
public Manager () {
|
||||
application_id = "org.manjaro.pamac.manager";
|
||||
@@ -35,16 +35,52 @@ namespace Pamac {
|
||||
|
||||
base.startup ();
|
||||
|
||||
manager_window = new ManagerWindow (this);
|
||||
pamac_run = check_pamac_running ();
|
||||
if (pamac_run) {
|
||||
var transaction_info_dialog = new TransactionInfoDialog (null);
|
||||
transaction_info_dialog.set_title (dgettext (null, "Error"));
|
||||
transaction_info_dialog.label.set_visible (true);
|
||||
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running"));
|
||||
transaction_info_dialog.expander.set_visible (false);
|
||||
transaction_info_dialog.run ();
|
||||
transaction_info_dialog.hide ();
|
||||
} else
|
||||
manager_window = new ManagerWindow (this);
|
||||
}
|
||||
|
||||
public override void activate () {
|
||||
manager_window.present ();
|
||||
if (pamac_run == false)
|
||||
manager_window.present ();
|
||||
}
|
||||
|
||||
public override void shutdown () {
|
||||
base.shutdown ();
|
||||
manager_window.transaction.stop_daemon ();
|
||||
if (pamac_run == false)
|
||||
manager_window.transaction.stop_daemon ();
|
||||
}
|
||||
|
||||
bool check_pamac_running () {
|
||||
Application app;
|
||||
bool run = false;
|
||||
app = new Application ("org.manjaro.pamac.updater", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
if (run)
|
||||
return run;
|
||||
else {
|
||||
app = new Application ("org.manjaro.pamac.install", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
return run;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,8 +20,8 @@
|
||||
namespace Pamac {
|
||||
|
||||
public class Updater : Gtk.Application {
|
||||
|
||||
UpdaterWindow updater_window;
|
||||
bool pamac_run;
|
||||
|
||||
public Updater () {
|
||||
application_id = "org.manjaro.pamac.updater";
|
||||
@@ -35,16 +35,52 @@ namespace Pamac {
|
||||
|
||||
base.startup ();
|
||||
|
||||
updater_window = new UpdaterWindow (this);
|
||||
pamac_run = check_pamac_running ();
|
||||
if (pamac_run) {
|
||||
var transaction_info_dialog = new TransactionInfoDialog (null);
|
||||
transaction_info_dialog.set_title (dgettext (null, "Error"));
|
||||
transaction_info_dialog.label.set_visible (true);
|
||||
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running"));
|
||||
transaction_info_dialog.expander.set_visible (false);
|
||||
transaction_info_dialog.run ();
|
||||
transaction_info_dialog.hide ();
|
||||
} else
|
||||
updater_window = new UpdaterWindow (this);
|
||||
}
|
||||
|
||||
public override void activate () {
|
||||
updater_window.present ();
|
||||
if (pamac_run == false)
|
||||
updater_window.present ();
|
||||
}
|
||||
|
||||
public override void shutdown () {
|
||||
base.shutdown ();
|
||||
updater_window.transaction.stop_daemon ();
|
||||
if (pamac_run == false)
|
||||
updater_window.transaction.stop_daemon ();
|
||||
}
|
||||
|
||||
bool check_pamac_running () {
|
||||
Application app;
|
||||
bool run = false;
|
||||
app = new Application ("org.manjaro.pamac.manager", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
if (run)
|
||||
return run;
|
||||
else {
|
||||
app = new Application ("org.manjaro.pamac.install", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
return run;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user