Fixed S598 [bug] 911172 - File Association
[moonshot-ui.git] / src / moonshot-identity-manager-app.vala
index a65dd60..9d22ad6 100644 (file)
@@ -1,20 +1,39 @@
 using Gtk;
 
-class IdentityManagerApp : Window {
+
+class IdentityManagerApp {
     public IdentityManagerModel model;
     private IdentityManagerView view;
     private MoonshotServer ipc_server;
+#if OS_MACOS
+       public OSXApplication osxApp;
+       public bool on_osx_open_files (string file_name ) {
+       print ("on_osx_open_files()  file_name = %s\n", file_name);
+               return ipc_server.install_from_file(file_name);
+       }
+#endif
     private const int WINDOW_WIDTH = 400;
     private const int WINDOW_HEIGHT = 500;
-
+    public void show() {
+        view.show();    
+    }
+       
     public IdentityManagerApp () {
         model = new IdentityManagerModel(this);
         view = new IdentityManagerView(this);
         init_ipc_server ();
+#if OS_MACOS
+               osxApp = OSXApplication.get_instance();
+// This wont work with Vala 0.12               
+//             osxApp.ns_application_open_file.connect(ipc_server.install_from_file);
+// so we have to use this old way
+               Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(on_osx_open_files), ipc_server);
+//             Signal.connect_data(osxApp, "NSApplicationOpenFile", (GLib.Callback)(ipc_server.install_from_file), ipc_server, null, 0);
+
+#endif
         view.show();
     }   
     
-
 #if IPC_MSRPC
     private void init_ipc_server ()
     {
@@ -27,6 +46,7 @@ class IdentityManagerApp : Window {
 #elif IPC_DBUS_GLIB
     private void init_ipc_server ()
     {
         try {
             var conn = DBus.Bus.get (DBus.BusType.SESSION);
             dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
@@ -75,6 +95,9 @@ class IdentityManagerApp : Window {
 
 public static int main(string[] args){
         Gtk.init(ref args);
+               stdout.printf("Hello\n");
+        foreach (string arg in args)
+                       stdout.printf("arg %s\n", arg);
 
 #if OS_WIN32
         // Force specific theme settings on Windows without requiring a gtkrc file
@@ -87,6 +110,7 @@ public static int main(string[] args){
         Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
         Intl.textdomain (Config.GETTEXT_PACKAGE);
        
+          
         var app = new IdentityManagerApp();
         
         app.show();