After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 675941 - Ellipsized GtkLabel apparently makes too large size request
Ellipsized GtkLabel apparently makes too large size request
Status: RESOLVED NOTABUG
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-05-12 14:43 UTC by Phillip Berndt
Modified: 2016-03-06 15:11 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Phillip Berndt 2012-05-12 14:43:45 UTC
The Python code below will create a window with a fixed layout containing a container with red background and a label inside. The label is set to ellipsize its content if it is longer than the size of the label.

In GTK 2 the window would have been 100px wide when executing this and this is also what I'd expect.

What actually happens in GTK 3 is that the label and the surrounding event box are 100px wide as requested but the window has the size it would need to have to display the whole text.

--

from gi.repository import Gtk, Gdk

wnd = Gtk.Window()
box = Gtk.EventBox()
fixed = Gtk.Fixed()
lbl = Gtk.Label("Long label..with lots of text.. foo bar baz")
wnd.add(fixed)

box.add(lbl)
box.modify_bg(0, Gdk.Color(0xffff, 0, 0))

fixed.put(box, 10, 10)
lbl.set_size_request(100, -1)
lbl.set_ellipsize(1)

wnd.set_size_request(100, -1)

wnd.show_all()

Gtk.main()
Comment 1 Matthias Clasen 2016-03-06 15:11:55 UTC
set_size_request only sets the minimum size of a widget. The label will still determine its natural size from its content, and the window will take that into account when choosing its size