Porting some exo code to GTK3 as part of SpaceFM - how to properly subclass GtkCellRendererText

OmegaPhil OmegaPhil at startmail.com
Fri Jul 10 21:34:24 CEST 2015


SpaceFM[0] has recently nicked the icon picker/viewer from exo (normally
used by Thunar at least), available in its GTK2 build. I've been asked
to port the code to GTK3 (no prior experience etc), however the GTK
maintainers have bricked the get_size call that
exo-cell-render-ellipsized-text relies on
(exo/exo-cell-renderer-ellipsized-text.c) - the specific call that got
my attention was:

================================================================

(*GTK_CELL_RENDERER_CLASS
(exo_cell_renderer_ellipsized_text_parent_class)->get_size) (renderer,
widget, &text_area,
                                            &x0, &y0, &text_width,
&text_height);

================================================================

in exo_cell_renderer_ellipsized_text_render (in exo git[1]).

The parent class' get_size member is actually NULL - this is because no
function has been assigned to it in GTK3's
gtkcellrenderer.c:gtk_cell_renderer_class_init, even though there is a
get_size function available, and then in gtkcellrenderertext.c they
didn't implement a get_size either.

Looking at the general documentation I can see that
gtk_cell_renderer_get_size is deprecated (but not removed) in favour of
gtk_cell_renderer_get_preferred_size, yet looking at
gtk_cell_renderer_class_init again there is no direct call to
gtk_cell_renderer_get_preferred_size available - only bits and pieces
like gtk_cell_renderer_text_get_preferred_width and
gtk_cell_renderer_text_get_preferred_height_for_width e.g., which are
used amongst other functions in the internal implementation of
gtk_cell_renderer_get_preferred_size. So before I start copying GTK3
internal implementation I need a sanity check from someone who knows
about this kind of thing.

Do they even intend people to subclass/derive from their widgets at this
point?

Doesn't look like exo is being ported atm in XFCE, but asking here in
case someone knows about the current code, before I ask a more generic
question on the GTK list.

Thanks

0: https://ignorantguru.github.io/spacefm/
1:
http://git.xfce.org/xfce/exo/tree/exo/exo-cell-renderer-ellipsized-text.c#n309

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://mail.xfce.org/pipermail/xfce4-dev/attachments/20150710/012475ee/attachment.sig>


More information about the Xfce4-dev mailing list