4 class IdentityManagerApp {
5 public IdentityManagerModel model;
6 private IdentityManagerView view;
7 private MoonshotServer ipc_server;
9 public OSXApplication osxApp;
10 public bool on_osx_open_files (string file_name ) {
11 print ("on_osx_open_files() file_name = %s\n", file_name);
12 return ipc_server.install_from_file(file_name);
15 private const int WINDOW_WIDTH = 400;
16 private const int WINDOW_HEIGHT = 500;
21 public IdentityManagerApp () {
22 model = new IdentityManagerModel(this);
23 view = new IdentityManagerView(this);
26 osxApp = OSXApplication.get_instance();
27 // This wont work with Vala 0.12
28 // osxApp.ns_application_open_file.connect(ipc_server.install_from_file);
29 // so we have to use this old way
30 Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(on_osx_open_files), ipc_server);
31 // Signal.connect_data(osxApp, "NSApplicationOpenFile", (GLib.Callback)(ipc_server.install_from_file), ipc_server, null, 0);
38 private void init_ipc_server ()
40 // Errors will currently be sent via g_log - ie. to an
41 // obtrusive message box, on Windows
43 this.ipc_server = MoonshotServer.get_instance ();
44 MoonshotServer.start (this.view);
47 private void init_ipc_server ()
51 var conn = DBus.Bus.get (DBus.BusType.SESSION);
52 dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
53 "/org/freedesktop/DBus",
54 "org.freedesktop.DBus");
56 // try to register service in session bus
57 uint reply = bus.request_name ("org.janet.Moonshot", (uint) 0);
58 assert (reply == DBus.RequestNameReply.PRIMARY_OWNER);
60 this.ipc_server = new MoonshotServer (this.view);
61 conn.register_object ("/org/janet/moonshot", ipc_server);
65 stderr.printf ("%s\n", e.message);
69 private void bus_acquired_cb (DBusConnection conn)
72 conn.register_object ("/org/janet/moonshot", ipc_server);
76 stderr.printf ("%s\n", e.message);
80 private void init_ipc_server ()
82 this.ipc_server = new MoonshotServer (this.view);
83 GLib.Bus.own_name (GLib.BusType.SESSION,
85 GLib.BusNameOwnerFlags.NONE,
89 error ("Couldn't own name %s on DBus.", name);
96 public static int main(string[] args){
100 // Force specific theme settings on Windows without requiring a gtkrc file
101 Gtk.Settings settings = Gtk.Settings.get_default ();
102 settings.set_string_property ("gtk-theme-name", "ms-windows", "moonshot");
103 settings.set_long_property ("gtk-menu-images", 0, "moonshot");
106 Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
107 Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
108 Intl.textdomain (Config.GETTEXT_PACKAGE);
111 var app = new IdentityManagerApp();