Add vapi for gtk-mac-integration. App now uses the Mac system menu :-)
authorPete Fotheringham <pete.fotheringham@codethink.co.uk>
Fri, 13 Jan 2012 14:10:06 +0000 (14:10 +0000)
committerPete Fotheringham <pete.fotheringham@codethink.co.uk>
Fri, 13 Jan 2012 14:10:06 +0000 (14:10 +0000)
Makefile.am
configure.ac
src/moonshot-identity-management-view.vala
src/moonshot-identity-manager-app.vala
vapi/gtk-mac-integration.vapi [new file with mode: 0644]

index 20df4f8..29ffcf0 100644 (file)
@@ -19,12 +19,13 @@ AM_CPPFLAGS = \
 
 AM_VALAFLAGS = \
         config.vapi \
+       --vapidir=$(top_srcdir)/vapi \
         --pkg gio-2.0
 
 
 libmoonshot_libmoonshot_la_CPPFLAGS = \
         $(libmoonshot_CFLAGS) \
-        $(AM_CPPFLAGS)
+        $(AM_CPPFLAGS) 
 
 libmoonshot_libmoonshot_la_SOURCES = libmoonshot/libmoonshot-common.c
 
@@ -53,8 +54,8 @@ src_moonshot_webp_SOURCES = \
         src/moonshot-id.vala
 
 src_moonshot_VALAFLAGS = --pkg gdk-2.0 --pkg gtk+-2.0 --pkg gee-1.0 $(AM_VALAFLAGS)
-src_moonshot_CPPFLAGS = $(moonshot_CFLAGS) $(AM_CPPFLAGS)
-src_moonshot_LDADD = $(moonshot_LIBS)
+src_moonshot_CPPFLAGS = $(moonshot_CFLAGS) $(AM_CPPFLAGS)  
+src_moonshot_LDADD = $(moonshot_LIBS) 
 
 src_moonshot_webp_VALAFLAGS = --vapidir=$(top_srcdir)/libmoonshot --pkg gdk-2.0 --pkg libmoonshot $(AM_VALAFLAGS)
 src_moonshot_webp_CPPFLAGS = $(moonshot_CFLAGS) $(AM_CPPFLAGS)
@@ -81,8 +82,9 @@ endif
 
 if  OS_MACOS
 
-AM_CPPFLAGS += -DOS_MACOS
-AM_VALAFLAGS += --define=OS_MACOS
+AM_CPPFLAGS += -DOS_MACOS $(MAC_CFLAGS)
+AM_VALAFLAGS += --define=OS_MACOS --pkg gtk-mac-integration
+moonshot_LIBS += $(MAC_LIBS)
 
 endif
 
index 7a433fe..91fc5d1 100644 (file)
@@ -53,6 +53,10 @@ case "$host" in
             [SERVER_IPC_MODULE="gio-2.0"],
             [SERVER_IPC_MODULE="dbus-glib-1"]
     )
+       
+       PKG_CHECK_MODULES([MAC], 
+                       [gtk-mac-integration >= 1.0.1]
+       )
 
 # TODO: Move to GTK+-3
 #            [gtk+-3.0 >= 2.0],
@@ -212,6 +216,7 @@ PKG_CHECK_MODULES(moonshot,[
         $GTK_VERSION
         gee-1.0 >= 0.5
         $SERVER_IPC_MODULE
+               $MAC
 ])
 
 PKG_CHECK_MODULES(libmoonshot,[
index 91a1330..6090fb8 100644 (file)
@@ -5,6 +5,9 @@ class IdentityManagerView : Window {
     private const int WINDOW_WIDTH = 400;
     private const int WINDOW_HEIGHT = 500;
     protected IdentityManagerApp parent_app;
+#if OS_MACOS
+       public OSXApplication osxApp;
+#endif
     private UIManager ui_manager = new UIManager();
     private Entry search_entry;
     private VBox vbox_right;
@@ -50,15 +53,21 @@ class IdentityManagerView : Window {
 
     public IdentityManagerView(IdentityManagerApp app) {
        parent_app = app;
-       identities_manager = parent_app.model;
+#if OS_MACOS
+               osxApp = OSXApplication.get_instance();
+#endif
+          identities_manager = parent_app.model;
        request_queue = new GLib.Queue<IdentityRequest>();
        service_button_map = new HashTable<Gtk.Button, string> (direct_hash, direct_equal);
        this.title = "Moonshoot";
        this.set_position (WindowPosition.CENTER);
        set_default_size (WINDOW_WIDTH, WINDOW_HEIGHT);
        build_ui();
-       setup_list_model();
+       setup_list_model(); 
         load_id_cards(); 
+#if OS_MACOS
+               osxApp = app.osxApp;
+#endif
        connect_signals();
     }
     
@@ -925,6 +934,10 @@ SUCH DAMAGE.
         var menubar = this.ui_manager.get_widget ("/MenuBar");
         main_vbox.pack_start (menubar, false, false, 0);
         main_vbox.pack_start (hbox, true, true, 0);
+#if OS_MACOS
+               var menushell = this.ui_manager.get_widget("/Menu") as Gtk.MenuShell;
+               osxApp.set_menu_bar(menushell);
+#endif
         add (main_vbox);
 
         main_vbox.show_all();
index 390e934..13b17a7 100644 (file)
@@ -1,9 +1,13 @@
 using Gtk;
 
+
 class IdentityManagerApp : Window {
     public IdentityManagerModel model;
     private IdentityManagerView view;
     private MoonshotServer ipc_server;
+#if OS_MACOS
+       public OSXApplication osxApp;
+#endif
     private const int WINDOW_WIDTH = 400;
     private const int WINDOW_HEIGHT = 500;
     public void show() {
@@ -13,6 +17,9 @@ class IdentityManagerApp : Window {
         model = new IdentityManagerModel(this);
         view = new IdentityManagerView(this);
         init_ipc_server ();
+#if OS_MACOS
+               osxApp = OSXApplication.get_instance();
+#endif
         view.show();
     }   
     
@@ -77,6 +84,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
@@ -89,6 +99,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();
diff --git a/vapi/gtk-mac-integration.vapi b/vapi/gtk-mac-integration.vapi
new file mode 100644 (file)
index 0000000..5323bb5
--- /dev/null
@@ -0,0 +1,17 @@
+[CCode(cheader_filename="gtkosxapplication.h")]
+public class Gtk.OSXApplication : GLib.Object {
+       [CCode(cname="GTK_TYPE_OSX_APPLICATION")]
+       public static GLib.Type GTK_TYPE_OSX_APPLICATION;
+
+       public static OSXApplication get_instance() {
+               return (Gtk.OSXApplication) GLib.Object.new(GTK_TYPE_OSX_APPLICATION);
+       }
+       [CCode(cname="gtk_osxapplication_set_menu_bar")]
+       public void set_menu_bar(Gtk.MenuShell shell);
+
+       [CCode(cname="gtk_osxapplication_ready")]
+       public void ready();
+
+       [CCode(cname="gtk_osxapplication_sync_menubar")]
+       public void sync_menu_bar();
+}