X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkcellrenderertext.c;h=4a3110caedcb1a0fcec2b445228c9787e80bdf90;hb=e0c2a4e10fd483d24aa384c0d5f2b606ad00e8ca;hp=abdd8db3ef0e83c8b000306a7d1fd80e0013a4e6;hpb=024c31e2fe274c720aa7153b69bc705d3fae650a;p=~andy%2Fgtk diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index abdd8db3e..4a3110cae 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -17,18 +17,21 @@ * Boston, MA 02111-1307, USA. */ -#include -#include -#include "gtkalias.h" +#include "config.h" + #include "gtkcellrenderertext.h" + +#include + #include "gtkeditable.h" #include "gtkentry.h" +#include "gtksizerequest.h" #include "gtkmarshalers.h" #include "gtkintl.h" +#include "gtkprivate.h" #include "gtktreeprivate.h" -static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext); -static void gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class); + static void gtk_cell_renderer_text_finalize (GObject *object); static void gtk_cell_renderer_text_get_property (GObject *object, @@ -39,29 +42,35 @@ static void gtk_cell_renderer_text_set_property (GObject *obje guint param_id, const GValue *value, GParamSpec *pspec); -static void gtk_cell_renderer_text_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height); static void gtk_cell_renderer_text_render (GtkCellRenderer *cell, - GdkWindow *window, + cairo_t *cr, GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, + const GdkRectangle *background_area, + const GdkRectangle *cell_area, GtkCellRendererState flags); static GtkCellEditable *gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, + const GdkRectangle *background_area, + const GdkRectangle *cell_area, GtkCellRendererState flags); +static void gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell, + GtkWidget *widget, + gint *minimal_size, + gint *natural_size); +static void gtk_cell_renderer_text_get_preferred_height (GtkCellRenderer *cell, + GtkWidget *widget, + gint *minimal_size, + gint *natural_size); +static void gtk_cell_renderer_text_get_preferred_height_for_width (GtkCellRenderer *cell, + GtkWidget *widget, + gint width, + gint *minimum_height, + gint *natural_height); + enum { EDITED, LAST_SIGNAL @@ -75,6 +84,9 @@ enum { PROP_ATTRIBUTES, PROP_SINGLE_PARAGRAPH_MODE, PROP_WIDTH_CHARS, + PROP_MAX_WIDTH_CHARS, + PROP_WRAP_WIDTH, + PROP_ALIGN, /* Style args */ PROP_BACKGROUND, @@ -97,6 +109,7 @@ enum { PROP_RISE, PROP_LANGUAGE, PROP_ELLIPSIZE, + PROP_WRAP_MODE, /* Whether-a-style-arg-is-set args */ PROP_BACKGROUND_SET, @@ -113,81 +126,86 @@ enum { PROP_UNDERLINE_SET, PROP_RISE_SET, PROP_LANGUAGE_SET, - PROP_ELLIPSIZE_SET + PROP_ELLIPSIZE_SET, + PROP_ALIGN_SET }; -static gpointer parent_class; static guint text_cell_renderer_signals [LAST_SIGNAL]; #define GTK_CELL_RENDERER_TEXT_PATH "gtk-cell-renderer-text-path" -#define GTK_CELL_RENDERER_TEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER_TEXT, GtkCellRendererTextPrivate)) - -typedef struct _GtkCellRendererTextPrivate GtkCellRendererTextPrivate; struct _GtkCellRendererTextPrivate { - guint single_paragraph : 1; - guint language_set : 1; - guint markup_set : 1; - guint ellipsize_set : 1; - - gulong focus_out_id; - PangoLanguage *language; - PangoEllipsizeMode ellipsize; - - gulong populate_popup_id; - gulong entry_menu_popdown_timeout; - gboolean in_entry_menu; - - gint width_chars; - GtkWidget *entry; -}; + PangoAlignment align; + PangoAttrList *extra_attrs; + PangoColor foreground; + PangoColor background; + PangoEllipsizeMode ellipsize; + PangoFontDescription *font; + PangoLanguage *language; + PangoUnderline underline_style; + PangoWrapMode wrap_mode; -GType -gtk_cell_renderer_text_get_type (void) -{ - static GType cell_text_type = 0; + gboolean in_entry_menu; - if (!cell_text_type) - { - static const GTypeInfo cell_text_info = - { - sizeof (GtkCellRendererTextClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_cell_renderer_text_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCellRendererText), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_cell_renderer_text_init, - }; - - cell_text_type = - g_type_register_static (GTK_TYPE_CELL_RENDERER, "GtkCellRendererText", - &cell_text_info, 0); - } + gchar *text; - return cell_text_type; -} + gdouble font_scale; + + gint rise; + gint fixed_height_rows; + gint width_chars; + gint max_width_chars; + gint wrap_width; + + guint strikethrough : 1; + guint editable : 1; + guint scale_set : 1; + guint foreground_set : 1; + guint background_set : 1; + guint underline_set : 1; + guint rise_set : 1; + guint strikethrough_set : 1; + guint editable_set : 1; + guint calc_fixed_height : 1; + guint single_paragraph : 1; + guint language_set : 1; + guint markup_set : 1; + guint ellipsize_set : 1; + guint align_set : 1; + + gulong focus_out_id; + gulong populate_popup_id; + gulong entry_menu_popdown_timeout; +}; + +G_DEFINE_TYPE (GtkCellRendererText, gtk_cell_renderer_text, GTK_TYPE_CELL_RENDERER) static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext) { GtkCellRendererTextPrivate *priv; + GtkCellRenderer *cell = GTK_CELL_RENDERER (celltext); - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (celltext); + celltext->priv = G_TYPE_INSTANCE_GET_PRIVATE (celltext, + GTK_TYPE_CELL_RENDERER_TEXT, + GtkCellRendererTextPrivate); + priv = celltext->priv; - GTK_CELL_RENDERER (celltext)->xalign = 0.0; - GTK_CELL_RENDERER (celltext)->yalign = 0.5; - GTK_CELL_RENDERER (celltext)->xpad = 2; - GTK_CELL_RENDERER (celltext)->ypad = 2; - celltext->fixed_height_rows = -1; - celltext->font = pango_font_description_new (); + gtk_cell_renderer_set_alignment (cell, 0.0, 0.5); + gtk_cell_renderer_set_padding (cell, 2, 2); + priv->font_scale = 1.0; + priv->fixed_height_rows = -1; + priv->font = pango_font_description_new (); priv->width_chars = -1; + priv->max_width_chars = -1; + priv->wrap_width = -1; + priv->wrap_mode = PANGO_WRAP_CHAR; + priv->align = PANGO_ALIGN_LEFT; + priv->align_set = FALSE; } static void @@ -196,24 +214,24 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) GObjectClass *object_class = G_OBJECT_CLASS (class); GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class); - parent_class = g_type_class_peek_parent (class); - object_class->finalize = gtk_cell_renderer_text_finalize; object_class->get_property = gtk_cell_renderer_text_get_property; object_class->set_property = gtk_cell_renderer_text_set_property; - cell_class->get_size = gtk_cell_renderer_text_get_size; cell_class->render = gtk_cell_renderer_text_render; cell_class->start_editing = gtk_cell_renderer_text_start_editing; - + cell_class->get_preferred_width = gtk_cell_renderer_text_get_preferred_width; + cell_class->get_preferred_height = gtk_cell_renderer_text_get_preferred_height; + cell_class->get_preferred_height_for_width = gtk_cell_renderer_text_get_preferred_height_for_width; + g_object_class_install_property (object_class, PROP_TEXT, g_param_spec_string ("text", P_("Text"), P_("Text to render"), NULL, - G_PARAM_READWRITE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_MARKUP, @@ -221,7 +239,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Markup"), P_("Marked up text to render"), NULL, - G_PARAM_WRITABLE)); + GTK_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_ATTRIBUTES, @@ -229,15 +247,15 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Attributes"), P_("A list of style attributes to apply to the text of the renderer"), PANGO_TYPE_ATTR_LIST, - G_PARAM_READWRITE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_SINGLE_PARAGRAPH_MODE, - g_param_spec_boolean ("single_paragraph_mode", + g_param_spec_boolean ("single-paragraph-mode", P_("Single Paragraph Mode"), - P_("Whether or not to keep all text in a single paragraph"), + P_("Whether to keep all text in a single paragraph"), FALSE, - G_PARAM_READWRITE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, @@ -246,15 +264,15 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Background color name"), P_("Background color as a string"), NULL, - G_PARAM_WRITABLE)); + GTK_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_BACKGROUND_GDK, - g_param_spec_boxed ("background_gdk", + g_param_spec_boxed ("background-gdk", P_("Background color"), P_("Background color as a GdkColor"), GDK_TYPE_COLOR, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_FOREGROUND, @@ -262,15 +280,15 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Foreground color name"), P_("Foreground color as a string"), NULL, - G_PARAM_WRITABLE)); + GTK_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_FOREGROUND_GDK, - g_param_spec_boxed ("foreground_gdk", + g_param_spec_boxed ("foreground-gdk", P_("Foreground color"), P_("Foreground color as a GdkColor"), GDK_TYPE_COLOR, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, @@ -279,23 +297,23 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Editable"), P_("Whether the text can be modified by the user"), FALSE, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_FONT, g_param_spec_string ("font", P_("Font"), - P_("Font description as a string"), + P_("Font description as a string, e.g. \"Sans Italic 12\""), NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_FONT_DESC, - g_param_spec_boxed ("font_desc", + g_param_spec_boxed ("font-desc", P_("Font"), P_("Font description as a PangoFontDescription struct"), PANGO_TYPE_FONT_DESCRIPTION, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, @@ -304,7 +322,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Font family"), P_("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"), NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_STYLE, @@ -313,7 +331,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Font style"), PANGO_TYPE_STYLE, PANGO_STYLE_NORMAL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_VARIANT, @@ -322,7 +340,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Font variant"), PANGO_TYPE_VARIANT, PANGO_VARIANT_NORMAL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_WEIGHT, @@ -332,7 +350,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) 0, G_MAXINT, PANGO_WEIGHT_NORMAL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_STRETCH, @@ -341,7 +359,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Font stretch"), PANGO_TYPE_STRETCH, PANGO_STRETCH_NORMAL, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_SIZE, @@ -351,17 +369,17 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) 0, G_MAXINT, 0, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_SIZE_POINTS, - g_param_spec_double ("size_points", + g_param_spec_double ("size-points", P_("Font points"), P_("Font size in points"), 0.0, G_MAXDOUBLE, 0.0, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_SCALE, @@ -371,17 +389,18 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) 0.0, G_MAXDOUBLE, 1.0, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_RISE, g_param_spec_int ("rise", P_("Rise"), - P_("Offset of text above the baseline (below the baseline if rise is negative)"), + P_("Offset of text above the baseline " + "(below the baseline if rise is negative)"), -G_MAXINT, G_MAXINT, 0, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, @@ -390,7 +409,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Strikethrough"), P_("Whether to strike through the text"), FALSE, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_UNDERLINE, @@ -399,25 +418,39 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) P_("Style of underline for this text"), PANGO_TYPE_UNDERLINE, PANGO_UNDERLINE_NONE, - G_PARAM_READABLE | G_PARAM_WRITABLE)); + GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_LANGUAGE, g_param_spec_string ("language", P_("Language"), - P_("The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If you don't understand this parameter, you probably don't need it"), + P_("The language this text is in, as an ISO code. " + "Pango can use this as a hint when rendering the text. " + "If you don't understand this parameter, you probably don't need it"), NULL, - G_PARAM_READWRITE)); + GTK_PARAM_READWRITE)); + /** + * GtkCellRendererText:ellipsize: + * + * Specifies the preferred place to ellipsize the string, if the cell renderer + * does not have enough room to display the entire string. Setting it to + * %PANGO_ELLIPSIZE_NONE turns off ellipsizing. See the wrap-width property + * for another way of making the text fit into a given width. + * + * Since: 2.6 + */ g_object_class_install_property (object_class, PROP_ELLIPSIZE, g_param_spec_enum ("ellipsize", P_("Ellipsize"), - P_("The preferred place to ellipsize the string, if the cell renderer does not have enough room to display the entire string, if at all"), + P_("The preferred place to ellipsize the string, " + "if the cell renderer does not have enough room " + "to display the entire string"), PANGO_TYPE_ELLIPSIZE_MODE, PANGO_ELLIPSIZE_NONE, - G_PARAM_READWRITE)); + GTK_PARAM_READWRITE)); /** * GtkCellRendererText:width-chars: @@ -430,81 +463,181 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) **/ g_object_class_install_property (object_class, PROP_WIDTH_CHARS, - g_param_spec_int ("width_chars", + g_param_spec_int ("width-chars", P_("Width In Characters"), P_("The desired width of the label, in characters"), -1, G_MAXINT, -1, - G_PARAM_READWRITE)); + GTK_PARAM_READWRITE)); + + /** + * GtkCellRendererText:max-width-chars: + * + * The desired maximum width of the cell, in characters. If this property + * is set to -1, the width will be calculated automatically. + * + * For cell renderers that ellipsize or wrap text; this property + * controls the maximum reported width of the cell. The + * cell should not receive any greater allocation unless it is + * set to expand in its #GtkCellLayout and all of the cell's siblings + * have received their natural width. + * + * Since: 3.0 + **/ + g_object_class_install_property (object_class, + PROP_MAX_WIDTH_CHARS, + g_param_spec_int ("max-width-chars", + P_("Maximum Width In Characters"), + P_("The maximum width of the cell, in characters"), + -1, + G_MAXINT, + -1, + GTK_PARAM_READWRITE)); + + /** + * GtkCellRendererText:wrap-mode: + * + * Specifies how to break the string into multiple lines, if the cell + * renderer does not have enough room to display the entire string. + * This property has no effect unless the wrap-width property is set. + * + * Since: 2.8 + */ + g_object_class_install_property (object_class, + PROP_WRAP_MODE, + g_param_spec_enum ("wrap-mode", + P_("Wrap mode"), + P_("How to break the string into multiple lines, " + "if the cell renderer does not have enough room " + "to display the entire string"), + PANGO_TYPE_WRAP_MODE, + PANGO_WRAP_CHAR, + GTK_PARAM_READWRITE)); + + /** + * GtkCellRendererText:wrap-width: + * + * Specifies the minimum width at which the text is wrapped. The wrap-mode property can + * be used to influence at what character positions the line breaks can be placed. + * Setting wrap-width to -1 turns wrapping off. + * + * Since: 2.8 + */ + g_object_class_install_property (object_class, + PROP_WRAP_WIDTH, + g_param_spec_int ("wrap-width", + P_("Wrap width"), + P_("The width at which the text is wrapped"), + -1, + G_MAXINT, + -1, + GTK_PARAM_READWRITE)); + + /** + * GtkCellRendererText:alignment: + * + * Specifies how to align the lines of text with respect to each other. + * + * Note that this property describes how to align the lines of text in + * case there are several of them. The "xalign" property of #GtkCellRenderer, + * on the other hand, sets the horizontal alignment of the whole text. + * + * Since: 2.10 + */ + g_object_class_install_property (object_class, + PROP_ALIGN, + g_param_spec_enum ("alignment", + P_("Alignment"), + P_("How to align the lines"), + PANGO_TYPE_ALIGNMENT, + PANGO_ALIGN_LEFT, + GTK_PARAM_READWRITE)); + + /* Style props are set or not */ -#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE)) +#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE)) - ADD_SET_PROP ("background_set", PROP_BACKGROUND_SET, + ADD_SET_PROP ("background-set", PROP_BACKGROUND_SET, P_("Background set"), P_("Whether this tag affects the background color")); - ADD_SET_PROP ("foreground_set", PROP_FOREGROUND_SET, + ADD_SET_PROP ("foreground-set", PROP_FOREGROUND_SET, P_("Foreground set"), P_("Whether this tag affects the foreground color")); - ADD_SET_PROP ("editable_set", PROP_EDITABLE_SET, + ADD_SET_PROP ("editable-set", PROP_EDITABLE_SET, P_("Editability set"), P_("Whether this tag affects text editability")); - ADD_SET_PROP ("family_set", PROP_FAMILY_SET, + ADD_SET_PROP ("family-set", PROP_FAMILY_SET, P_("Font family set"), P_("Whether this tag affects the font family")); - ADD_SET_PROP ("style_set", PROP_STYLE_SET, + ADD_SET_PROP ("style-set", PROP_STYLE_SET, P_("Font style set"), P_("Whether this tag affects the font style")); - ADD_SET_PROP ("variant_set", PROP_VARIANT_SET, + ADD_SET_PROP ("variant-set", PROP_VARIANT_SET, P_("Font variant set"), P_("Whether this tag affects the font variant")); - ADD_SET_PROP ("weight_set", PROP_WEIGHT_SET, + ADD_SET_PROP ("weight-set", PROP_WEIGHT_SET, P_("Font weight set"), P_("Whether this tag affects the font weight")); - ADD_SET_PROP ("stretch_set", PROP_STRETCH_SET, + ADD_SET_PROP ("stretch-set", PROP_STRETCH_SET, P_("Font stretch set"), P_("Whether this tag affects the font stretch")); - ADD_SET_PROP ("size_set", PROP_SIZE_SET, + ADD_SET_PROP ("size-set", PROP_SIZE_SET, P_("Font size set"), P_("Whether this tag affects the font size")); - ADD_SET_PROP ("scale_set", PROP_SCALE_SET, + ADD_SET_PROP ("scale-set", PROP_SCALE_SET, P_("Font scale set"), P_("Whether this tag scales the font size by a factor")); - ADD_SET_PROP ("rise_set", PROP_RISE_SET, + ADD_SET_PROP ("rise-set", PROP_RISE_SET, P_("Rise set"), P_("Whether this tag affects the rise")); - ADD_SET_PROP ("strikethrough_set", PROP_STRIKETHROUGH_SET, + ADD_SET_PROP ("strikethrough-set", PROP_STRIKETHROUGH_SET, P_("Strikethrough set"), P_("Whether this tag affects strikethrough")); - ADD_SET_PROP ("underline_set", PROP_UNDERLINE_SET, + ADD_SET_PROP ("underline-set", PROP_UNDERLINE_SET, P_("Underline set"), P_("Whether this tag affects underlining")); - ADD_SET_PROP ("language_set", PROP_LANGUAGE_SET, + ADD_SET_PROP ("language-set", PROP_LANGUAGE_SET, P_("Language set"), P_("Whether this tag affects the language the text is rendered as")); - ADD_SET_PROP ("ellipsize_set", PROP_ELLIPSIZE_SET, + ADD_SET_PROP ("ellipsize-set", PROP_ELLIPSIZE_SET, P_("Ellipsize set"), P_("Whether this tag affects the ellipsize mode")); - + + ADD_SET_PROP ("align-set", PROP_ALIGN_SET, + P_("Align set"), + P_("Whether this tag affects the alignment mode")); + + /** + * GtkCellRendererText::edited + * @renderer: the object which received the signal + * @path: the path identifying the edited cell + * @new_text: the new text + * + * This signal is emitted after @renderer has been edited. + * + * It is the responsibility of the application to update the model + * and store @new_text at the position indicated by @path. + */ text_cell_renderer_signals [EDITED] = - g_signal_new ("edited", + g_signal_new (I_("edited"), G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GtkCellRendererTextClass, edited), @@ -521,22 +654,19 @@ static void gtk_cell_renderer_text_finalize (GObject *object) { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (object); - GtkCellRendererTextPrivate *priv; + GtkCellRendererTextPrivate *priv = celltext->priv; - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (object); + pango_font_description_free (priv->font); - pango_font_description_free (celltext->font); + g_free (priv->text); - if (celltext->text) - g_free (celltext->text); - - if (celltext->extra_attrs) - pango_attr_list_unref (celltext->extra_attrs); + if (priv->extra_attrs) + pango_attr_list_unref (priv->extra_attrs); if (priv->language) g_object_unref (priv->language); - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + G_OBJECT_CLASS (gtk_cell_renderer_text_parent_class)->finalize (object); } static PangoFontMask @@ -568,18 +698,16 @@ gtk_cell_renderer_text_get_property (GObject *object, GParamSpec *pspec) { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (object); - GtkCellRendererTextPrivate *priv; - - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (object); + GtkCellRendererTextPrivate *priv = celltext->priv; switch (param_id) { case PROP_TEXT: - g_value_set_string (value, celltext->text); + g_value_set_string (value, priv->text); break; case PROP_ATTRIBUTES: - g_value_set_boxed (value, celltext->extra_attrs); + g_value_set_boxed (value, priv->extra_attrs); break; case PROP_SINGLE_PARAGRAPH_MODE: @@ -590,9 +718,9 @@ gtk_cell_renderer_text_get_property (GObject *object, { GdkColor color; - color.red = celltext->background.red; - color.green = celltext->background.green; - color.blue = celltext->background.blue; + color.red = priv->background.red; + color.green = priv->background.green; + color.blue = priv->background.blue; g_value_set_boxed (value, &color); } @@ -602,91 +730,96 @@ gtk_cell_renderer_text_get_property (GObject *object, { GdkColor color; - color.red = celltext->foreground.red; - color.green = celltext->foreground.green; - color.blue = celltext->foreground.blue; + color.red = priv->foreground.red; + color.green = priv->foreground.green; + color.blue = priv->foreground.blue; g_value_set_boxed (value, &color); } break; case PROP_FONT: - { - /* FIXME GValue imposes a totally gratuitous string copy - * here, we could just hand off string ownership - */ - gchar *str = pango_font_description_to_string (celltext->font); - g_value_set_string (value, str); - g_free (str); - } + g_value_take_string (value, pango_font_description_to_string (priv->font)); break; case PROP_FONT_DESC: - g_value_set_boxed (value, celltext->font); + g_value_set_boxed (value, priv->font); break; case PROP_FAMILY: - g_value_set_string (value, pango_font_description_get_family (celltext->font)); + g_value_set_string (value, pango_font_description_get_family (priv->font)); break; case PROP_STYLE: - g_value_set_enum (value, pango_font_description_get_style (celltext->font)); + g_value_set_enum (value, pango_font_description_get_style (priv->font)); break; case PROP_VARIANT: - g_value_set_enum (value, pango_font_description_get_variant (celltext->font)); + g_value_set_enum (value, pango_font_description_get_variant (priv->font)); break; case PROP_WEIGHT: - g_value_set_int (value, pango_font_description_get_weight (celltext->font)); + g_value_set_int (value, pango_font_description_get_weight (priv->font)); break; case PROP_STRETCH: - g_value_set_enum (value, pango_font_description_get_stretch (celltext->font)); + g_value_set_enum (value, pango_font_description_get_stretch (priv->font)); break; case PROP_SIZE: - g_value_set_int (value, pango_font_description_get_size (celltext->font)); + g_value_set_int (value, pango_font_description_get_size (priv->font)); break; case PROP_SIZE_POINTS: - g_value_set_double (value, ((double)pango_font_description_get_size (celltext->font)) / (double)PANGO_SCALE); + g_value_set_double (value, ((double)pango_font_description_get_size (priv->font)) / (double)PANGO_SCALE); break; case PROP_SCALE: - g_value_set_double (value, celltext->font_scale); + g_value_set_double (value, priv->font_scale); break; case PROP_EDITABLE: - g_value_set_boolean (value, celltext->editable); + g_value_set_boolean (value, priv->editable); break; case PROP_STRIKETHROUGH: - g_value_set_boolean (value, celltext->strikethrough); + g_value_set_boolean (value, priv->strikethrough); break; case PROP_UNDERLINE: - g_value_set_enum (value, celltext->underline_style); + g_value_set_enum (value, priv->underline_style); break; case PROP_RISE: - g_value_set_int (value, celltext->rise); + g_value_set_int (value, priv->rise); break; case PROP_LANGUAGE: - g_value_set_string (value, pango_language_to_string (priv->language)); + g_value_set_static_string (value, pango_language_to_string (priv->language)); break; case PROP_ELLIPSIZE: g_value_set_enum (value, priv->ellipsize); break; + case PROP_WRAP_MODE: + g_value_set_enum (value, priv->wrap_mode); + break; + + case PROP_WRAP_WIDTH: + g_value_set_int (value, priv->wrap_width); + break; + + case PROP_ALIGN: + g_value_set_enum (value, priv->align); + break; + case PROP_BACKGROUND_SET: - g_value_set_boolean (value, celltext->background_set); + g_value_set_boolean (value, priv->background_set); break; case PROP_FOREGROUND_SET: - g_value_set_boolean (value, celltext->foreground_set); + g_value_set_boolean (value, priv->foreground_set); break; case PROP_FAMILY_SET: @@ -697,29 +830,29 @@ gtk_cell_renderer_text_get_property (GObject *object, case PROP_SIZE_SET: { PangoFontMask mask = get_property_font_set_mask (param_id); - g_value_set_boolean (value, (pango_font_description_get_set_fields (celltext->font) & mask) != 0); + g_value_set_boolean (value, (pango_font_description_get_set_fields (priv->font) & mask) != 0); break; } case PROP_SCALE_SET: - g_value_set_boolean (value, celltext->scale_set); + g_value_set_boolean (value, priv->scale_set); break; case PROP_EDITABLE_SET: - g_value_set_boolean (value, celltext->editable_set); + g_value_set_boolean (value, priv->editable_set); break; case PROP_STRIKETHROUGH_SET: - g_value_set_boolean (value, celltext->strikethrough_set); + g_value_set_boolean (value, priv->strikethrough_set); break; case PROP_UNDERLINE_SET: - g_value_set_boolean (value, celltext->underline_set); + g_value_set_boolean (value, priv->underline_set); break; case PROP_RISE_SET: - g_value_set_boolean (value, celltext->rise_set); + g_value_set_boolean (value, priv->rise_set); break; case PROP_LANGUAGE_SET: @@ -729,11 +862,19 @@ gtk_cell_renderer_text_get_property (GObject *object, case PROP_ELLIPSIZE_SET: g_value_set_boolean (value, priv->ellipsize_set); break; + + case PROP_ALIGN_SET: + g_value_set_boolean (value, priv->align_set); + break; case PROP_WIDTH_CHARS: g_value_set_int (value, priv->width_chars); break; + case PROP_MAX_WIDTH_CHARS: + g_value_set_int (value, priv->max_width_chars); + break; + case PROP_BACKGROUND: case PROP_FOREGROUND: case PROP_MARKUP: @@ -748,24 +889,26 @@ static void set_bg_color (GtkCellRendererText *celltext, GdkColor *color) { + GtkCellRendererTextPrivate *priv = celltext->priv; + if (color) { - if (!celltext->background_set) + if (!priv->background_set) { - celltext->background_set = TRUE; - g_object_notify (G_OBJECT (celltext), "background_set"); + priv->background_set = TRUE; + g_object_notify (G_OBJECT (celltext), "background-set"); } - celltext->background.red = color->red; - celltext->background.green = color->green; - celltext->background.blue = color->blue; + priv->background.red = color->red; + priv->background.green = color->green; + priv->background.blue = color->blue; } else { - if (celltext->background_set) + if (priv->background_set) { - celltext->background_set = FALSE; - g_object_notify (G_OBJECT (celltext), "background_set"); + priv->background_set = FALSE; + g_object_notify (G_OBJECT (celltext), "background-set"); } } } @@ -775,24 +918,26 @@ static void set_fg_color (GtkCellRendererText *celltext, GdkColor *color) { + GtkCellRendererTextPrivate *priv = celltext->priv; + if (color) { - if (!celltext->foreground_set) + if (!priv->foreground_set) { - celltext->foreground_set = TRUE; - g_object_notify (G_OBJECT (celltext), "foreground_set"); + priv->foreground_set = TRUE; + g_object_notify (G_OBJECT (celltext), "foreground-set"); } - celltext->foreground.red = color->red; - celltext->foreground.green = color->green; - celltext->foreground.blue = color->blue; + priv->foreground.red = color->red; + priv->foreground.green = color->green; + priv->foreground.blue = color->blue; } else { - if (celltext->foreground_set) + if (priv->foreground_set) { - celltext->foreground_set = FALSE; - g_object_notify (G_OBJECT (celltext), "foreground_set"); + priv->foreground_set = FALSE; + g_object_notify (G_OBJECT (celltext), "foreground-set"); } } } @@ -842,17 +987,17 @@ notify_set_changed (GObject *object, PangoFontMask changed_mask) { if (changed_mask & PANGO_FONT_MASK_FAMILY) - g_object_notify (object, "family_set"); + g_object_notify (object, "family-set"); if (changed_mask & PANGO_FONT_MASK_STYLE) - g_object_notify (object, "style_set"); + g_object_notify (object, "style-set"); if (changed_mask & PANGO_FONT_MASK_VARIANT) - g_object_notify (object, "variant_set"); + g_object_notify (object, "variant-set"); if (changed_mask & PANGO_FONT_MASK_WEIGHT) - g_object_notify (object, "weight_set"); + g_object_notify (object, "weight-set"); if (changed_mask & PANGO_FONT_MASK_STRETCH) - g_object_notify (object, "stretch_set"); + g_object_notify (object, "stretch-set"); if (changed_mask & PANGO_FONT_MASK_SIZE) - g_object_notify (object, "size_set"); + g_object_notify (object, "size-set"); } static void @@ -877,6 +1022,7 @@ static void set_font_description (GtkCellRendererText *celltext, PangoFontDescription *font_desc) { + GtkCellRendererTextPrivate *priv = celltext->priv; GObject *object = G_OBJECT (celltext); PangoFontDescription *new_font_desc; PangoFontMask old_mask, new_mask, changed_mask, set_changed_mask; @@ -886,18 +1032,18 @@ set_font_description (GtkCellRendererText *celltext, else new_font_desc = pango_font_description_new (); - old_mask = pango_font_description_get_set_fields (celltext->font); + old_mask = pango_font_description_get_set_fields (priv->font); new_mask = pango_font_description_get_set_fields (new_font_desc); changed_mask = old_mask | new_mask; set_changed_mask = old_mask ^ new_mask; - pango_font_description_free (celltext->font); - celltext->font = new_font_desc; + pango_font_description_free (priv->font); + priv->font = new_font_desc; g_object_freeze_notify (object); - g_object_notify (object, "font_desc"); + g_object_notify (object, "font-desc"); g_object_notify (object, "font"); if (changed_mask & PANGO_FONT_MASK_FAMILY) @@ -913,7 +1059,7 @@ set_font_description (GtkCellRendererText *celltext, if (changed_mask & PANGO_FONT_MASK_SIZE) { g_object_notify (object, "size"); - g_object_notify (object, "size_points"); + g_object_notify (object, "size-points"); } notify_set_changed (object, set_changed_mask); @@ -928,35 +1074,32 @@ gtk_cell_renderer_text_set_property (GObject *object, GParamSpec *pspec) { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (object); - GtkCellRendererTextPrivate *priv; - - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (object); + GtkCellRendererTextPrivate *priv = celltext->priv; switch (param_id) { case PROP_TEXT: - if (celltext->text) - g_free (celltext->text); + g_free (priv->text); if (priv->markup_set) { - if (celltext->extra_attrs) - pango_attr_list_unref (celltext->extra_attrs); - celltext->extra_attrs = NULL; + if (priv->extra_attrs) + pango_attr_list_unref (priv->extra_attrs); + priv->extra_attrs = NULL; priv->markup_set = FALSE; } - celltext->text = g_strdup (g_value_get_string (value)); + priv->text = g_value_dup_string (value); g_object_notify (object, "text"); break; case PROP_ATTRIBUTES: - if (celltext->extra_attrs) - pango_attr_list_unref (celltext->extra_attrs); + if (priv->extra_attrs) + pango_attr_list_unref (priv->extra_attrs); - celltext->extra_attrs = g_value_get_boxed (value); - if (celltext->extra_attrs) - pango_attr_list_ref (celltext->extra_attrs); + priv->extra_attrs = g_value_get_boxed (value); + if (priv->extra_attrs) + pango_attr_list_ref (priv->extra_attrs); break; case PROP_MARKUP: { @@ -974,20 +1117,19 @@ gtk_cell_renderer_text_set_property (GObject *object, NULL, &error)) { - g_warning ("Failed to set cell text from markup due to error parsing markup: %s", + g_warning ("Failed to set text from markup due to error parsing markup: %s", error->message); g_error_free (error); return; } - if (celltext->text) - g_free (celltext->text); + g_free (priv->text); - if (celltext->extra_attrs) - pango_attr_list_unref (celltext->extra_attrs); + if (priv->extra_attrs) + pango_attr_list_unref (priv->extra_attrs); - celltext->text = text; - celltext->extra_attrs = attrs; + priv->text = text; + priv->extra_attrs = attrs; priv->markup_set = TRUE; } break; @@ -1001,13 +1143,13 @@ gtk_cell_renderer_text_set_property (GObject *object, GdkColor color; if (!g_value_get_string (value)) - set_bg_color (celltext, NULL); /* reset to backgrounmd_set to FALSE */ + set_bg_color (celltext, NULL); /* reset to background_set to FALSE */ else if (gdk_color_parse (g_value_get_string (value), &color)) set_bg_color (celltext, &color); else g_warning ("Don't know color `%s'", g_value_get_string (value)); - g_object_notify (object, "background_gdk"); + g_object_notify (object, "background-gdk"); } break; @@ -1022,7 +1164,7 @@ gtk_cell_renderer_text_set_property (GObject *object, else g_warning ("Don't know color `%s'", g_value_get_string (value)); - g_object_notify (object, "foreground_gdk"); + g_object_notify (object, "foreground-gdk"); } break; @@ -1050,16 +1192,16 @@ gtk_cell_renderer_text_set_property (GObject *object, pango_font_description_free (font_desc); - if (celltext->fixed_height_rows != -1) - celltext->calc_fixed_height = TRUE; + if (priv->fixed_height_rows != -1) + priv->calc_fixed_height = TRUE; } break; case PROP_FONT_DESC: set_font_description (celltext, g_value_get_boxed (value)); - if (celltext->fixed_height_rows != -1) - celltext->calc_fixed_height = TRUE; + if (priv->fixed_height_rows != -1) + priv->calc_fixed_height = TRUE; break; case PROP_FAMILY: @@ -1070,89 +1212,89 @@ gtk_cell_renderer_text_set_property (GObject *object, case PROP_SIZE: case PROP_SIZE_POINTS: { - PangoFontMask old_set_mask = pango_font_description_get_set_fields (celltext->font); + PangoFontMask old_set_mask = pango_font_description_get_set_fields (priv->font); switch (param_id) { case PROP_FAMILY: - pango_font_description_set_family (celltext->font, + pango_font_description_set_family (priv->font, g_value_get_string (value)); break; case PROP_STYLE: - pango_font_description_set_style (celltext->font, + pango_font_description_set_style (priv->font, g_value_get_enum (value)); break; case PROP_VARIANT: - pango_font_description_set_variant (celltext->font, + pango_font_description_set_variant (priv->font, g_value_get_enum (value)); break; case PROP_WEIGHT: - pango_font_description_set_weight (celltext->font, + pango_font_description_set_weight (priv->font, g_value_get_int (value)); break; case PROP_STRETCH: - pango_font_description_set_stretch (celltext->font, + pango_font_description_set_stretch (priv->font, g_value_get_enum (value)); break; case PROP_SIZE: - pango_font_description_set_size (celltext->font, + pango_font_description_set_size (priv->font, g_value_get_int (value)); - g_object_notify (object, "size_points"); + g_object_notify (object, "size-points"); break; case PROP_SIZE_POINTS: - pango_font_description_set_size (celltext->font, + pango_font_description_set_size (priv->font, g_value_get_double (value) * PANGO_SCALE); g_object_notify (object, "size"); break; } - if (celltext->fixed_height_rows != -1) - celltext->calc_fixed_height = TRUE; + if (priv->fixed_height_rows != -1) + priv->calc_fixed_height = TRUE; - notify_set_changed (object, old_set_mask & pango_font_description_get_set_fields (celltext->font)); - g_object_notify (object, "font_desc"); + notify_set_changed (object, old_set_mask & pango_font_description_get_set_fields (priv->font)); + g_object_notify (object, "font-desc"); g_object_notify (object, "font"); break; } case PROP_SCALE: - celltext->font_scale = g_value_get_double (value); - celltext->scale_set = TRUE; - if (celltext->fixed_height_rows != -1) - celltext->calc_fixed_height = TRUE; - g_object_notify (object, "scale_set"); + priv->font_scale = g_value_get_double (value); + priv->scale_set = TRUE; + if (priv->fixed_height_rows != -1) + priv->calc_fixed_height = TRUE; + g_object_notify (object, "scale-set"); break; case PROP_EDITABLE: - celltext->editable = g_value_get_boolean (value); - celltext->editable_set = TRUE; - if (celltext->editable) - GTK_CELL_RENDERER (celltext)->mode = GTK_CELL_RENDERER_MODE_EDITABLE; + priv->editable = g_value_get_boolean (value); + priv->editable_set = TRUE; + if (priv->editable) + g_object_set (celltext, "mode", GTK_CELL_RENDERER_MODE_EDITABLE, NULL); else - GTK_CELL_RENDERER (celltext)->mode = GTK_CELL_RENDERER_MODE_INERT; - g_object_notify (object, "editable_set"); + g_object_set (celltext, "mode", GTK_CELL_RENDERER_MODE_INERT, NULL); + g_object_notify (object, "editable-set"); break; case PROP_STRIKETHROUGH: - celltext->strikethrough = g_value_get_boolean (value); - celltext->strikethrough_set = TRUE; - g_object_notify (object, "strikethrough_set"); + priv->strikethrough = g_value_get_boolean (value); + priv->strikethrough_set = TRUE; + g_object_notify (object, "strikethrough-set"); break; case PROP_UNDERLINE: - celltext->underline_style = g_value_get_enum (value); - celltext->underline_set = TRUE; - g_object_notify (object, "underline_set"); + priv->underline_style = g_value_get_enum (value); + priv->underline_set = TRUE; + g_object_notify (object, "underline-set"); break; case PROP_RISE: - celltext->rise = g_value_get_int (value); - celltext->rise_set = TRUE; - g_object_notify (object, "rise_set"); - if (celltext->fixed_height_rows != -1) - celltext->calc_fixed_height = TRUE; + priv->rise = g_value_get_int (value); + priv->rise_set = TRUE; + g_object_notify (object, "rise-set"); + if (priv->fixed_height_rows != -1) + priv->calc_fixed_height = TRUE; break; case PROP_LANGUAGE: @@ -1160,25 +1302,43 @@ gtk_cell_renderer_text_set_property (GObject *object, if (priv->language) g_object_unref (priv->language); priv->language = pango_language_from_string (g_value_get_string (value)); - g_object_notify (object, "language_set"); + g_object_notify (object, "language-set"); break; case PROP_ELLIPSIZE: priv->ellipsize = g_value_get_enum (value); priv->ellipsize_set = TRUE; - g_object_notify (object, "ellipsize_set"); + g_object_notify (object, "ellipsize-set"); + break; + + case PROP_WRAP_MODE: + priv->wrap_mode = g_value_get_enum (value); break; + case PROP_WRAP_WIDTH: + priv->wrap_width = g_value_get_int (value); + break; + case PROP_WIDTH_CHARS: priv->width_chars = g_value_get_int (value); - g_object_notify (object, "width_chars"); break; + + case PROP_MAX_WIDTH_CHARS: + priv->max_width_chars = g_value_get_int (value); + break; + + case PROP_ALIGN: + priv->align = g_value_get_enum (value); + priv->align_set = TRUE; + g_object_notify (object, "align-set"); + break; + case PROP_BACKGROUND_SET: - celltext->background_set = g_value_get_boolean (value); + priv->background_set = g_value_get_boolean (value); break; case PROP_FOREGROUND_SET: - celltext->foreground_set = g_value_get_boolean (value); + priv->foreground_set = g_value_get_boolean (value); break; case PROP_FAMILY_SET: @@ -1189,37 +1349,37 @@ gtk_cell_renderer_text_set_property (GObject *object, case PROP_SIZE_SET: if (!g_value_get_boolean (value)) { - pango_font_description_unset_fields (celltext->font, + pango_font_description_unset_fields (priv->font, get_property_font_set_mask (param_id)); } else { PangoFontMask changed_mask; - changed_mask = set_font_desc_fields (celltext->font, + changed_mask = set_font_desc_fields (priv->font, get_property_font_set_mask (param_id)); notify_fields_changed (G_OBJECT (celltext), changed_mask); } break; case PROP_SCALE_SET: - celltext->scale_set = g_value_get_boolean (value); + priv->scale_set = g_value_get_boolean (value); break; case PROP_EDITABLE_SET: - celltext->editable_set = g_value_get_boolean (value); + priv->editable_set = g_value_get_boolean (value); break; case PROP_STRIKETHROUGH_SET: - celltext->strikethrough_set = g_value_get_boolean (value); + priv->strikethrough_set = g_value_get_boolean (value); break; case PROP_UNDERLINE_SET: - celltext->underline_set = g_value_get_boolean (value); + priv->underline_set = g_value_get_boolean (value); break; case PROP_RISE_SET: - celltext->rise_set = g_value_get_boolean (value); + priv->rise_set = g_value_get_boolean (value); break; case PROP_LANGUAGE_SET: @@ -1227,7 +1387,11 @@ gtk_cell_renderer_text_set_property (GObject *object, break; case PROP_ELLIPSIZE_SET: - priv->ellipsize_set = g_value_get_enum (value); + priv->ellipsize_set = g_value_get_boolean (value); + break; + + case PROP_ALIGN_SET: + priv->align_set = g_value_get_boolean (value); break; default: @@ -1268,26 +1432,27 @@ add_attr (PangoAttrList *attr_list, static PangoLayout* get_layout (GtkCellRendererText *celltext, GtkWidget *widget, - gboolean will_render, + const GdkRectangle *cell_area, GtkCellRendererState flags) { + GtkCellRendererTextPrivate *priv = celltext->priv; PangoAttrList *attr_list; PangoLayout *layout; PangoUnderline uline; - GtkCellRendererTextPrivate *priv; + gint xpad; - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (celltext); - - layout = gtk_widget_create_pango_layout (widget, celltext->text); + layout = gtk_widget_create_pango_layout (widget, priv->text); - if (celltext->extra_attrs) - attr_list = pango_attr_list_copy (celltext->extra_attrs); + gtk_cell_renderer_get_padding (GTK_CELL_RENDERER (celltext), &xpad, NULL); + + if (priv->extra_attrs) + attr_list = pango_attr_list_copy (priv->extra_attrs); else attr_list = pango_attr_list_new (); pango_layout_set_single_paragraph_mode (layout, priv->single_paragraph); - if (will_render) + if (cell_area) { /* Add options that affect appearance but not size */ @@ -1295,30 +1460,30 @@ get_layout (GtkCellRendererText *celltext, * background_area not the PangoLayout area */ - if (celltext->foreground_set + if (priv->foreground_set && (flags & GTK_CELL_RENDERER_SELECTED) == 0) { PangoColor color; - color = celltext->foreground; + color = priv->foreground; add_attr (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue)); } - if (celltext->strikethrough_set) + if (priv->strikethrough_set) add_attr (attr_list, - pango_attr_strikethrough_new (celltext->strikethrough)); + pango_attr_strikethrough_new (priv->strikethrough)); } - add_attr (attr_list, pango_attr_font_desc_new (celltext->font)); + add_attr (attr_list, pango_attr_font_desc_new (priv->font)); - if (celltext->scale_set && - celltext->font_scale != 1.0) - add_attr (attr_list, pango_attr_scale_new (celltext->font_scale)); + if (priv->scale_set && + priv->font_scale != 1.0) + add_attr (attr_list, pango_attr_scale_new (priv->font_scale)); - if (celltext->underline_set) - uline = celltext->underline_style; + if (priv->underline_set) + uline = priv->underline_style; else uline = PANGO_UNDERLINE_NONE; @@ -1343,53 +1508,94 @@ get_layout (GtkCellRendererText *celltext, } if (uline != PANGO_UNDERLINE_NONE) - add_attr (attr_list, pango_attr_underline_new (celltext->underline_style)); + add_attr (attr_list, pango_attr_underline_new (priv->underline_style)); - if (celltext->rise_set) - add_attr (attr_list, pango_attr_rise_new (celltext->rise)); + if (priv->rise_set) + add_attr (attr_list, pango_attr_rise_new (priv->rise)); + + /* Now apply the attributes as they will effect the outcome + * of pango_layout_get_extents() */ + pango_layout_set_attributes (layout, attr_list); + pango_attr_list_unref (attr_list); if (priv->ellipsize_set) pango_layout_set_ellipsize (layout, priv->ellipsize); else pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE); - - pango_layout_set_attributes (layout, attr_list); - pango_layout_set_width (layout, -1); - pango_attr_list_unref (attr_list); + if (priv->wrap_width != -1) + { + PangoRectangle rect; + gint width, text_width; + + pango_layout_get_extents (layout, NULL, &rect); + text_width = rect.width; + + if (cell_area) + width = (cell_area->width - xpad * 2) * PANGO_SCALE; + else + width = priv->wrap_width * PANGO_SCALE; + + width = MIN (width, text_width); + + pango_layout_set_width (layout, width); + pango_layout_set_wrap (layout, priv->wrap_mode); + } + else + { + pango_layout_set_width (layout, -1); + pango_layout_set_wrap (layout, PANGO_WRAP_CHAR); + } + + if (priv->align_set) + pango_layout_set_alignment (layout, priv->align); + else + { + PangoAlignment align; + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + align = PANGO_ALIGN_RIGHT; + else + align = PANGO_ALIGN_LEFT; + + pango_layout_set_alignment (layout, align); + } return layout; } + static void -get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - PangoLayout *layout, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) +get_size (GtkCellRenderer *cell, + GtkWidget *widget, + const GdkRectangle *cell_area, + PangoLayout *layout, + gint *x_offset, + gint *y_offset, + gint *width, + gint *height) { - GtkCellRendererText *celltext = (GtkCellRendererText *) cell; + GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (cell); + GtkCellRendererTextPrivate *priv = celltext->priv; PangoRectangle rect; - GtkCellRendererTextPrivate *priv; + gint xpad, ypad; + gint cell_width, cell_height; - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (cell); + gtk_cell_renderer_get_padding (cell, &xpad, &ypad); - if (celltext->calc_fixed_height) + if (priv->calc_fixed_height) { PangoContext *context; PangoFontMetrics *metrics; PangoFontDescription *font_desc; gint row_height; - font_desc = pango_font_description_copy (widget->style->font_desc); - pango_font_description_merge (font_desc, celltext->font, TRUE); + font_desc = pango_font_description_copy_static (gtk_widget_get_style (widget)->font_desc); + pango_font_description_merge_static (font_desc, priv->font, TRUE); - if (celltext->scale_set) + if (priv->scale_set) pango_font_description_set_size (font_desc, - celltext->font_scale * pango_font_description_get_size (font_desc)); + priv->font_scale * pango_font_description_get_size (font_desc)); context = gtk_widget_get_pango_context (widget); @@ -1402,16 +1608,18 @@ get_size (GtkCellRenderer *cell, pango_font_description_free (font_desc); + gtk_cell_renderer_get_fixed_size (cell, &cell_width, &cell_height); + gtk_cell_renderer_set_fixed_size (cell, - cell->width, 2*cell->ypad + - celltext->fixed_height_rows * PANGO_PIXELS (row_height)); + cell_width, 2 * ypad + + priv->fixed_height_rows * PANGO_PIXELS (row_height)); if (height) { - *height = cell->height; + *height = cell_height; height = NULL; } - celltext->calc_fixed_height = FALSE; + priv->calc_fixed_height = FALSE; if (width == NULL) return; } @@ -1419,12 +1627,12 @@ get_size (GtkCellRenderer *cell, if (layout) g_object_ref (layout); else - layout = get_layout (celltext, widget, FALSE, 0); + layout = get_layout (celltext, widget, NULL, 0); pango_layout_get_pixel_extents (layout, NULL, &rect); - + if (height) - *height = GTK_CELL_RENDERER (celltext)->ypad * 2 + rect.height; + *height = ypad * 2 + rect.height; /* The minimum size for ellipsized labels is ~ 3 chars */ if (width) @@ -1436,145 +1644,124 @@ get_size (GtkCellRenderer *cell, gint char_width; context = pango_layout_get_context (layout); - metrics = pango_context_get_metrics (context, widget->style->font_desc, NULL); + metrics = pango_context_get_metrics (context, + gtk_widget_get_style (widget)->font_desc, + pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); pango_font_metrics_unref (metrics); - *width += (PANGO_PIXELS (char_width) * MAX (priv->width_chars, 3)); + *width = xpad * 2 + (PANGO_PIXELS (char_width) * MAX (priv->width_chars, 3)); } else { - *width = GTK_CELL_RENDERER (celltext)->xpad * 2 + rect.width; + *width = xpad * 2 + rect.x + rect.width; } } if (cell_area) { + gfloat xalign, yalign; + + gtk_cell_renderer_get_alignment (cell, &xalign, &yalign); + if (x_offset) { if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - *x_offset = (1.0 - cell->xalign) * (cell_area->width - rect.width - (2 * cell->xpad)); + *x_offset = (1.0 - xalign) * (cell_area->width - (rect.x + rect.width + (2 * xpad))); else - *x_offset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad)); + *x_offset = xalign * (cell_area->width - (rect.x + rect.width + (2 * xpad))); - if (priv->ellipsize) + if ((priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) || priv->wrap_width != -1) *x_offset = MAX(*x_offset, 0); } if (y_offset) { - *y_offset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad)); + *y_offset = yalign * (cell_area->height - (rect.height + (2 * ypad))); *y_offset = MAX (*y_offset, 0); } } + else + { + if (x_offset) *x_offset = 0; + if (y_offset) *y_offset = 0; + } g_object_unref (layout); } - -static void -gtk_cell_renderer_text_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) -{ - get_size (cell, widget, cell_area, NULL, - x_offset, y_offset, width, height); -} - static void gtk_cell_renderer_text_render (GtkCellRenderer *cell, - GdkDrawable *window, + cairo_t *cr, GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, + const GdkRectangle *background_area, + const GdkRectangle *cell_area, GtkCellRendererState flags) { - GtkCellRendererText *celltext = (GtkCellRendererText *) cell; + GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (cell); + GtkCellRendererTextPrivate *priv = celltext->priv; PangoLayout *layout; GtkStateType state; - gint x_offset; - gint y_offset; - GtkCellRendererTextPrivate *priv; - - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (cell); + gint x_offset = 0; + gint y_offset = 0; + gint xpad, ypad; - layout = get_layout (celltext, widget, TRUE, flags); + layout = get_layout (celltext, widget, cell_area, flags); get_size (cell, widget, cell_area, layout, &x_offset, &y_offset, NULL, NULL); - if (!cell->sensitive) + if (!gtk_cell_renderer_get_sensitive (cell)) { state = GTK_STATE_INSENSITIVE; } else if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED) { - if (GTK_WIDGET_HAS_FOCUS (widget)) + if (gtk_widget_has_focus (widget)) state = GTK_STATE_SELECTED; else state = GTK_STATE_ACTIVE; } else if ((flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT && - GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) + gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT) { state = GTK_STATE_PRELIGHT; } else { - if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE) + if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE) state = GTK_STATE_INSENSITIVE; else state = GTK_STATE_NORMAL; } - if (celltext->background_set && + if (priv->background_set && (flags & GTK_CELL_RENDERER_SELECTED) == 0) { - GdkColor color; - GdkGC *gc; - - color.red = celltext->background.red; - color.green = celltext->background.green; - color.blue = celltext->background.blue; - - gc = gdk_gc_new (window); - - gdk_gc_set_rgb_fg_color (gc, &color); - - if (expose_area) - gdk_gc_set_clip_rectangle (gc, expose_area); - gdk_draw_rectangle (window, - gc, - TRUE, - background_area->x, - background_area->y, - background_area->width, - background_area->height); - if (expose_area) - gdk_gc_set_clip_rectangle (gc, NULL); - g_object_unref (gc); + gdk_cairo_rectangle (cr, background_area); + cairo_set_source_rgb (cr, + priv->background.red / 65535., + priv->background.green / 65535., + priv->background.blue / 65535.); + cairo_fill (cr); } - if (priv->ellipsize) + gtk_cell_renderer_get_padding (cell, &xpad, &ypad); + + if (priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) pango_layout_set_width (layout, - (cell_area->width - x_offset - 2 * cell->xpad) * PANGO_SCALE); - else + (cell_area->width - x_offset - 2 * xpad) * PANGO_SCALE); + else if (priv->wrap_width == -1) pango_layout_set_width (layout, -1); - - gtk_paint_layout (widget->style, - window, - state, - TRUE, - expose_area, - widget, - "cellrenderertext", - cell_area->x + x_offset + cell->xpad, - cell_area->y + y_offset + cell->ypad, - layout); + + gtk_paint_layout (gtk_widget_get_style (widget), + cr, + state, + TRUE, + widget, + "cellrenderertext", + cell_area->x + x_offset + xpad, + cell_area->y + y_offset + ypad, + layout); g_object_unref (layout); } @@ -1583,11 +1770,12 @@ static void gtk_cell_renderer_text_editing_done (GtkCellEditable *entry, gpointer data) { + GtkCellRendererTextPrivate *priv; const gchar *path; const gchar *new_text; - GtkCellRendererTextPrivate *priv; + gboolean canceled; - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data); + priv = GTK_CELL_RENDERER_TEXT (data)->priv; priv->entry = NULL; @@ -1609,9 +1797,12 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry, priv->entry_menu_popdown_timeout = 0; } - gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), - GTK_ENTRY (entry)->editing_canceled); - if (GTK_ENTRY (entry)->editing_canceled) + g_object_get (entry, + "editing-canceled", &canceled, + NULL); + gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), canceled); + + if (canceled) return; path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH); @@ -1625,17 +1816,13 @@ popdown_timeout (gpointer data) { GtkCellRendererTextPrivate *priv; - GDK_THREADS_ENTER (); - - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data); + priv = GTK_CELL_RENDERER_TEXT (data)->priv; priv->entry_menu_popdown_timeout = 0; - if (!GTK_WIDGET_HAS_FOCUS (priv->entry)) + if (!gtk_widget_has_focus (priv->entry)) gtk_cell_renderer_text_editing_done (GTK_CELL_EDITABLE (priv->entry), data); - GDK_THREADS_LEAVE (); - return FALSE; } @@ -1645,14 +1832,14 @@ gtk_cell_renderer_text_popup_unmap (GtkMenu *menu, { GtkCellRendererTextPrivate *priv; - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data); + priv = GTK_CELL_RENDERER_TEXT (data)->priv; priv->in_entry_menu = FALSE; if (priv->entry_menu_popdown_timeout) return; - priv->entry_menu_popdown_timeout = g_timeout_add (500, popdown_timeout, + priv->entry_menu_popdown_timeout = gdk_threads_add_timeout (500, popdown_timeout, data); } @@ -1663,7 +1850,7 @@ gtk_cell_renderer_text_populate_popup (GtkEntry *entry, { GtkCellRendererTextPrivate *priv; - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data); + priv = GTK_CELL_RENDERER_TEXT (data)->priv; if (priv->entry_menu_popdown_timeout) { @@ -1684,12 +1871,16 @@ gtk_cell_renderer_text_focus_out_event (GtkWidget *entry, { GtkCellRendererTextPrivate *priv; - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data); + priv = GTK_CELL_RENDERER_TEXT (data)->priv; if (priv->in_entry_menu) return FALSE; - gtk_cell_renderer_text_editing_done (GTK_CELL_EDITABLE (entry), data); + g_object_set (entry, + "editing-canceled", TRUE, + NULL); + gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry)); + gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry)); /* entry needs focus-out-event */ return FALSE; @@ -1700,31 +1891,60 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, + const GdkRectangle *background_area, + const GdkRectangle *cell_area, GtkCellRendererState flags) { + GtkRequisition requisition; GtkCellRendererText *celltext; GtkCellRendererTextPrivate *priv; + gfloat xalign, yalign; celltext = GTK_CELL_RENDERER_TEXT (cell); - priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (cell); + priv = celltext->priv; /* If the cell isn't editable we return NULL. */ - if (celltext->editable == FALSE) + if (priv->editable == FALSE) return NULL; - priv->entry = g_object_new (GTK_TYPE_ENTRY, - "has_frame", FALSE, - "xalign", cell->xalign, - NULL); + gtk_cell_renderer_get_alignment (cell, &xalign, &yalign); - if (celltext->text) - gtk_entry_set_text (GTK_ENTRY (priv->entry), celltext->text); - g_object_set_data_full (G_OBJECT (priv->entry), GTK_CELL_RENDERER_TEXT_PATH, g_strdup (path), g_free); + priv->entry = gtk_entry_new (); + gtk_entry_set_has_frame (GTK_ENTRY (priv->entry), FALSE); + gtk_entry_set_alignment (GTK_ENTRY (priv->entry), xalign); + + if (priv->text) + gtk_entry_set_text (GTK_ENTRY (priv->entry), priv->text); + g_object_set_data_full (G_OBJECT (priv->entry), I_(GTK_CELL_RENDERER_TEXT_PATH), g_strdup (path), g_free); gtk_editable_select_region (GTK_EDITABLE (priv->entry), 0, -1); - + + gtk_widget_get_preferred_size (priv->entry, &requisition, NULL); + if (requisition.height < cell_area->height) + { + GtkBorder *style_border; + GtkBorder border; + + gtk_widget_style_get (priv->entry, + "inner-border", &style_border, + NULL); + + if (style_border) + { + border = *style_border; + g_boxed_free (GTK_TYPE_BORDER, style_border); + } + else + { + /* Since boxed style properties can't have default values ... */ + border.left = 2; + border.right = 2; + } + + border.top = (cell_area->height - requisition.height) / 2; + border.bottom = (cell_area->height - requisition.height) / 2; + gtk_entry_set_inner_border (GTK_ENTRY (priv->entry), &border); + } priv->in_entry_menu = FALSE; if (priv->entry_menu_popdown_timeout) @@ -1734,14 +1954,14 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell, } g_signal_connect (priv->entry, - "editing_done", + "editing-done", G_CALLBACK (gtk_cell_renderer_text_editing_done), celltext); - priv->focus_out_id = g_signal_connect (priv->entry, "focus_out_event", - G_CALLBACK (gtk_cell_renderer_text_focus_out_event), - celltext); + priv->focus_out_id = g_signal_connect_after (priv->entry, "focus-out-event", + G_CALLBACK (gtk_cell_renderer_text_focus_out_event), + celltext); priv->populate_popup_id = - g_signal_connect (priv->entry, "populate_popup", + g_signal_connect (priv->entry, "populate-popup", G_CALLBACK (gtk_cell_renderer_text_populate_popup), celltext); @@ -1767,18 +1987,172 @@ void gtk_cell_renderer_text_set_fixed_height_from_font (GtkCellRendererText *renderer, gint number_of_rows) { + GtkCellRendererTextPrivate *priv; + GtkCellRenderer *cell; + g_return_if_fail (GTK_IS_CELL_RENDERER_TEXT (renderer)); g_return_if_fail (number_of_rows == -1 || number_of_rows > 0); + cell = GTK_CELL_RENDERER (renderer); + priv = renderer->priv; + if (number_of_rows == -1) { - gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (renderer), - GTK_CELL_RENDERER (renderer)->width, - -1); + gint width, height; + + gtk_cell_renderer_get_fixed_size (cell, &width, &height); + gtk_cell_renderer_set_fixed_size (cell, width, -1); + } + else + { + priv->fixed_height_rows = number_of_rows; + priv->calc_fixed_height = TRUE; } +} + +static void +gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell, + GtkWidget *widget, + gint *minimum_size, + gint *natural_size) +{ + GtkCellRendererTextPrivate *priv; + GtkCellRendererText *celltext; + GtkStyle *style; + PangoLayout *layout; + PangoContext *context; + PangoFontMetrics *metrics; + PangoRectangle rect; + gint char_width, digit_width, char_pixels, text_width, ellipsize_chars, guess_width, xpad; + gint min_width, nat_width; + + /* "width-chars" Hard-coded minimum width: + * - minimum size should be MAX (width-chars, strlen ("...")); + * - natural size should be MAX (width-chars, strlen (label->text)); + * + * "wrap-width" User specified natural wrap width + * - minimum size should be MAX (width-chars, 0) + * - natural size should be MIN (wrap-width, strlen (label->text)) + */ + + celltext = GTK_CELL_RENDERER_TEXT (cell); + priv = celltext->priv; + + style = gtk_widget_get_style (widget); + + gtk_cell_renderer_get_padding (cell, &xpad, NULL); + + layout = get_layout (celltext, widget, NULL, 0); + + /* Get the layout with the text possibly wrapping at wrap_width */ + pango_layout_get_pixel_extents (layout, NULL, &rect); + guess_width = rect.width; + + /* Fetch the length of the complete unwrapped text */ + pango_layout_set_width (layout, -1); + pango_layout_get_extents (layout, NULL, &rect); + text_width = rect.width; + + /* Fetch the average size of a charachter */ + context = pango_layout_get_context (layout); + metrics = pango_context_get_metrics (context, style->font_desc, + pango_context_get_language (context)); + + char_width = pango_font_metrics_get_approximate_char_width (metrics); + digit_width = pango_font_metrics_get_approximate_digit_width (metrics); + char_pixels = MAX (char_width, digit_width); + + pango_font_metrics_unref (metrics); + g_object_unref (layout); + + /* enforce minimum width for ellipsized labels at ~3 chars */ + if (priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) + ellipsize_chars = 3; + else + ellipsize_chars = 0; + + if ((priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) || priv->width_chars > 0) + min_width = + xpad * 2 + (PANGO_PIXELS (char_width) * MAX (priv->width_chars, ellipsize_chars)); + /* If no width-chars set, minimum for wrapping text will be the wrap-width */ + else if (priv->wrap_width > -1) + min_width = xpad * 2 + rect.x + priv->wrap_width; else + min_width = xpad * 2 + rect.x + guess_width; + + if (priv->width_chars > 0) + nat_width = xpad * 2 + + MAX ((PANGO_PIXELS (char_width) * priv->width_chars), PANGO_PIXELS (text_width)); + else + nat_width = xpad * 2 + PANGO_PIXELS (text_width); + + nat_width = MAX (nat_width, min_width); + + if (priv->max_width_chars > 0) { - renderer->fixed_height_rows = number_of_rows; - renderer->calc_fixed_height = TRUE; + gint max_width = xpad * 2 + PANGO_PIXELS (char_width) * priv->max_width_chars; + + min_width = MIN (min_width, max_width); + nat_width = MIN (nat_width, max_width); } + + if (minimum_size) + *minimum_size = min_width; + + if (natural_size) + *natural_size = nat_width; + } + +static void +gtk_cell_renderer_text_get_preferred_height_for_width (GtkCellRenderer *cell, + GtkWidget *widget, + gint width, + gint *minimum_height, + gint *natural_height) +{ + GtkCellRendererTextPrivate *priv; + GtkCellRendererText *celltext; + PangoLayout *layout; + gint text_height, xpad, ypad; + + + celltext = GTK_CELL_RENDERER_TEXT (cell); + priv = celltext->priv; + + gtk_cell_renderer_get_padding (cell, &xpad, &ypad); + + layout = get_layout (celltext, widget, NULL, 0); + + pango_layout_set_width (layout, (width - xpad * 2) * PANGO_SCALE); + pango_layout_get_pixel_size (layout, NULL, &text_height); + + if (minimum_height) + *minimum_height = text_height + ypad * 2; + + if (natural_height) + *natural_height = text_height + ypad * 2; + + g_object_unref (layout); +} + +static void +gtk_cell_renderer_text_get_preferred_height (GtkCellRenderer *cell, + GtkWidget *widget, + gint *minimum_size, + gint *natural_size) +{ + gint min_width; + + /* Thankfully cell renderers dont rotate, so they only have to do + * height-for-width and not the opposite. Here we have only to return + * the height for the base minimum width of the renderer. + * + * Note this code path wont be followed by GtkTreeView which is + * height-for-width specifically. + */ + gtk_cell_renderer_get_preferred_width (cell, widget, &min_width, NULL); + gtk_cell_renderer_text_get_preferred_height_for_width (cell, widget, min_width, + minimum_size, natural_size); +} +