Re: [gtk-list] intended gtk_frame behavior as container?




Antonio Campos <acampos@ceronet.com> writes:

> When I set the border width of a gtk_frame as a container, with:
> 
> gtk_container_set_border_width(GTK_CONTAINER(frame),30);
> 
> the interior of the frame doesn't get the 30 pixels of border width as
> expected. Instead of this, the exterior of the frame gets the 30 pixels
> of border width.
> I consider this more a bug than a feature, because when I set the border
> width of a container, the contained widget gets the border width around
> it, and inside the container.
> For example, this is what happens with gtk_windows,gtk_buttons, etc...

As far as I know, GtkWindow is the sole case where the border_width is
inside the widget. Everything else behaves like GtkFrame.

And it would be hard for the border_width to be outside the widget
for GtkWindow.

> 
> I attach a simple code to illustrate this:
> 
> #include <gtk/gtk.h>
> 
> int main(int argc,char **argv)
> {
>   GtkWidget *w,*frame;
> 
>   gtk_init(&argc,&argv);
> 
>   w=gtk_window_new(GTK_WINDOW_TOPLEVEL);
> 
>   frame=gtk_frame_new("Test of frame border width as container");
>   gtk_container_set_border_width(GTK_CONTAINER(frame),30);
>   gtk_container_add(GTK_CONTAINER(frame),gtk_label_new("Label inside
> frame"));
>   gtk_container_add(GTK_CONTAINER(w),frame);
>   gtk_container_set_border_width(GTK_CONTAINER(w),10);
>   gtk_widget_show_all(w);
> 
>   gtk_main();
> 
>   return 0;
> }
> 
> As you can see, the expected result should be a 10 pixels border width
> around the frame, and a 30 pixels border width inside the frame. But the
> result is a 10+30=40 pixels border width around the frame.
> This is strange, because if I want to put a border inside the frame I
p> must create a container inside the frame and set the border of this last
> container. (A waste of resources and widgets).
> 
> Is this considered a bug? If so, do I post it to the bug tracker?

I'm not sure if it is a misfeature, but it is not a bug, in the sense,
that fixing it would break so much stuff that it isn't even funny.

Most of the time you already have a suitable container inside the frame,
if not, then a simple container like a GtkAlignment is really cheap,
and I would not worry about the wasted resources.

(Note that Tk has both padding and ipadding, so they allow both
types of border to be set on a widget. GTK+ has only a single border
width.)
 
> By the way, if I want to send a patch, which are the "diff" switches I
> must use?

diff -u.

 Do I have to make a .tgz file? Do I have to use the last
> CVS module? (I still don't know how to use the CVS thingie (:^(   )

A patch against the latest released version is always OK for something like
this.

Regards,
                                        Owen



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