Re: ellipsize expander label



On Sun, Mar 1, 2009 at 9:48 AM, Vladimir Nadvornik <nadvornik suse cz> wrote:
Hi,

Is it possible to ellipsize expander label?

The simple approach does not work for me.

expander = gtk_expander_new(NULL);
label = gtk_label_new("some longer text");
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
gtk_expander_set_label_widget(GTK_EXPANDER(expander), label);

It shows just "..." even if there is enough room for the whole text.

The label will only request size for the ellipsis if you dont manually
set a size request - you could just use a value...

...or... if you want an expand to fit label... I dont know if this is
documented anywhere
but just take a look at the size_request() and size_allocate_after()
functions here:
http://svn.gnome.org/viewvc/glade3/trunk/gladeui/glade-editor-property.c?revision=2034&view=markup
(note the calculation for the child label allocation will be alot
simpler if you just wrap it alone
in an hbox or something).

Its a little evil and hackish but the technique will give you expand to fit
allocation ellipsis (although personally I've only tried it for word wrapping).

Cheers,
                -Tristan



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