~ubuntu-branches/ubuntu/quantal/banshee/quantal

« back to all changes in this revision

Viewing changes to src/Backends/Banshee.Osx/OsxIntegration.GtkOsxApplication/GtkOsxApplication.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2012-09-23 16:41:43 UTC
  • mfrom: (1.2.22) (6.3.25 experimental)
  • Revision ID: package-import@ubuntu.com-20120923164143-xuygdccvr2uqjdfj
Tags: 2.5.1-1ubuntu1
* [9615bd3e] Merge from Debian Experimental (LP: #1041245), remaining changes:
  - Enable and recommend SoundMenu and Disable NotificationArea by default
  - Disable boo and karma extensions
  - Move desktop file for Meego UI to /usr/share/une/applications
  - Change the url for the Amazon store redirector
  - [9b356d6] Add workaround for set_Height exception.
  - [ccbcbbd] Make Banshee translatable in Launchpad
* [77c7309] Drop Workaruond-for-set_Height-Exceptions.patch.
  Applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// GtkOsxApplication.cs
 
3
// 
 
4
// Author:
 
5
//   Timo Dörr <timo@latecrew.de>
 
6
// 
 
7
// Copyright 2012 Timo Dörr
 
8
// 
 
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:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
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
 
25
// THE SOFTWARE.
 
26
 
 
27
using System;
 
28
using System.Runtime.InteropServices;
 
29
using Gtk;
 
30
 
 
31
namespace OsxIntegration.GtkOsxApplication
 
32
{
 
33
    /// <summary>
 
34
    /// Wraps the native GtkOsxApplicationBinding function to C# style API
 
35
    /// </summary>
 
36
    public class GtkOsxApplication
 
37
    {
 
38
        // Main application handle
 
39
        private IntPtr theApp;
 
40
 
 
41
        public GtkOsxApplication ()
 
42
        {
 
43
            IntPtr osx_app = gtk_osxapplication_get_type ();
 
44
            theApp = new GLib.GType (osx_app).Val;
 
45
 
 
46
        }
 
47
 
 
48
        // Takes the Gtk.MenuShell and sets it as OS X application menu
 
49
        public void SetMenu (MenuShell shell)
 
50
        {
 
51
            gtk_osxapplication_set_menu_bar (theApp, shell.Handle);
 
52
        }
 
53
 
 
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
 
57
        // dialog in there
 
58
        public void InsertIntoAppMenu (MenuItem item, int index)
 
59
        {
 
60
            gtk_osxapplication_insert_app_menu_item (theApp, item.Handle, index);
 
61
            gtk_osxapplication_sync_menubar (theApp);
 
62
        }
 
63
 
 
64
        public void SetWindowMenu (MenuItem item)
 
65
        {
 
66
            gtk_osxapplication_set_window_menu (theApp, item.Handle);
 
67
            gtk_osxapplication_sync_menubar (theApp);
 
68
        }
 
69
        public void Ready ()
 
70
        {
 
71
            gtk_osxapplication_ready (theApp);
 
72
        }
 
73
 
 
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
 
78
 
 
79
        [DllImport ("libgtkmacintegration.dylib")]
 
80
        protected extern static IntPtr gtk_osxapplication_get_type ();
 
81
 
 
82
        [DllImport ("libgtkmacintegration.dylib")]
 
83
        protected extern static void gtk_osxapplication_ready (IntPtr app);
 
84
 
 
85
        [DllImport ("libgtkmacintegration.dylib")]
 
86
        protected extern static void gtk_osxapplication_set_menu_bar (IntPtr app, IntPtr menu_shell);
 
87
 
 
88
        [DllImport ("libgtkmacintegration.dylib")]
 
89
        protected extern static void gtk_osxapplication_insert_app_menu_item (IntPtr app, IntPtr menu_item, int index);
 
90
 
 
91
        [DllImport ("libgtkmacintegration.dylib")]
 
92
        protected extern static void gtk_osxapplication_sync_menubar (IntPtr app);
 
93
 
 
94
        [DllImport ("libgtkmacintegration.dylib")]
 
95
        protected extern static void gtk_osxapplication_set_dock_menu  (IntPtr app, IntPtr menu_shell);
 
96
 
 
97
        [DllImport ("libgtkmacintegration.dylib")]
 
98
        protected extern static void gtk_osxapplication_set_window_menu (IntPtr app, IntPtr menu_item);
 
99
 
 
100
        // TODO add more functions from GtkOsxApplication
 
101
 
 
102
    }
 
103
}
 
 
b'\\ No newline at end of file'