GNOME Bugzilla – Bug 675941
Ellipsized GtkLabel apparently makes too large size request
Last modified: 2016-03-06 15:11:55 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()
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