2005-03-12 18:54:53 +00:00
|
|
|
// Gnome.PanelAppletFactory.cs - PanelAppletFactory class impl
|
|
|
|
//
|
|
|
|
// Copyright (c) 2004-2005 Novell, Inc.
|
|
|
|
//
|
|
|
|
// This code is inserted after the automatically generated code.
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the Lesser GNU General
|
|
|
|
// Public License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-10-29 20:33:07 +00:00
|
|
|
using System;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2005-01-07 21:29:38 +00:00
|
|
|
namespace Gnome
|
2004-10-29 20:33:07 +00:00
|
|
|
{
|
2005-01-07 21:29:38 +00:00
|
|
|
public class PanelAppletFactory
|
2004-10-29 20:33:07 +00:00
|
|
|
{
|
2005-01-07 21:29:38 +00:00
|
|
|
private PanelAppletFactory () {}
|
2004-10-29 20:33:07 +00:00
|
|
|
|
|
|
|
private static string _IID;
|
|
|
|
private static string _factoryIID;
|
2005-01-07 21:29:38 +00:00
|
|
|
private static GnomeSharp.PanelAppletFactoryCallbackWrapper cb_wrapper;
|
2004-10-29 20:33:07 +00:00
|
|
|
|
|
|
|
public static void Register (Type applet_type)
|
|
|
|
{
|
|
|
|
PanelApplet applet = (PanelApplet) Activator.CreateInstance (applet_type, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, new object[] {IntPtr.Zero}, null);
|
|
|
|
|
2005-03-12 18:54:53 +00:00
|
|
|
cb_wrapper = new GnomeSharp.PanelAppletFactoryCallbackWrapper (new PanelAppletFactoryCallback (Creation));
|
2004-10-29 20:33:07 +00:00
|
|
|
_IID = applet.IID;
|
|
|
|
_factoryIID = applet.FactoryIID;
|
2005-03-08 21:28:08 +00:00
|
|
|
IntPtr native_iid = GLib.Marshaller.StringToPtrGStrdup (_factoryIID);
|
2005-05-04 16:54:24 +00:00
|
|
|
panel_applet_factory_main (native_iid, ((GLib.GType) applet_type).Val, cb_wrapper.NativeDelegate, IntPtr.Zero);
|
2005-03-08 21:28:08 +00:00
|
|
|
GLib.Marshaller.Free (native_iid);
|
2004-10-29 20:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static bool Creation (PanelApplet applet, string iid)
|
|
|
|
{
|
|
|
|
if (_IID != iid)
|
|
|
|
return false;
|
|
|
|
applet.Creation ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport("panel-applet-2")]
|
2005-03-08 21:28:08 +00:00
|
|
|
static extern int panel_applet_factory_main(IntPtr iid, IntPtr applet_type, GnomeSharp.PanelAppletFactoryCallbackNative cb, IntPtr data);
|
2004-10-29 20:33:07 +00:00
|
|
|
}
|
|
|
|
}
|