[Glade-devel] RE : fill_empty method (was Helping out)
Joaquin Cuenca Abela
e98cuenc@free.fr
Sat, 4 Oct 2003 22:49:09 +0200
Paolo wrote:
>
> On Sat, 2003-10-04 at 13:29, Joaquin Cuenca Abela wrote:
> > I'm also done with glade-widget-class, so please commit any pending
> > changes.
> >
>
> Attached there is a patch which turns fill_empty (the
> function which takes care of filling the containers with
> placeholders) into a method of GladeWidgetClass, since a
> generic function, like the one we have now, doesn't work for
> every widget. I made the patch some time ago and today I
> updated it to the current cvs, but before committing I'd like
> to hear your opinions on some issues.
>
> 1) For most of the containers fill_empty would simply do
> gtk_container_add
> (GTK_CONTAINER(widget->widget),glade_placeholder_new ()); so
> I'd like to know which is the preferred way to handle this
> common case. Among others I can at least think of 3 ways:
> - Every widget has its <FillEmptyFunction> (ugly)
> - Have a gtkcontainer.xml which declares the common
> <FillEmptyFunction> and widgets inheriting from it can
> override the method if needed (I don't know how to do it in practice)
> - Handle it in glade_widget_fill_empty() and only the widgets
> which need something different have a not NULL fill_empty
> method (this is what it is in the patch now)
I prefer the second option. The less knowledge we defer to the .xml
files the best.
You can let it like you've done, and I will change it to the second
option if you have problems implementing it.
Just let me know.
> 2) Somewhat related to the above. Some widgets (e.g.
> GtkButton) are containers, but do not have to be filled with
> placeholders, this can be handled in two way:
> - adding more logic to glade_widget_fill_empty (like the current cvs
> works)
> - these widgets override the fill_empty method with the
> ignore() function
Again, second option
> 3) With the attached patch applied [vh]box get wrong their
> size (e.g 4 placeholders instead of 3). The bug can be
> papered over be overriding the fill_empty method of [vh]box
> with ignore(), but there seems to be something wrong in
> glade_gtk_box_set_size... btw how do I set a gdb breakpoint
> in glade_gtk_box_set_size now that it is in a shared library?
I didn't have any problem setting a breakpoint at
glade_gtk_box_set_size. What's gdb complaining about?
> 4) In the patch I only included glade_gtk_dialog_fill_empty
> and glade_gtk_paned_fill_empty; of course also other widgets
> need to override the method. With regard to GtkPaned, is it
> possible to create a gtkpaned.xml, put the
> <FillEmptyFunction> there and have GtkVPaned and GtkHPaned
> automagically inherit it or should both gtkhpaned.xml and
> gtkvpaned.xml be created?
Just gtkpaned.xml should be enough. Again, you should implement the
inheritability of FillEmptyFunction.
If you want to implement it yourself, take a look at
glade_widget_class_merge. It's probably just a matter of adding:
if (widget_class->fill_empty_function == NULL)
widget_class->fill_empty_function =
parent_class->fill_empty_function;
Cheers,