using Adw;
using Gtk;

public class KordophoneApp : Adw.Application
{
    private MainWindow window;

    public KordophoneApp () {
        Object (application_id: "net.buzzert.kordophone2", flags: ApplicationFlags.FLAGS_NONE);
    }
    
    protected override void startup () {
        base.startup ();
        
        // Set default icon theme
        Gtk.Settings.get_default().set_property("gtk-icon-theme-name", "Adwaita");
        
        // Load CSS from resources
        var provider = new Gtk.CssProvider ();
        provider.load_from_resource ("/net/buzzert/kordophone2/style.css");
        Gtk.StyleContext.add_provider_for_display (
            Gdk.Display.get_default (),
            provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        );

        // Setup application actions
        var quit_action = new SimpleAction("quit", null);
        quit_action.activate.connect(() => {
            this.quit();
        });
        add_action(quit_action);

        // Warm up dbus connections
        Repository.get_instance();
    }
    
    protected override void activate () {
        window = new MainWindow ();
        window.set_default_size (1200, 1000);
        window.application = this;

        window.present ();
    }
    
    public static int main (string[] args) {
        var app = new KordophoneApp ();
        return app.run (args);
    }
}