use actions instead of events for update buttons
This commit is contained in:
parent
78a8be9299
commit
1b720e4b5d
3 changed files with 55 additions and 77 deletions
|
@ -23,12 +23,6 @@ namespace Yggtk {
|
|||
[GtkChild]
|
||||
private Gtk.Switch status_switch;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button update_yggtk_button;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button update_yggdrasil_button;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.CheckButton portable_checkbutton;
|
||||
|
||||
|
@ -38,7 +32,9 @@ namespace Yggtk {
|
|||
[GtkChild]
|
||||
private Gtk.Entry ip_entry;
|
||||
|
||||
public AppWindow () {
|
||||
public AppWindow (Gtk.Application application) {
|
||||
|
||||
Object(application: application);
|
||||
|
||||
check_status (status_switch);
|
||||
|
||||
|
@ -90,14 +86,6 @@ namespace Yggtk {
|
|||
|
||||
});
|
||||
|
||||
update_yggdrasil_button.clicked.connect (() => {
|
||||
download ();
|
||||
});
|
||||
|
||||
update_yggtk_button.clicked.connect (() => {
|
||||
update ();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
int check_status (Switch status) {
|
||||
|
@ -185,66 +173,6 @@ namespace Yggtk {
|
|||
|
||||
}
|
||||
|
||||
int update () {
|
||||
|
||||
try {
|
||||
|
||||
unowned string repo_url = Environment.get_variable ("YGG_UPDATE_REPO");
|
||||
string temp_dir = Utils.mktempdir ();
|
||||
|
||||
if (repo_url == null) {
|
||||
repo_url = "https://git.macaw.me/plant_1312/Yggtk.git";
|
||||
}
|
||||
|
||||
Process.spawn_command_line_sync (@"git clone $repo_url $temp_dir");
|
||||
Process.spawn_command_line_sync (@"meson $temp_dir/build $temp_dir");
|
||||
Process.spawn_command_line_sync (@"ninja -C $temp_dir/build");
|
||||
Process.spawn_command_line_sync (@"cp $temp_dir/build/src/yggtk .");
|
||||
Process.spawn_command_line_sync (@"rm -rf $temp_dir");
|
||||
Process.spawn_command_line_sync ("./yggtk");
|
||||
|
||||
Gtk.main_quit ();
|
||||
|
||||
} catch (Error e) {
|
||||
|
||||
print ("Error update: %s\n", e.message);
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int download () {
|
||||
|
||||
try {
|
||||
|
||||
string pm;
|
||||
Process.spawn_command_line_sync ("pkexec pacman -S yggdrasil --noconfirm", out pm);
|
||||
|
||||
if (pm == "Cannot run program pacman: No such file or directory\n") {
|
||||
|
||||
Process.spawn_command_line_sync (
|
||||
"wget https://2375-115685026-gh.circle-artifacts.com/0/yggdrasil-0.3.12-amd64.deb"
|
||||
);
|
||||
Process.spawn_command_line_sync ("pkexec dpkg -i yggdrasil-0.3.12-amd64.deb");
|
||||
|
||||
}
|
||||
|
||||
} catch (Error e) {
|
||||
|
||||
print ("Error download: %s\n", e.message);
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int parse (string yggconf, Entry ip) {
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue