Re: How to get a GtkLabel to fill all the available space.



Nickolay V. Shmyrev wrote:
В Чтв, 05/01/2006 в 11:28 -0500, Hans Deragon пишет:

Greetings.


Under Gnome 2.10, using glade-2, I created a simple window with GtkHBox. The GtkHBox as 3 sections, the first a small image, the second a label and the tird a small button.

The GtkLabel is the widget that should take all the rest of available space. When clicking on it, I see that it seams to be taking it, as the border shown with glade-2 confirms it. Yet, the text I have entered, multi-line and very long, seams to wrap much before the right border of the widget. I tried all sort of stuff, but could not have the text go as far as the right border. There seams to be an imaginary boundary in the middle of the label where the text wraps.

I noticed that if I increase the width of the widget in pixels, in the Properties/Common/width entry, I can sorta fix this. But that means I have to enter a specific width. I do not want this. I want for the label to expand and wrap as the user changes the size of the window.

This must be a common problem. Probably there is an easy solution I simply am not to figure out.


Best regards,
Hans Deragon
--


Hello Hans

You are correct, it's just an internal hard-coded behaviour of the
GtkLabel with wrapped text. If you just need to have simple label, it
may have sense to implement your own label-like widget.
Otherwise, you should look at gtk_label_ensure_layout function in gtk
sources (there is if (label->wrap) statement). It uses quite hackish
algorithm to determine label's width from layout width, screen width and
so on. Of course, it can be improved. Probably you can suggest something
better. In that case you should search bugzilla for similar bugs,
probably create a bug in bugzilla against gtk and mail a patch to gtk-
devel list.

Thanks for the feedback Nickolay.


Unfortunatly, I am not mandated to work on gtk+ by my employer. I will live with this shortcomming. Also, I am using gtk+ within python and the ensure_layout() function is not available in this language (or I did not find the function on the gtkLabel object).

  I checked bugzilla, but found no opened bug relating to this.


Best regards,
Hans Deragon
--
Consultant en informatique/Software Consultant
Deragon Informatique inc.
http://www.deragon.biz        Open source (contribution):
mailto://hans deragon biz     http://autopoweroff.deragon.biz



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