Re: Help with non-GUI Bonobo Controls



Erik Lotspeich <erik elctech com> writes:

> I am trying to get started using Bonobo, and want to develop a basic
> Bonobo object that supports one property and one method.  This control
> will not require a GUI representation and will simply allow the setting of
> a variable, say "var1" and then a method i.e. response() that repeats the
> property value when called.

There is no such thing "non-GUI Bonobo Control"; either you have an UI or
you don't want to use a control.

> more GTK+ widgets into a Bonobo Control and assign properties to it, but
> although my question is simpler, I have not seen an example either in the
> API documentation or the tutorial.
> 
> Any direction on how to accomplish this or sample code would be
> appreciated.

Quickly hacked up at almost 3am after a few beer, uncomplete and untested -
but it should give you the idea:

* In your IDL:

        module Whatever {
                interface Foo : Bonobo::Unknown {
                        void response ();
                };
        };

* In your C header:

        struct _FooClass {
                BonoboObjectClass class;
        };

        struct _Foo {
                BonoboObject object;

                glong var1;
        };

* In your C source:

        enum {
                PROP_0,
                PROP_VAR1
        };

        static void
        impl_Whatever_Foo_response (PortableServer_Servant servant) {
                foo = FOO (bonobo_object_from_servant (servant));

                do_something_with_it (foo->var1);
        }

        static void
        foo_class_init (FooClass *klass) {
                POA_Whatever_Foo__epv *epv = &klass->epv;

                epv->response = impl_Whatever_Foo_response;
        }

        static void
        foo_instance_init (Foo *foo) {
                BonoboPropertyBag *pbag;

                pbag = bonobo_property_bag_new (get_prop, set_prop, foo);

                bonobo_property_bag_add (pbag, "var1", PROP_VAR1,
                                         TC_CORBA_long, NULL, NULL,
                                         BONOBO_PROPERTY_READABLE |
                                         BONOBO_PROPERTY_WRITEABLE);

                bonobo_object_add_interface (BONOBO_OBJECT (foo),
                                             BONOBO_OBJECT (pbag));
        }

        BONOBO_TYPE_FUNC_FULL(Foo, Whatever_Foo, BONOBO_OBJECT_TYPE, fo);


Something like this ....


-- 
Martin Baulig
martin gnome org (private)
baulig suse de (work)




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