Re: GtkPaned vs. GtkBox



Emmanuel DELOGET wrote:
> 
> From: Fritz Jetzek <fritz.jetzek@i-dmedia.com>
> > hi,
> >
> > i've been accustomed to use GtkPaneds instead of GtkBoxes wherever
> > possible. there are two things which i'd like to remark:
> 
>     I do not understand your design. The goal of GtkBox and GtkPaned
>     are rather different : GtkBox is (well... :) a box - a container
>     for multiple widgets.
> 
>     And to quote the tutorial:
>     "The paned window widgets are useful when you want to divide
>     an area into two parts, with the relative size of the two
>     parts controlled by the user."
> 
> >
> > a) wouldn't it make sense to implement GtkPaneds in a way that makes it
> > possible to add elements at will instead of just two? i'm working around
> > this by nesting multiple paneds with each other but it seems suboptimal
> > in a way.
> 
>     Considering what I just told, it is not the goal of GtkPaned
>     to hold more than 2 widgets. 

this is just what i consider a design flaw. in computer science, there
are just three numbers: 0, 1, and n - where n is any other number. taken
this, it would make any container more powerful to allow for an
arbitrary number of children -or only one.
what's actually the advantage of a widget allowing exactly 2 children?

> You'll have to play with boxes
>     tables or fixed layout if you want to add more widgets around
>     - then add your container to the paned window.
> >
> > b) the settings of GtkBoxes are a bit more flexible in that they provide
> > means to set filling and padding; i found no simple way to tell the
> > elements contained in GtkPaneds to take up all the remaining space or
> > otherwise behave like elements of a GtkBox
> >
> > could someone comment on whether it would make sense to reimplement
> > GtkPaned as being derived from GtkBox?
> 
>     At this time, the design of the GK containers are rather simple:
>     you have
>         * containers that caon contain multiple widgets (box and so on)
>         * containers that can contain only one widget (window, button,
>         paned window, ...)

as you pointed out yourself (quotation from tutorial above), the paned
window is a container for 2 widgets, not for one or just multiple
widgets, so it fits in neither category imho.

>     When you want to add more than one widget in the former you must
>     first add a container that can handle all the widgets you want.
>     This way you can do everything you want.

yes, that's the way i do it now. but it makes my code (or anyone's code
that has to use more than two paneds in a row) less readable because of
that nesting. what i suggest is a generic gtk_paned_add() function that
will allow me to add an arbitrary number of children to a GtkPaned
object, instead of nesting GtkPaned objects over and over.
consider a row of n widgets that you want to have separated by those
handles only GtkPaned provides. with the current implementation, you'll
have to set up n-1 GtkPaned objects instead of just adding widgets to 1
GtkPaned object. 

illustration:

[current implementation of GtkPaned]
 _____________________ 
|                     | code:
|__________________o__|         paned = gtk_vpaned_new();
| ___________________ |         gtk_paned_add1(paned, child);
||                   ||         paned2 = gtk_vpaned_new();
||________________o__||         gtk_paned_add2(paned, paned2);
|| _________________ ||         gtk_paned_add1(paned2, child2);
|||                 |||         paned3 = gtk_vpaned_new();
|||______________o__|||         gtk_paned_add2(paned2, paned3);
|||                 |||         gtk_paned_add1(paned3, child3);
|||                 |||         ...
|||                 |||
...                 ...

[suggested api]
 _____________________  
|                     |         paned = gtk_vpaned_new();
|__________________o__|         gtk_paned_add(paned, child1);
|                     |         gtk_paned_add(paned, child2);
|__________________o__|         gtk_paned_add(paned, child3);
|                     |         ...
|__________________o__|
.                     .

(_o_ stands for the handle button)

i'm aware that GtkPaned and GtkBox are quite different right now, but i
see several advantages for a GtkBox-based implementation of GtkPaned. 

sorry if i'm going to annoy you - i just thought it'd be worth a
discussion:-)

fritz



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