00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef _LIBPANELAPPLETMM_FACTORY_H
00020
#define _LIBPANELAPPLETMM_FACTORY_H
00021
00022
#include <glibmm.h>
00023
#include <libpanelappletmm/applet.h>
00024
00025
namespace Gnome
00026 {
00027
00028
namespace Panel
00029 {
00030
00031 typedef sigc::slot<bool, PanelApplet*, const Glib::ustring&>
SlotFactory;
00032
00033
namespace
00034
{
00035
00036
00037
00038 class SignalProxy_Factory
00039 {
00040
public:
00041 typedef Gnome::Panel::SlotFactory SlotType;
00042
00043
SignalProxy_Factory(
const SlotType& slot);
00044
~SignalProxy_Factory();
00045
00046
static gboolean
c_callback(PanelApplet* applet,
const gchar* iid,
void* data);
00047
00048 SlotType slot_;
00049 };
00050
00051 SignalProxy_Factory::SignalProxy_Factory(
const SlotType& slot) : slot_(slot)
00052 {
00053 }
00054
00055 SignalProxy_Factory::~SignalProxy_Factory()
00056 {}
00057
00058 gboolean SignalProxy_Factory::c_callback(PanelApplet* applet,
const gchar* iid,
void* data)
00059 {
00060
SignalProxy_Factory *
const self = (
SignalProxy_Factory*)(data);
00061
00062
const Glib::ustring sp_iid = Glib::convert_const_gchar_ptr_to_ustring(iid);
00063
00064
00065
00066
return (
self->slot_)(applet, sp_iid);
00067 }
00068
00069
template<
class DerivedApplet>
00070 bool applet_factory_callback(PanelApplet* panel_applet,
const Glib::ustring& iid)
00071 {
00072
00073
00074 DerivedApplet* applet =
Gtk::manage(
new DerivedApplet(panel_applet));
00075
00076 applet->show();
00077
00078
return true;
00079 }
00080
00081 }
00082
00083
template<
class DerivedApplet>
00084
int factory_main(
const Glib::ustring& iid);
00085
00086
template<
class DerivedApplet>
00087 Bonobo_Unknown
shlib_factory(
const Glib::ustring& iid, PortableServer_POA poa,
void* impl_ptr,
const SlotFactory& slot, CORBA_Environment* ev);
00088
00089
int factory_main_closure(
const Glib::ustring& iid, GClosure *closure);
00090
00091 Bonobo_Unknown
shlib_factory_closure(
const Glib::ustring& iid, PortableServer_POA poa,
void* impl_ptr, GClosure* closure, CORBA_Environment* ev);
00092
00093
00094
template<
class DerivedApplet>
00095 int factory_main(
const Glib::ustring& iid)
00096 {
00097
SignalProxy_Factory proxy( sigc::ptr_fun(&applet_factory_callback<DerivedApplet>) );
00098
00099
return panel_applet_factory_main( iid.
c_str(), Applet::get_type(), SignalProxy_Factory::c_callback, &proxy);
00100 }
00101
00102
template<
class DerivedApplet>
00103 Bonobo_Unknown
shlib_factory(
const Glib::ustring& iid, PortableServer_POA poa,
void* impl_ptr,
const SlotFactory& slot, CORBA_Environment* ev)
00104 {
00105
SignalProxy_Factory proxy( sigc::ptr_fun(&applet_factory_callback<DerivedApplet>) );
00106
00107
return panel_applet_shlib_factory( iid.
c_str(), Applet::get_type(), poa, impl_ptr, SignalProxy_Factory::c_callback, &proxy, ev);
00108 }
00109
00110 }
00111 }
00112
00113
#endif