From 62a15f2ae1dd4cec4511775429cd97c99ead303b Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Wed, 17 Dec 2003 23:30:36 +0000 Subject: [PATCH] add a single-paragraph-mode property, use private instance data. (Fixes Thu Dec 18 00:24:32 2003 Kristian Rietveld * 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). --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-4 | 8 ++++++++ ChangeLog.pre-2-6 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ gtk/gtkcellrenderertext.c | 39 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9ea063166e..ac3dd6fd6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Dec 18 00:24:32 2003 Kristian Rietveld + + * 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). + Thu Dec 18 00:07:01 2003 Kristian Rietveld * gtk/gtktreemodel.h (gtk_tree_path_new_root), diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9ea063166e..ac3dd6fd6b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Thu Dec 18 00:24:32 2003 Kristian Rietveld + + * 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). + Thu Dec 18 00:07:01 2003 Kristian Rietveld * gtk/gtktreemodel.h (gtk_tree_path_new_root), diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9ea063166e..ac3dd6fd6b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Thu Dec 18 00:24:32 2003 Kristian Rietveld + + * 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). + Thu Dec 18 00:07:01 2003 Kristian Rietveld * gtk/gtktreemodel.h (gtk_tree_path_new_root), diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9ea063166e..ac3dd6fd6b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Thu Dec 18 00:24:32 2003 Kristian Rietveld + + * 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). + Thu Dec 18 00:07:01 2003 Kristian Rietveld * gtk/gtktreemodel.h (gtk_tree_path_new_root), diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9ea063166e..ac3dd6fd6b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Thu Dec 18 00:24:32 2003 Kristian Rietveld + + * 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). + Thu Dec 18 00:07:01 2003 Kristian Rietveld * gtk/gtktreemodel.h (gtk_tree_path_new_root), 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 */