Add gtk_label_set_line_wrap_mode, gtk_label_get_line_wrap_mode, and a

2006-06-19  Alexander Larsson  <alexl@redhat.com>

	* gtk/gtk.symbols:
	* gtk/gtklabel.[ch]:
	Add gtk_label_set_line_wrap_mode, gtk_label_get_line_wrap_mode, and
	a wrap-mode property that lets you set the PangoWrapMode.
This commit is contained in:
Alexander Larsson 2006-06-19 14:27:50 +00:00 committed by Alexander Larsson
parent f1191fdf33
commit ff865a441f
7 changed files with 99 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2006-06-19 Alexander Larsson <alexl@redhat.com>
* gtk/gtk.symbols:
* gtk/gtklabel.[ch]:
Add gtk_label_set_line_wrap_mode, gtk_label_get_line_wrap_mode, and
a wrap-mode property that lets you set the PangoWrapMode.
2006-06-19 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprinter-private.h:

View File

@ -1,3 +1,10 @@
2006-06-19 Alexander Larsson <alexl@redhat.com>
* gtk/gtk.symbols:
* gtk/gtklabel.[ch]:
Add gtk_label_set_line_wrap_mode, gtk_label_get_line_wrap_mode, and
a wrap-mode property that lets you set the PangoWrapMode.
2006-06-19 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprinter-private.h:

View File

@ -1,3 +1,8 @@
2006-06-19 Alexander Larsson <alexl@redhat.com>
* gtk/gtk-sections.txt:
Add gtk_label_set_line_wrap_mode and gtk_label_get_line_wrap_mode
2006-06-12 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.3 ===

View File

@ -2008,6 +2008,7 @@ gtk_label_set_max_width_chars
gtk_label_get
gtk_label_parse_uline
gtk_label_set_line_wrap
gtk_label_set_line_wrap_mode
gtk_label_set
gtk_label_get_layout_offsets
gtk_label_get_mnemonic_keyval
@ -2026,6 +2027,7 @@ gtk_label_get_max_width_chars
gtk_label_get_label
gtk_label_get_layout
gtk_label_get_line_wrap
gtk_label_get_line_wrap_mode
gtk_label_get_mnemonic_widget
gtk_label_get_selection_bounds
gtk_label_get_use_markup

View File

@ -1984,6 +1984,7 @@ gtk_label_get_label
gtk_label_get_layout
gtk_label_get_layout_offsets
gtk_label_get_line_wrap
gtk_label_get_line_wrap_mode
gtk_label_get_max_width_chars
gtk_label_get_mnemonic_keyval
gtk_label_get_mnemonic_widget
@ -2004,6 +2005,7 @@ gtk_label_set_ellipsize
gtk_label_set_justify
gtk_label_set_label
gtk_label_set_line_wrap
gtk_label_set_line_wrap_mode
gtk_label_set_markup
gtk_label_set_markup_with_mnemonic
gtk_label_set_max_width_chars

View File

