4 class IdentityManagerApp {
5 public IdentityManagerModel model;
6 private IdentityManagerView view;
7 private MoonshotServer ipc_server;
9 public OSXApplication osxApp;
11 private const int WINDOW_WIDTH = 400;
12 private const int WINDOW_HEIGHT = 500;
17 public IdentityManagerApp () {
18 model = new IdentityManagerModel(this);
19 view = new IdentityManagerView(this);
22 osxApp = OSXApplication.get_instance();
23 // This wont work with Vala 0.12
24 // osxApp.ns_application_open_file.connect(ipc_server.install_from_file);
25 // so we have to use this old way
26 Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(ipc_server.install_from_file), null);
33 private void init_ipc_server ()
35 // Errors will currently be sent via g_log - ie. to an
36 // obtrusive message box, on Windows
38 this.ipc_server = MoonshotServer.get_instance ();
39 MoonshotServer.start (this.view);
42 private void init_ipc_server ()
46 var conn = DBus.Bus.get (DBus.BusType.SESSION);
47 dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
48 "/org/freedesktop/DBus",
49 "org.freedesktop.DBus");
51 // try to register service in session bus
52 uint reply = bus.request_name ("org.janet.Moonshot", (uint) 0);
53 assert (reply == DBus.RequestNameReply.PRIMARY_OWNER);
55 this.ipc_server = new MoonshotServer (this.view);
56 conn.register_object ("/org/janet/moonshot", ipc_server);
60 stderr.printf ("%s\n", e.message);
64 private void bus_acquired_cb (DBusConnection conn)
67 conn.register_object ("/org/janet/moonshot", ipc_server);
71 stderr.printf ("%s\n", e.message);
75 private void init_ipc_server ()
77 this.ipc_server = new MoonshotServer (this.view);
78 GLib.Bus.own_name (GLib.BusType.SESSION,
80 GLib.BusNameOwnerFlags.NONE,
84 error ("Couldn't own name %s on DBus.", name);
91 public static int main(string[] args){
93 stdout.printf("Hello\n");
94 foreach (string arg in args)
95 stdout.printf("arg %s\n", arg);
98 // Force specific theme settings on Windows without requiring a gtkrc file
99 Gtk.Settings settings = Gtk.Settings.get_default ();
100 settings.set_string_property ("gtk-theme-name", "ms-windows", "moonshot");
101 settings.set_long_property ("gtk-menu-images", 0, "moonshot");
104 Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
105 Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
106 Intl.textdomain (Config.GETTEXT_PACKAGE);
109 var app = new IdentityManagerApp();