~mantas/pinta/stable

« back to all changes in this revision

Viewing changes to Pinta/IgeMacMenu.cs

  • Committer: Iain Lane
  • Date: 2010-03-13 18:20:18 UTC
  • mfrom: (1.1.2)
  • Revision ID: git-v1:1781694a68ecf232d0110c0b2f3d4a1b96c74ec2
Merge commit 'upstream/0.2'

Conflicts:
        debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// IgeMacMenu.cs
 
3
//  
 
4
// Author:
 
5
//       Eoin Hennessy <eoin@randomrules.org> 
 
6
//       jurgenobernolte
 
7
// 
 
8
// Copyright (c) 2010 Eoin Hennessy
 
9
// 
 
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:
 
16
// 
 
17
// The above copyright notice and this permission notice shall be included in
 
18
// all copies or substantial portions of the Software.
 
19
// 
 
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
 
26
// THE SOFTWARE.
 
27
//
 
28
// Ported by jurgenobernolte from:
 
29
// http://github.com/eoin/ige-mac-integration-sharp/tree/master/bindings/ige-mac-integration-sharp
 
30
 
 
31
using System;
 
32
using System.Runtime.InteropServices;
 
33
 
 
34
namespace Pinta
 
35
{
 
36
        public class IgeMacMenu
 
37
        {
 
38
                [DllImport ("libigemacintegration.dylib")]
 
39
                static extern void ige_mac_menu_connect_window_key_handler (IntPtr window);
 
40
 
 
41
                public static void ConnectWindowKeyHandler (Gtk.Window window)
 
42
                {
 
43
                        ige_mac_menu_connect_window_key_handler (window.Handle);
 
44
                }
 
45
 
 
46
                [DllImport ("libigemacintegration.dylib")]
 
47
                static extern void ige_mac_menu_set_global_key_handler_enabled (bool enabled);
 
48
 
 
49
                public static bool GlobalKeyHandlerEnabled {
 
50
                        set { ige_mac_menu_set_global_key_handler_enabled (value); }
 
51
                }
 
52
 
 
53
                [DllImport ("libigemacintegration.dylib")]
 
54
                static extern void ige_mac_menu_set_menu_bar (IntPtr menu_shell);
 
55
 
 
56
                public static Gtk.MenuShell MenuBar {
 
57
                        set { ige_mac_menu_set_menu_bar (value == null ? IntPtr.Zero : value.Handle); }
 
58
                }
 
59
 
 
60
                [DllImport ("libigemacintegration.dylib")]
 
61
                static extern void ige_mac_menu_set_quit_menu_item (IntPtr quit_item);
 
62
 
 
63
                public static Gtk.MenuItem QuitMenuItem {
 
64
                        set { ige_mac_menu_set_quit_menu_item (value == null ? IntPtr.Zero : value.Handle); }
 
65
                }
 
66
 
 
67
                [DllImport ("libigemacintegration.dylib")]
 
68
                static extern IntPtr ige_mac_menu_add_app_menu_group ();
 
69
 
 
70
                public static Pinta.IgeMacMenuGroup AddAppMenuGroup ()
 
71
                {
 
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);
 
74
                        return ret;
 
75
                }
 
76
        }
 
77
        
 
78
        public class IgeMacMenuGroup : GLib.Opaque
 
79
        {
 
80
                [DllImport ("libigemacintegration.dylib")]
 
81
                static extern void ige_mac_menu_add_app_menu_item (IntPtr raw, IntPtr menu_item, IntPtr label);
 
82
 
 
83
                public void AddMenuItem (Gtk.MenuItem menu_item, string label)
 
84
                {
 
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);
 
88
                }
 
89
 
 
90
                public IgeMacMenuGroup (IntPtr raw) : base(raw)
 
91
                {
 
92
                }
 
93
        }
 
94
}