1

I trying to create custom GtkCellRenderer with some text. And I want this text truncated, when a size of GtkCellRenderer is smaller than size of text. For example:

alt text

How can I do this? Is this some property of CellRenderer or PangoLayout or I need to do this manually?

gpoo
  • 8,408
  • 3
  • 38
  • 53
troorl
  • 1,579
  • 1
  • 15
  • 20

1 Answers1

1

Use the ellipsize and ellipsize-set properties of GtkCellRendererText.

If you want to do it manually with Pango, use pango_layout_set_ellipsize().

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • But I'm extending GtkCellRenderer, not GtkCellRendererText. – troorl Jun 04 '10 at 09:49
  • 1
    Why not subclass `GtkCellRendererText`? Do you want to make something like in the picture you posted? Then you would be better off using two columns, one with `GtkCellRendererPixbuf` and one `GtkCellRendererText`. But also see edit above. – ptomato Jun 04 '10 at 10:17
  • Thank you, pango_layout_set_ellipsize - probably is what I need. But when I use it, instead of the text displayed only three dots. Maybe I missed something. – troorl Jun 04 '10 at 13:08
  • You need to use it in combination with `pango_layout_set_width()`. – ptomato Jun 04 '10 at 14:55
  • Can you give an example of overloading a `Gtk.CellRendererText` please? – buhtz May 09 '18 at 22:09