~ubuntu-branches/ubuntu/lucid/gnome-desktop-sharp2/lucid

« back to all changes in this revision

Viewing changes to gnomepanel/PanelAppletFactory.cs

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2009-01-20 12:30:23 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20090120123023-qu6l14pud2vrysmu
Tags: 2.24.0-1ubuntu1
* Sync with Debian (LP: #317344)
* Add Build-dep on libgnomeprintui2.2-dev
* Install the upstream changelog in the gnome-desktop-sharp2
  package only
* debian/patches/02_gnomedesktop_dllmap
  + Actually map the new libgnome-desktop-2-11 lib.  Fixes
    the dependency generation and library use.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Gnome.PanelAppletFactory.cs - PanelAppletFactory class impl
 
2
//
 
3
// Copyright (c) 2004-2005 Novell, Inc.
 
4
//
 
5
// This code is inserted after the automatically generated code.
 
6
//
 
7
// This program is free software; you can redistribute it and/or
 
8
// modify it under the terms of version 2 of the Lesser GNU General 
 
9
// Public License as published by the Free Software Foundation.
 
10
//
 
11
// This program is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
// Lesser General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU Lesser General Public
 
17
// License along with this program; if not, write to the
 
18
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
// Boston, MA 02111-1307, USA.
 
20
 
 
21
 
 
22
 
 
23
using System;
 
24
using System.Reflection;
 
25
using System.Runtime.InteropServices;
 
26
 
 
27
namespace Gnome
 
28
{
 
29
        public class PanelAppletFactory
 
30
        {
 
31
                private PanelAppletFactory () {}
 
32
 
 
33
                private static string _IID;
 
34
                private static string _factoryIID;
 
35
                private static GnomeSharp.PanelAppletFactoryCallbackWrapper cb_wrapper;
 
36
 
 
37
                public static void Register (Type applet_type)
 
38
                {
 
39
                        PanelApplet applet = (PanelApplet) Activator.CreateInstance (applet_type, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, new object[] {IntPtr.Zero}, null);
 
40
 
 
41
                        cb_wrapper = new GnomeSharp.PanelAppletFactoryCallbackWrapper (new PanelAppletFactoryCallback (Creation));
 
42
                        _IID = applet.IID;
 
43
                        _factoryIID = applet.FactoryIID;
 
44
                        IntPtr native_iid = GLib.Marshaller.StringToPtrGStrdup (_factoryIID);
 
45
                        panel_applet_factory_main (native_iid, ((GLib.GType) applet_type).Val, cb_wrapper.NativeDelegate, IntPtr.Zero);
 
46
                        GLib.Marshaller.Free (native_iid);
 
47
                }
 
48
 
 
49
                private static bool Creation (PanelApplet applet, string iid)
 
50
                {
 
51
                        if (_IID != iid)
 
52
                                return false;
 
53
                        applet.Creation ();
 
54
                        return true;
 
55
                }
 
56
 
 
57
                [DllImport("panel-applet-2")]
 
58
                static extern int panel_applet_factory_main(IntPtr iid, IntPtr applet_type, GnomeSharp.PanelAppletFactoryCallbackNative cb, IntPtr data);
 
59
        }
 
60
}