2
// GtkOsxApplication.cs
5
// Timo Dörr <timo@latecrew.de>
7
// Copyright 2012 Timo Dörr
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using System.Runtime.InteropServices;
31
namespace OsxIntegration.GtkOsxApplication
34
/// Wraps the native GtkOsxApplicationBinding function to C# style API
36
public class GtkOsxApplication
38
// Main application handle
39
private IntPtr theApp;
41
public GtkOsxApplication ()
43
IntPtr osx_app = gtk_osxapplication_get_type ();
44
theApp = new GLib.GType (osx_app).Val;
48
// Takes the Gtk.MenuShell and sets it as OS X application menu
49
public void SetMenu (MenuShell shell)
51
gtk_osxapplication_set_menu_bar (theApp, shell.Handle);
54
// Places MenuItems into the OS X specific "Application" menu
55
// (the menu right next to the Apple-Menu)
56
// It's convention on OS X to put the about and the preferences
58
public void InsertIntoAppMenu (MenuItem item, int index)
60
gtk_osxapplication_insert_app_menu_item (theApp, item.Handle, index);
61
gtk_osxapplication_sync_menubar (theApp);
64
public void SetWindowMenu (MenuItem item)
66
gtk_osxapplication_set_window_menu (theApp, item.Handle);
67
gtk_osxapplication_sync_menubar (theApp);
71
gtk_osxapplication_ready (theApp);
74
// Bindings against native gtk-mac-integration/GtkOSXApplication
75
// which uses cocoa instead of deprecated carbon
76
// for documentation of these functions, see:
77
// http://gtk-osx.sourceforge.net/ige-mac-integration/GtkOSXApplication.html
79
[DllImport ("libgtkmacintegration.dylib")]
80
protected extern static IntPtr gtk_osxapplication_get_type ();
82
[DllImport ("libgtkmacintegration.dylib")]
83
protected extern static void gtk_osxapplication_ready (IntPtr app);
85
[DllImport ("libgtkmacintegration.dylib")]
86
protected extern static void gtk_osxapplication_set_menu_bar (IntPtr app, IntPtr menu_shell);
88
[DllImport ("libgtkmacintegration.dylib")]
89
protected extern static void gtk_osxapplication_insert_app_menu_item (IntPtr app, IntPtr menu_item, int index);
91
[DllImport ("libgtkmacintegration.dylib")]
92
protected extern static void gtk_osxapplication_sync_menubar (IntPtr app);
94
[DllImport ("libgtkmacintegration.dylib")]
95
protected extern static void gtk_osxapplication_set_dock_menu (IntPtr app, IntPtr menu_shell);
97
[DllImport ("libgtkmacintegration.dylib")]
98
protected extern static void gtk_osxapplication_set_window_menu (IntPtr app, IntPtr menu_item);
100
// TODO add more functions from GtkOsxApplication
b'\\ No newline at end of file'