Re: stupid question?

On 20 May 2001 14:11:26 +0200, Dietmar Maurer wrote:
> Erik Bågfors wrote:
> > Hi!
> >
> > Here is a stupid question (perhaps).
> >
> > I've been playing around alittle in bonobo and it's really sweet :).
> >
> > If I understand things correctly here is parts of how the classes hang
> > together..
> >
> > GtkObject ->    BonoboObject ->         BonoboXObject
> >                             |-> BonoboPropertyBag
> >                             |-> BonoboControlFrame
> >
> > The thing I don't understand is that the I can convert the BonoboControlFrame
> > to a GtkObject using GTK_OBJECT(control_frame) but I cannot convert the
> > BonoboPropertyBag to a GtkObject with GTK_OBJECT.
> A PropertyBag is a GtkObject, so GTK_OBJECT(property_bag) should work without
> any problems. Maybe something else is wrong with your code.

Good, thanks, then maybe you (or someone else) can explain this.

I'm playing around with the code in the bonobo-tutorial (ipctrl).  This is from test-container.c 
in function install_property_bag_listener.  I only added three lines (four with the comment :) ) 
to the code (just as a try).  This doesn't break the code since I don't use the GtkObject I add.

Anyway.  I added a GtkObject named testA and then tried to do a GTK_OBJECT on the prop_bag.  This 
code gives me two Gtk-WARNING's

Gtk-WARNING **: invalid cast from `(unknown)' to `GtkObject'

Gtk-WARNING **: invalid cast from `(unknown)' to `GtkObject'


static Bonobo_PropertyBag      prop_bag = CORBA_OBJECT_NIL;

static void
install_property_bag_listener (BonoboWidget *control, BonoboWindow *bonobo_win)
        Bonobo_Listener corba_listener;
        BonoboListener *listener;
        BonoboControlFrame *control_frame;
        CORBA_Environment ev;
        GtkObject *testA; /* I added this */

        CORBA_exception_init (&ev);
         *  the property bag is associated with the control frame, so get a
         *  control frame first
        control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control));
        if (!control_frame)
                g_error ("can't find control frame\n");

         * now, get a ref to the property bag
        prop_bag = bonobo_control_frame_get_control_property_bag (control_frame, NULL);

        /* I added the following two lines */
        testA = GTK_OBJECT(&prop_bag); /* Try one.. gives one warning */
        testA = GTK_OBJECT(prop_bag);  /* Try two gives another warning :( */

        if (prop_bag == CORBA_OBJECT_NIL)
                g_error ("can't connect to property bag\n");

         * connect a listener to the property-bag
        bonobo_event_source_client_add_listener (prop_bag, on_prop_changed,
                                                 "Bonobo/Property:change:octet1", NULL, bonobo_win);
        CORBA_exception_free (&ev);


As you can see the propertybag is correct since I use it later and the
propgram works.

So, what am I doing wrong?


Erik Bågfors               |    
erik bagfors nu            | Erik Bagfors engohol se
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32

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