deskcandy/src/application.vala

60 lines
1.6 KiB
Vala

using Deskcandy.Candy;
namespace Deskcandy {
public class Application : Gtk.Application {
public signal void initialized(BaseCandy candy);
private Gtk.Window window;
private Gtk.Window desktop_window;
public BaseCandy candy { get; private set; }
public bool enabled { get; set; }
public Application() {
Object(application_id: "moe.solarpunk.Deskcandy");
var toggle_enabled = new PropertyAction("toggle-enabled", this, "enabled");
toggle_enabled.notify.connect(this.on_toggle_enabled);
this.add_action(toggle_enabled);
this.set_up_actions();
this.candy = new XScreensaver();
}
private async void initialize_async() {
yield this.candy.initialize();
initialized(this.candy);
}
private void on_toggle_enabled() {
}
private void set_up_actions() {
var a_about = new SimpleAction("about", null);
a_about.activate.connect((widget) => {
var about_dialog = new Gtk.AboutDialog();
about_dialog.destroy_with_parent = true;
about_dialog.transient_for = this.window;
about_dialog.modal = true;
});
this.add_action(a_about);
var a_quit = new SimpleAction("quit", null);
a_quit.activate.connect(this.quit);
this.add_action(a_quit);
}
public override void activate() {
this.window = this.active_window;
if (this.window == null) {
this.window = new Window(this);
}
this.desktop_window = new DesktopWindow(this);
this.window.present();
this.initialize_async.begin();
}
}
}