@ -83,6 +83,7 @@ enum {
PROP_JUSTIFY,
PROP_PATTERN,
PROP_WRAP,
PROP_WRAP_MODE,
PROP_SELECTABLE,
PROP_MNEMONIC_KEYVAL,
PROP_MNEMONIC_WIDGET,
@ -340,6 +341,23 @@ gtk_label_class_init (GtkLabelClass *class)
P_("If set, wrap lines if the text becomes too wide"),
FALSE,
GTK_PARAM_READWRITE));
/**
* GtkLabel:wrap-mode:
*
* If line wrapping is on (see the wrap property) this controls how
* the line wrapping is done. The default is %PANGO_WRAP_WORD which means
* wrap on word boundaries.
*
* Since: 2.10
*/
g_object_class_install_property (gobject_class,
PROP_WRAP_MODE,
g_param_spec_enum ("wrap-mode",
P_("Line wrap mode"),
P_("If wrap is set, controls how linewrapping is done"),
PANGO_TYPE_WRAP_MODE,
PANGO_WRAP_WORD,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SELECTABLE,
g_param_spec_boolean ("selectable",
@ -641,6 +659,9 @@ gtk_label_set_property (GObject *object,
case PROP_WRAP:
gtk_label_set_line_wrap (label, g_value_get_boolean (value));
break;
case PROP_WRAP_MODE:
gtk_label_set_line_wrap_mode (label, g_value_get_enum (value));
break;
case PROP_SELECTABLE:
gtk_label_set_selectable (label, g_value_get_boolean (value));
break;
@ -698,6 +719,9 @@ gtk_label_get_property (GObject *object,
case PROP_WRAP:
g_value_set_boolean (value, label->wrap);
break;
case PROP_WRAP_MODE:
g_value_set_enum (value, label->wrap_mode);
break;
case PROP_SELECTABLE:
g_value_set_boolean (value, gtk_label_get_selectable (label));
break;
@ -763,6 +787,7 @@ gtk_label_init (GtkLabel *label)
label->jtype = GTK_JUSTIFY_LEFT;
label->wrap = FALSE;
label->wrap_mode = PANGO_WRAP_WORD;
label->ellipsize = PANGO_ELLIPSIZE_NONE;
label->use_underline = FALSE;
@ -1693,6 +1718,51 @@ gtk_label_get_line_wrap (GtkLabel *label)
return label->wrap;
}
/**
* gtk_label_set_line_wrap_mode:
* @label: a #GtkLabel
* @wrap: the line wrapping mode
*
* If line wrapping is on (see gtk_label_set_line_wrap()) this controls how
* the line wrapping is done. The default is %PANGO_WRAP_WORD which means
* wrap on word boundaries.
*
* Since: 2.10
**/
void
gtk_label_set_line_wrap_mode (GtkLabel *label,
PangoWrapMode wrap_mode)
{
g_return_if_fail (GTK_IS_LABEL (label));
if (label->wrap_mode != wrap_mode)
{
label->wrap_mode = wrap_mode;
g_object_notify (G_OBJECT (label), "wrap-mode");
gtk_widget_queue_resize (GTK_WIDGET (label));
}
}
/**
* gtk_label_get_line_wrap_mode:
* @label: a #GtkLabel
*
* Returns line wrap mode used by the label. See gtk_label_set_line_wrap_mode ().
*
* Return value: %TRUE if the lines of the label are automatically wrapped.
*
* Since: 2.10
*/
PangoWrapMode
gtk_label_get_line_wrap_mode (GtkLabel *label)
{
g_return_val_if_fail (GTK_IS_LABEL (label), FALSE);
return label->wrap_mode;
}
void
gtk_label_get (GtkLabel *label,
gchar **str)
@ -1875,6 +1945,8 @@ gtk_label_ensure_layout (GtkLabel *label)
GtkWidgetAuxInfo *aux_info;
gint longest_paragraph;
gint width, height;
pango_layout_set_wrap (label->layout, label->wrap_mode);
aux_info = _gtk_widget_get_aux_info (widget, FALSE);
if (aux_info && aux_info->width > 0)

View File

@ -61,6 +61,7 @@ struct _GtkLabel
guint single_line_mode : 1;
guint have_transform : 1;
guint in_click : 1;
guint wrap_mode : 3;
guint mnemonic_keyval;
@ -143,6 +144,9 @@ void gtk_label_set_pattern (GtkLabel *label,
void gtk_label_set_line_wrap (GtkLabel *label,
gboolean wrap);
gboolean gtk_label_get_line_wrap (GtkLabel *label);
void gtk_label_set_line_wrap_mode (GtkLabel *label,
PangoWrapMode wrap_mode);
PangoWrapMode gtk_label_get_line_wrap_mode (GtkLabel *label);
void gtk_label_set_selectable (GtkLabel *label,
gboolean setting);
gboolean gtk_label_get_selectable (GtkLabel *label);