diff options
author | Kristian Rietveld <kris@gtk.org> | 2003-12-17 23:30:36 +0000 |
---|---|---|
committer | Kristian Rietveld <kristian@src.gnome.org> | 2003-12-17 23:30:36 +0000 |
commit | 62a15f2ae1dd4cec4511775429cd97c99ead303b (patch) | |
tree | c32187ba385fbd273a59ea8a546c026c4d2f8048 /gtk/gtkcellrenderertext.c | |
parent | 4891296311189f4b7121fc6a43c0b343fc6b77a1 (diff) | |
download | gtk+-62a15f2ae1dd4cec4511775429cd97c99ead303b.tar.gz |
add a single-paragraph-mode property, use private instance data. (Fixes
Thu Dec 18 00:24:32 2003 Kristian Rietveld <kris@gtk.org>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_class_init),
(gtk_cell_renderer_text_get_property),
(gtk_cell_renderer_text_set_property), (get_layout): add a
single-paragraph-mode property, use private instance data.
(Fixes #114943, reported by Morten Welinder).
Diffstat (limited to 'gtk/gtkcellrenderertext.c')
-rw-r--r-- | gtk/gtkcellrenderertext.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 52ab1f4edb..ac87f35f62 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -71,6 +71,7 @@ enum { PROP_TEXT, PROP_MARKUP, PROP_ATTRIBUTES, + PROP_SINGLE_PARAGRAPH_MODE, /* Style args */ PROP_BACKGROUND, @@ -113,6 +114,15 @@ 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; +}; + + GType gtk_cell_renderer_text_get_type (void) { @@ -192,6 +202,15 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) _("A list of style attributes to apply to the text of the renderer"), PANGO_TYPE_ATTR_LIST, G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_SINGLE_PARAGRAPH_MODE, + g_param_spec_boolean ("single_paragraph_mode", + _("Single Paragraph Mode"), + _("Whether or not to keep all text in a single paragraph"), + FALSE, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_BACKGROUND, @@ -421,6 +440,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) G_TYPE_STRING, G_TYPE_STRING); + g_type_class_add_private (object_class, sizeof (GtkCellRendererTextPrivate)); } static void @@ -468,6 +488,9 @@ 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); switch (param_id) { @@ -479,6 +502,10 @@ gtk_cell_renderer_text_get_property (GObject *object, g_value_set_boxed (value, celltext->extra_attrs); break; + case PROP_SINGLE_PARAGRAPH_MODE: + g_value_set_boolean (value, priv->single_paragraph); + break; + case PROP_BACKGROUND_GDK: { GdkColor color; @@ -801,6 +828,9 @@ 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); switch (param_id) { @@ -851,6 +881,10 @@ gtk_cell_renderer_text_set_property (GObject *object, celltext->extra_attrs = attrs; } break; + + case PROP_SINGLE_PARAGRAPH_MODE: + priv->single_paragraph = g_value_get_boolean (value); + break; case PROP_BACKGROUND: { @@ -1102,6 +1136,9 @@ get_layout (GtkCellRendererText *celltext, PangoAttrList *attr_list; PangoLayout *layout; PangoUnderline uline; + GtkCellRendererTextPrivate *priv; + + priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (celltext); layout = gtk_widget_create_pango_layout (widget, celltext->text); @@ -1110,6 +1147,8 @@ get_layout (GtkCellRendererText *celltext, else attr_list = pango_attr_list_new (); + pango_layout_set_single_paragraph_mode (layout, priv->single_paragraph); + if (will_render) { /* Add options that affect appearance but not size */ |