Re: [gtkmm] Any easy way to write a cell renderer with a combo box it it.

On Fre, 2003-01-10 at 09:35, ZHOU DX wrote:
> Thanks for the hint. 
> Finally I worked out my combo cell renderer after
> studying the example codes. 


> Since I wrap a combo directly and thus I do not have
> to handle the popup issues, the codes are much simpler
> than in the gtkmm example. 

Yes I was wondering about that too.  The gtkmm example is a port of the
custom cell renderer used in MrProject.  It'd be really cool if you
could contribute your code -- i.e., are we allowed to include it in
gtkmm as example code?

I was just about to fix the keynav behaviour of the gtkmm popup renderer
example, but using a Gtk::Combo would of course be saner.

> But there is still one thing I do not understand. 
> What is the "Glib::ObjectBase (typeid
> (CMy_Combo_Editable))" for(marked in the soruces
> below)? If I remove that it, I got an error that says:

Yes you definitely need that line.  It's a nifty feature that allows you
to create a custom GObject class on the fly.  The typeid information is
necessary because it's not possible in C++ to retrieve the final type of
an object at construction time.

If you do:

    Glib::ObjectBase (typeid(MyClass))

then typeid(MyClass).name() will be used as the GObject type name (well
actually it's prefixed by "gtkmm__CustomObject_" and all characters that
aren't allowed in GType names are replaced with '+').

Alternatively, you can do:

    Glib::ObjectBase ("MyCustomType")

instead of using the C++ RTTI name.  Otherwise the same rules apply,
i.e. it'll be prefixed and canonicalized.

> (test: 4937): Gtk - CRITICAL **: file
> gtktreeviewcolumn.c: line 2500
> (gtk_tree_view_column_cell_process_action):assertion`
> GTK_IS_CELL_EDITABLE (*editable_widget)' failed
> It looks to me the line registers the class to
> somewhere. Is that right? I found a lot of mystery
> stuffs(to me) like this in the gtkmm source codes, and
> it was really hard to figure out a big image. Is there
> any document around about these "gtkmm internals" ?

Sorry, not yet.  I added that feature in order to implement the custom
cell renderer in C++, which is quite advanced stuff.  I hope I'll find
time to document it.

> The source of my combo renderer is following. The
> "spinbox" cell renderer can also be 
> implemented in this way, and is actually easier(Do not
> need an extra editable widget).


That's really nice stuff, thanks a lot.


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