4 class IdentityManagerApp {
5 public IdentityManagerModel model;
6 private IdentityManagerView view;
7 private MoonshotServer ipc_server;
10 public OSXApplication osxApp;
12 // the signal handler function.
13 // the current instance of our app class is passed in the
14 // id_manager_app_instanceparameter
15 public static bool on_osx_open_files (OSXApplication osx_app_instance,
17 IdentityManagerApp id_manager_app_instance ) {
18 int added_cards = id_manager_app_instance.ipc_server.install_from_file(file_name);
23 private const int WINDOW_WIDTH = 400;
24 private const int WINDOW_HEIGHT = 500;
29 public IdentityManagerApp () {
30 model = new IdentityManagerModel(this);
31 view = new IdentityManagerView(this);
36 osxApp = OSXApplication.get_instance();
37 // The 'correct' way of connrcting wont work in Mac OS with Vala 0.12 e.g.
38 // osxApp.ns_application_open_file.connect(install_from_file);
39 // so we have to use this old way
40 Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(on_osx_open_files), this);
47 private void init_ipc_server ()
49 // Errors will currently be sent via g_log - ie. to an
50 // obtrusive message box, on Windows
52 this.ipc_server = MoonshotServer.get_instance ();
53 MoonshotServer.start (this.view);
56 private void init_ipc_server ()
60 var conn = DBus.Bus.get (DBus.BusType.SESSION);
61 dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
62 "/org/freedesktop/DBus",
63 "org.freedesktop.DBus");
65 // try to register service in session bus
66 uint reply = bus.request_name ("org.janet.Moonshot", (uint) 0);
67 assert (reply == DBus.RequestNameReply.PRIMARY_OWNER);
69 this.ipc_server = new MoonshotServer (this.view);
70 conn.register_object ("/org/janet/moonshot", ipc_server);
74 stderr.printf ("%s\n", e.message);
78 private void bus_acquired_cb (DBusConnection conn)
81 conn.register_object ("/org/janet/moonshot", ipc_server);
85 stderr.printf ("%s\n", e.message);
89 private void init_ipc_server ()
91 this.ipc_server = new MoonshotServer (this.view);
92 GLib.Bus.own_name (GLib.BusType.SESSION,
94 GLib.BusNameOwnerFlags.NONE,
98 error ("Couldn't own name %s on DBus.", name);
105 public static int main(string[] args){
109 // Force specific theme settings on Windows without requiring a gtkrc file
110 Gtk.Settings settings = Gtk.Settings.get_default ();
111 settings.set_string_property ("gtk-theme-name", "ms-windows", "moonshot");
112 settings.set_long_property ("gtk-menu-images", 0, "moonshot");
115 Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
116 Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
117 Intl.textdomain (Config.GETTEXT_PACKAGE);
120 var app = new IdentityManagerApp();