using Gtk; namespace Publicate { public class PpubViewerApplication : Adw.Application { public PpubViewerApplication() { Object(application_id: "nz.barrow.billy.publicate", flags: GLib.ApplicationFlags.HANDLES_OPEN); } protected override void activate () { // Absolutely janky fix for whatever is causing the keyboard shortcuts not to show up in menus var window = new ViewerWindow(this); window.destroy (); window = new ViewerWindow(this); add_window (window); window.present (); } protected override void open (File[] files, string hint) { foreach (var file in files) { var window = new ViewerWindow(this); window.present (); window.load_ppub.begin(file); } } } int main (string[] argv) { seed(); // Create a new application var app = new PpubViewerApplication(); return app.run (argv); } string get_publicate_path() { return Environment.get_home_dir () + "/.publicate"; } void seed() { if(!FileUtils.test (get_publicate_path(), FileTest.EXISTS)) { DirUtils.create (get_publicate_path (), 0600); } if(!FileUtils.test (get_publicate_path() + "/credentials", FileTest.EXISTS)) { DirUtils.create (get_publicate_path() + "/credentials", 0600); } if(!FileUtils.test (get_publicate_path() + "/collections", FileTest.EXISTS)) { DirUtils.create (get_publicate_path() + "/collections", 0600); } if(!FileUtils.test (get_publicate_path() + "/collections.config", FileTest.EXISTS)) { var template = "{\"collections\": []}"; FileUtils.set_contents (get_publicate_path() + "/collections.config", template, template.length); } } }