Re: GGV 1.1.96



Well, I am on my way to create my own version of BonoboUIContainer. And
I am almost as dumb as I was before. I declare and create new class,
instantiate new object. And initialization functions are called OK. But
for some strange reason the system calls _old_ functions
registerComponent and deregisterComponent. Michael, if you have a couple
of minutes, could you please have a look at these small files - what
could be wrong here?
First I tried to have my own "epv" and use BONOBO_X_TYPE_FUNC_FULL
(memcopying epv from the parent class). Then I removed epv  and used
BONONO_X_TYPE_FUNC - but no difference. Functions are not overridden.
About the way I use my object:

XkbUIContainer * xkbuicont = xkb_ui_container_new();
Bonobo_UIContainer uicont = Bonobo_Unknown_queryInterface(
   BONOBO_OBJREF( xkbuicont ), "IDL:Bonobo/UIContainer:1.0", NULL );

newChild = bonobo_widget_new_control( psFileMoniker, uicont );

And this newChild works perfectly...

TIA,

Sergey
#ifndef _XKB_UI_CONTAINER_H_
#define _XKB_UI_CONTAINER_H_

#include <bonobo/bonobo-ui-container.h>

BEGIN_GNOME_DECLS
#define XKB_UI_CONTAINER_TYPE        (xkb_ui_container_get_type ())
#define XKB_UI_CONTAINER(o)          (GTK_CHECK_CAST ((o), XKB_UI_CONTAINER_TYPE, XkbUIContainer))
#define XKB_UI_CONTAINER_CLASS(k)    (GTK_CHECK_CLASS_CAST((k), XKB_UI_CONTAINER_TYPE, XkbUIContainerClass))
#define XKB_IS_UI_CONTAINER(o)       (GTK_CHECK_TYPE ((o), XKB_UI_CONTAINER_TYPE))
#define XKB_IS_UI_CONTAINER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), XKB_UI_CONTAINER_TYPE))
typedef struct _XkbUIContainerPrivate XkbUIContainerPrivate;

typedef struct
{
  BonoboUIContainer base;

  XkbUIContainerPrivate *priv;
}
XkbUIContainer;

typedef struct
{
  BonoboUIContainerClass parent;

  POA_Bonobo_UIContainer__epv epv;
}
XkbUIContainerClass;

GtkType xkb_ui_container_get_type( void );
//XkbUIContainer *xkb_ui_container_construct( XkbUIContainer * container,
  //                                          Bonobo_UIContainer
    //                                        corba_container );

XkbUIContainer *xkb_ui_container_new( void );

END_GNOME_DECLS
#endif /* _XKB_UI_CONTAINER_H_ */
#include "config.h"

#include <bonobo/bonobo-ui-component.h>
#include <xkb_ui_container.h>

#define PARENT_TYPE BONOBO_UI_CONTAINER_TYPE

static GtkObjectClass *xkb_ui_container_parent_class;

struct _XkbUIContainerPrivate
{
  int dummy;
};

static void xkb_ui_container_destroy( GtkObject * object )
{
  fprintf( stderr, "DESTROY! \n" );
  xkb_ui_container_parent_class->destroy( object );
}

static void xkb_ui_container_finalize( GtkObject * object )
{
  fprintf( stderr, "FINALIZE! \n" );
  XkbUIContainer *container = ( XkbUIContainer * ) object;

  g_free( container->priv );
  container->priv = NULL;

  xkb_ui_container_parent_class->finalize( object );
}

static void xkb_ui_container_init( GtkObject * object )
{
  XkbUIContainer *container = ( XkbUIContainer * ) object;

  container->priv = g_new0( XkbUIContainerPrivate, 1 );
  fprintf( stderr, "OBJECT INITIALIZED!\n" );
}

static void
impl_Xkb_UIContainer_registerComponent( PortableServer_Servant servant,
                                        const CORBA_char * component_name,
                                        const Bonobo_Unknown object,
                                        CORBA_Environment * ev )
{
  fprintf( stderr, "REGISTER! %p %i\n", object,
           BONOBO_IS_UI_COMPONENT( object ) );
  ( ( BonoboUIContainerClass * ) xkb_ui_container_parent_class )->epv.
    registerComponent( servant, component_name, object, ev );
}

static void
impl_Xkb_UIContainer_deregisterComponent( PortableServer_Servant servant,
                                          const CORBA_char * component_name,
                                          CORBA_Environment * ev )
{
  fprintf( stderr, "DEREGISTER! \n" );
  ( ( BonoboUIContainerClass * ) xkb_ui_container_parent_class )->epv.
    deregisterComponent( servant, component_name, ev );
}

static void
impl_Xkb_UIContainer_setObject( PortableServer_Servant servant,
                                const CORBA_char * path,
                                const Bonobo_Unknown control,
                                CORBA_Environment * ev )
{
  fprintf( stderr, "SETOBJECT %p! \n", control );
  ( ( BonoboUIContainerClass * ) xkb_ui_container_parent_class )->epv.
    setObject( servant, path, control, ev );
}

static void xkb_ui_container_class_init( XkbUIContainerClass * klass )
{
  GtkObjectClass *gtk_class = ( GtkObjectClass * ) klass;
  //POA_Bonobo_UIContainer__epv *epv = &klass->epv;
  POA_Bonobo_UIContainer__epv *epv = &klass->parent.epv;

  xkb_ui_container_parent_class = gtk_type_class( PARENT_TYPE );

  gtk_class->destroy = xkb_ui_container_destroy;
  gtk_class->finalize = xkb_ui_container_finalize;

/*  memcpy( epv,
          &( ( BonoboUIContainerClass * ) xkb_ui_container_parent_class )->
          epv, sizeof( *epv ) );*/

  epv->registerComponent = impl_Xkb_UIContainer_registerComponent;
  epv->deregisterComponent = impl_Xkb_UIContainer_deregisterComponent;

  epv->setObject = impl_Xkb_UIContainer_setObject;

  fprintf( stderr, "CLASS INITIALIZED!\n" );
}

//BONOBO_X_TYPE_FUNC_FULL( XkbUIContainer, Bonobo_UIContainer,
//                         bonobo_ui_container_get_type(  ), 
//			 xkb_ui_container );
BONOBO_X_TYPE_FUNC( XkbUIContainer, 
                         bonobo_ui_container_get_type(  ), 
			 xkb_ui_container );

XkbUIContainer *xkb_ui_container_new( void )
{
  return gtk_type_new( XKB_UI_CONTAINER_TYPE );
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]