5
// Eoin Hennessy <eoin@randomrules.org>
8
// Copyright (c) 2010 Eoin Hennessy
10
// Permission is hereby granted, free of charge, to any person obtaining a copy
11
// of this software and associated documentation files (the "Software"), to deal
12
// in the Software without restriction, including without limitation the rights
13
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
// copies of the Software, and to permit persons to whom the Software is
15
// furnished to do so, subject to the following conditions:
17
// The above copyright notice and this permission notice shall be included in
18
// all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
// Ported by jurgenobernolte from:
29
// http://github.com/eoin/ige-mac-integration-sharp/tree/master/bindings/ige-mac-integration-sharp
32
using System.Runtime.InteropServices;
36
public class IgeMacMenu
38
[DllImport ("libigemacintegration.dylib")]
39
static extern void ige_mac_menu_connect_window_key_handler (IntPtr window);
41
public static void ConnectWindowKeyHandler (Gtk.Window window)
43
ige_mac_menu_connect_window_key_handler (window.Handle);
46
[DllImport ("libigemacintegration.dylib")]
47
static extern void ige_mac_menu_set_global_key_handler_enabled (bool enabled);
49
public static bool GlobalKeyHandlerEnabled {
50
set { ige_mac_menu_set_global_key_handler_enabled (value); }
53
[DllImport ("libigemacintegration.dylib")]
54
static extern void ige_mac_menu_set_menu_bar (IntPtr menu_shell);
56
public static Gtk.MenuShell MenuBar {
57
set { ige_mac_menu_set_menu_bar (value == null ? IntPtr.Zero : value.Handle); }
60
[DllImport ("libigemacintegration.dylib")]
61
static extern void ige_mac_menu_set_quit_menu_item (IntPtr quit_item);
63
public static Gtk.MenuItem QuitMenuItem {
64
set { ige_mac_menu_set_quit_menu_item (value == null ? IntPtr.Zero : value.Handle); }
67
[DllImport ("libigemacintegration.dylib")]
68
static extern IntPtr ige_mac_menu_add_app_menu_group ();
70
public static Pinta.IgeMacMenuGroup AddAppMenuGroup ()
72
IntPtr raw_ret = ige_mac_menu_add_app_menu_group ();
73
Pinta.IgeMacMenuGroup ret = raw_ret == IntPtr.Zero ? null : (Pinta.IgeMacMenuGroup)GLib.Opaque.GetOpaque (raw_ret, typeof(Pinta.IgeMacMenuGroup), false);
78
public class IgeMacMenuGroup : GLib.Opaque
80
[DllImport ("libigemacintegration.dylib")]
81
static extern void ige_mac_menu_add_app_menu_item (IntPtr raw, IntPtr menu_item, IntPtr label);
83
public void AddMenuItem (Gtk.MenuItem menu_item, string label)
85
IntPtr native_label = GLib.Marshaller.StringToPtrGStrdup (label);
86
ige_mac_menu_add_app_menu_item (Handle, menu_item == null ? IntPtr.Zero : menu_item.Handle, native_label);
87
GLib.Marshaller.Free (native_label);
90
public IgeMacMenuGroup (IntPtr raw) : base(raw)