plugins.h

00001 #ifndef _PLUGINS_H
00002 #define _PLUGINS_H
00003 
00004 template<class UType> extern Glib::ObjectBase* UObj_Wrap_New(GObject* o)
00005 {
00006     return manage(new UType(( typename UType::GtkmmBaseType::BaseObjectType* )(o)));
00007 }
00008 
00009 template<class Type>
00010 extern Type* uwrap(GObject* object, bool take_copy=false)
00011 {
00012   return dynamic_cast<Type*> (Glib::wrap_auto((GObject*)(object), take_copy));
00013 }
00014 
00015 template<class UType> extern GType UObj_Get_Type()
00016 {
00017 static GType gtype = 0;
00018     if (!gtype) {
00019         UType* dummy = new UType();
00020         gtype = G_OBJECT_TYPE(dummy->gobj());
00021         delete( dummy );
00022         Glib::wrap_register(gtype, &UObj_Wrap_New<UType>);
00023     }
00024     return gtype;
00025 }
00026 
00027 template<class Type> extern Glib::ObjectBase* Obj_Wrap_New(GObject* o)
00028 {
00029     return manage(new Type(( typename Type::BaseObjectType* )(o)));
00030 }
00031 
00032 template<class Type> extern GType Obj_Get_Type()
00033 {
00034 static GType gtype = 0;
00035     if (!gtype) {
00036         Type* dummy = new Type();
00037         gtype = G_OBJECT_TYPE(dummy->gobj());
00038         delete( dummy );
00039         Glib::wrap_register(gtype, &Obj_Wrap_New<Type>);
00040     }
00041     return gtype;
00042 }
00043 /* Функция, которая меняет порядок инициализации, вызывая Wrap_New перед выставлением свойств виджета. Без этого свойства виджета,
00044    определенные в классе, не выставляются значениями из glade файла.
00045 */
00046 template<class Type> static void custom_set_property_callback(GObject * object, unsigned int property_id, const GValue * value, GParamSpec * param_spec)
00047 {
00048 
00049     if( !Glib::ObjectBase::_get_current_wrapper(object) )
00050         UObj_Wrap_New<Type>(object);
00051         Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object);
00052         if (!wrapper)
00053                 return;
00054         Type *renderer = dynamic_cast<Type *>(wrapper);
00055         if (!renderer)
00056                 return;
00057     Glib::custom_set_property_callback(object,property_id,value,param_spec);
00058 }
00059 
00060 template<class Type> static void custom_set_property_callback_object(GObject * object, unsigned int property_id, const GValue * value, GParamSpec * param_spec)
00061 {
00062     if( !Glib::ObjectBase::_get_current_wrapper(object) )
00063         Obj_Wrap_New<Type>(object);
00064         Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object);
00065         if (!wrapper)
00066                 return;
00067         Type *renderer = dynamic_cast<Type *>(wrapper);
00068         if (!renderer)
00069                 return;
00070     Glib::custom_set_property_callback(object,property_id,value,param_spec);
00071 }
00072 
00073 #endif

Документация по UniWidgets. Последние изменения: Fri Oct 10 09:57:49 2014. Создано системой  doxygen 1.5.9