69 lines
1.8 KiB
Vala
69 lines
1.8 KiB
Vala
using Deskcandy.Candy;
|
|
|
|
namespace Deskcandy {
|
|
public class Application : Gtk.Application {
|
|
public signal void initialized(BaseCandy[] candies);
|
|
|
|
private Gtk.Window window;
|
|
private Gtk.Window desktop_window;
|
|
private BaseCandy[] _candies;
|
|
|
|
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._candies = { new XScreensaver(), new Video() };
|
|
}
|
|
|
|
private async void initialize_async() {
|
|
foreach (var candy in this._candies) {
|
|
try {
|
|
yield candy.initialize();
|
|
} catch (Error e) {
|
|
error(@"Failed to load candy: $(e.message)");
|
|
}
|
|
}
|
|
|
|
initialized(this._candies);
|
|
}
|
|
|
|
private void on_toggle_enabled() {
|
|
}
|
|
|
|
private void set_up_actions() {
|
|
var a_about = new SimpleAction("about", null);
|
|
a_about.activate.connect((widget) => {
|
|
message("about...");
|
|
var about_dialog = new Gtk.AboutDialog();
|
|
about_dialog.destroy_with_parent = true;
|
|
about_dialog.transient_for = this.window;
|
|
about_dialog.modal = true;
|
|
about_dialog.present();
|
|
});
|
|
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();
|
|
}
|
|
}
|
|
}
|