Tooth/src/Application.vala

72 lines
2.1 KiB
Vala
Raw Normal View History

2018-04-14 12:09:06 +00:00
using Gtk;
using Granite;
namespace Tootle{
public static Application app;
2018-05-03 08:56:04 +00:00
public static MainWindow? window;
2018-05-08 16:09:38 +00:00
public static Window window_dummy;
2018-04-27 18:50:08 +00:00
2018-06-17 07:48:18 +00:00
public static Settings settings;
public static Accounts accounts;
public static Network network;
public static ImageCache image_cache;
2018-04-14 12:09:06 +00:00
public class Application : Granite.Application {
2018-05-05 15:38:01 +00:00
public abstract signal void refresh ();
public abstract signal void toast (string title);
public abstract signal void error (string title, string text);
2018-04-14 12:09:06 +00:00
construct {
application_id = "com.github.bleakgrey.tootle";
flags = ApplicationFlags.FLAGS_NONE;
2018-05-03 08:56:04 +00:00
program_name = "Tootle";
2018-06-19 10:06:31 +00:00
build_version = "0.1.4";
2018-04-14 12:09:06 +00:00
}
public static int main (string[] args) {
2018-05-03 08:56:04 +00:00
Gtk.init (ref args);
2018-04-14 12:09:06 +00:00
app = new Application ();
2018-05-31 12:13:21 +00:00
return app.run (args);
}
protected override void startup () {
base.startup ();
2018-05-08 16:09:38 +00:00
2018-06-17 07:48:18 +00:00
settings = new Settings ();
accounts = new Accounts ();
network = new Network ();
image_cache = new ImageCache ();
2018-05-27 16:25:16 +00:00
accounts.init ();
app.error.connect (app.on_error);
2018-05-08 16:09:38 +00:00
window_dummy = new Window ();
add_window (window_dummy);
2018-04-14 12:09:06 +00:00
}
protected override void activate () {
2018-05-31 12:13:21 +00:00
if (window != null)
return;
debug ("Creating new window");
if (accounts.is_empty ())
NewAccountDialog.open ();
2018-05-03 08:56:04 +00:00
else {
2018-05-31 12:13:21 +00:00
window = new MainWindow (this);
window.present ();
2018-05-03 08:56:04 +00:00
}
2018-04-14 12:09:06 +00:00
}
2018-05-27 16:25:16 +00:00
protected void on_error (string title, string msg){
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (title, msg, "dialog-warning");
message_dialog.transient_for = window;
message_dialog.run ();
message_dialog.destroy ();
}
2018-04-14 12:09:06 +00:00
}
}