Commit 0c2240ba authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

Add a 'text' argument to set the initial text.

Sun Jul  2 18:19:50 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
	set the initial text.

	* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
	gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
	gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
	gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().

	* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
	pango_layout_set_font_description to simplify.
parent 4e09f86e
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
set the initial text.
* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
pango_layout_set_font_description to simplify.
Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com> Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new * gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
......
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
set the initial text.
* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
pango_layout_set_font_description to simplify.
Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com> Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new * gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
......
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
set the initial text.
* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
pango_layout_set_font_description to simplify.
Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com> Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new * gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
......
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
set the initial text.
* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
pango_layout_set_font_description to simplify.
Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com> Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new * gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
......
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
set the initial text.
* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
pango_layout_set_font_description to simplify.
Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com> Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new * gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
......
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
set the initial text.
* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
pango_layout_set_font_description to simplify.
Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com> Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new * gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
......
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to
set the initial text.
* gtk/gtkaccellabel.c gtk/gtkcalendar.c gtk/gtkclist.c
gtk/gtkentry.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvruler.c
gtk/gtkvscale.c: Adapt to new argument of create_pango_layout().
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
pango_layout_set_font_description to simplify.
Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com> Sun Jul 2 17:43:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new * gtk/gtkclist.c (_gtk_clist_create_cell_layout): Use new
......
...@@ -242,8 +242,7 @@ gtk_accel_label_size_request (GtkWidget *widget, ...@@ -242,8 +242,7 @@ gtk_accel_label_size_request (GtkWidget *widget,
if (GTK_WIDGET_CLASS (parent_class)->size_request) if (GTK_WIDGET_CLASS (parent_class)->size_request)
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
pango_layout_set_text (layout, accel_label->accel_string, -1);
pango_layout_get_pixel_size (layout, &width, NULL); pango_layout_get_pixel_size (layout, &width, NULL);
accel_label->accel_string_width = width; accel_label->accel_string_width = width;
...@@ -288,8 +287,7 @@ gtk_accel_label_expose_event (GtkWidget *widget, ...@@ -288,8 +287,7 @@ gtk_accel_label_expose_event (GtkWidget *widget,
(widget->requisition.height - misc->ypad * 2)) * (widget->requisition.height - misc->ypad * 2)) *
misc->yalign) + 1.5; misc->yalign) + 1.5;
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
pango_layout_set_text (layout, accel_label->accel_string, -1);
if (GTK_WIDGET_STATE (accel_label) == GTK_STATE_INSENSITIVE) if (GTK_WIDGET_STATE (accel_label) == GTK_STATE_INSENSITIVE)
gdk_draw_layout (widget->window, gdk_draw_layout (widget->window,
......
...@@ -1168,7 +1168,7 @@ gtk_calendar_size_request (GtkWidget *widget, ...@@ -1168,7 +1168,7 @@ gtk_calendar_size_request (GtkWidget *widget,
calendar = GTK_CALENDAR (widget); calendar = GTK_CALENDAR (widget);
private_data = GTK_CALENDAR_PRIVATE_DATA (widget); private_data = GTK_CALENDAR_PRIVATE_DATA (widget);
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, NULL);
/* /*
* Calculate the requisition width for the widget. * Calculate the requisition width for the widget.
...@@ -1561,10 +1561,8 @@ gtk_calendar_paint_header (GtkWidget *widget) ...@@ -1561,10 +1561,8 @@ gtk_calendar_paint_header (GtkWidget *widget)
0, 0, header_width, private_data->header_h); 0, 0, header_width, private_data->header_h);
layout = gtk_widget_create_pango_layout (widget);
sprintf (buffer, "%d", calendar->year); sprintf (buffer, "%d", calendar->year);
pango_layout_set_text (layout, buffer, -1); layout = gtk_widget_create_pango_layout (widget, buffer);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
/* Draw title */ /* Draw title */
...@@ -1668,7 +1666,7 @@ gtk_calendar_paint_day_names (GtkWidget *widget) ...@@ -1668,7 +1666,7 @@ gtk_calendar_paint_day_names (GtkWidget *widget)
* Write the labels * Write the labels
*/ */
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, NULL);
gdk_gc_set_foreground (gc, &widget->style->fg[GTK_STATE_SELECTED]); gdk_gc_set_foreground (gc, &widget->style->fg[GTK_STATE_SELECTED]);
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
...@@ -1752,7 +1750,7 @@ gtk_calendar_paint_week_numbers (GtkWidget *widget) ...@@ -1752,7 +1750,7 @@ gtk_calendar_paint_week_numbers (GtkWidget *widget)
* Write the labels * Write the labels
*/ */
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, NULL);
gdk_gc_set_foreground (gc, &widget->style->fg[GTK_STATE_SELECTED]); gdk_gc_set_foreground (gc, &widget->style->fg[GTK_STATE_SELECTED]);
day_height = row_height (calendar); day_height = row_height (calendar);
...@@ -1900,10 +1898,8 @@ gtk_calendar_paint_day (GtkWidget *widget, ...@@ -1900,10 +1898,8 @@ gtk_calendar_paint_day (GtkWidget *widget,
} }
layout = gtk_widget_create_pango_layout (widget);
sprintf (buffer, "%d", day); sprintf (buffer, "%d", day);
pango_layout_set_text (layout, buffer, -1); layout = gtk_widget_create_pango_layout (widget, buffer);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
x_loc -= logical_rect.width; x_loc -= logical_rect.width;
......
...@@ -2500,7 +2500,6 @@ _gtk_clist_create_cell_layout (GtkCList *clist, ...@@ -2500,7 +2500,6 @@ _gtk_clist_create_cell_layout (GtkCList *clist,
GtkCListRow *clist_row, GtkCListRow *clist_row,
gint column) gint column)
{ {
PangoContext *context;
PangoLayout *layout; PangoLayout *layout;
GtkStyle *style; GtkStyle *style;
GtkCell *cell; GtkCell *cell;
...@@ -2522,11 +2521,11 @@ _gtk_clist_create_cell_layout (GtkCList *clist, ...@@ -2522,11 +2521,11 @@ _gtk_clist_create_cell_layout (GtkCList *clist,
if (!text) if (!text)
return NULL; return NULL;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (clist)); layout = gtk_widget_create_pango_layout (GTK_WIDGET (clist),
((cell->type == GTK_CELL_PIXTEXT) ?
GTK_CELL_PIXTEXT (*cell)->text :
GTK_CELL_TEXT (*cell)->text));
pango_layout_set_font_description (layout, style->font_desc); pango_layout_set_font_description (layout, style->font_desc);
pango_layout_set_text (layout, ((cell->type == GTK_CELL_PIXTEXT) ?
GTK_CELL_PIXTEXT (*cell)->text :
GTK_CELL_TEXT (*cell)->text), -1);
return layout; return layout;
......
...@@ -1165,7 +1165,7 @@ gtk_entry_ensure_layout (GtkEntry *entry) ...@@ -1165,7 +1165,7 @@ gtk_entry_ensure_layout (GtkEntry *entry)
if (!entry->layout) if (!entry->layout)
{ {
entry->layout = gtk_widget_create_pango_layout (widget); entry->layout = gtk_widget_create_pango_layout (widget, NULL);
pango_layout_set_text (entry->layout, entry->text, entry->n_bytes); pango_layout_set_text (entry->layout, entry->text, entry->n_bytes);
} }
} }
......
...@@ -172,8 +172,7 @@ gtk_hruler_draw_ticks (GtkRuler *ruler) ...@@ -172,8 +172,7 @@ gtk_hruler_draw_ticks (GtkRuler *ruler)
digit_height = PANGO_PIXELS (ink_rect.height) + 2; digit_height = PANGO_PIXELS (ink_rect.height) + 2;
digit_offset = ink_rect.y; digit_offset = ink_rect.y;
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, "012456789");
pango_layout_set_text (layout, "012456789", -1);
pango_layout_get_extents (layout, &ink_rect, &logical_rect); pango_layout_get_extents (layout, &ink_rect, &logical_rect);
digit_height = PANGO_PIXELS (ink_rect.height) + 1; digit_height = PANGO_PIXELS (ink_rect.height) + 1;
......
...@@ -525,9 +525,7 @@ gtk_hscale_draw_value (GtkScale *scale) ...@@ -525,9 +525,7 @@ gtk_hscale_draw_value (GtkScale *scale)
PangoRectangle logical_rect; PangoRectangle logical_rect;
sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value); sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value);
layout = gtk_widget_create_pango_layout (widget, buffer);
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
switch (scale->value_pos) switch (scale->value_pos)
......
...@@ -400,12 +400,11 @@ gtk_label_size_request (GtkWidget *widget, ...@@ -400,12 +400,11 @@ gtk_label_size_request (GtkWidget *widget,
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */ PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
PangoAttrList *attrs = gtk_label_pattern_to_attrs (label); PangoAttrList *attrs = gtk_label_pattern_to_attrs (label);
label->layout = gtk_widget_create_pango_layout (widget); label->layout = gtk_widget_create_pango_layout (widget, label->label);
pango_layout_set_attributes (label->layout, attrs); pango_layout_set_attributes (label->layout, attrs);
pango_attr_list_unref (attrs); pango_attr_list_unref (attrs);
pango_layout_set_text (label->layout, label->label, -1);
switch (label->jtype) switch (label->jtype)
{ {
case GTK_JUSTIFY_LEFT: case GTK_JUSTIFY_LEFT:
......
...@@ -363,8 +363,7 @@ gtk_progress_bar_size_request (GtkWidget *widget, ...@@ -363,8 +363,7 @@ gtk_progress_bar_size_request (GtkWidget *widget,
{ {
buf = gtk_progress_get_text_from_value (progress, progress->adjustment->upper); buf = gtk_progress_get_text_from_value (progress, progress->adjustment->upper);
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, buf);
pango_layout_set_text (layout, buf, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
g_object_unref (G_OBJECT (layout)); g_object_unref (G_OBJECT (layout));
...@@ -710,8 +709,7 @@ gtk_progress_bar_paint (GtkProgress *progress) ...@@ -710,8 +709,7 @@ gtk_progress_bar_paint (GtkProgress *progress)
buf = gtk_progress_get_current_text (progress); buf = gtk_progress_get_current_text (progress);
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, buf);
pango_layout_set_text (layout, buf, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
x = widget->style->xthickness + 1 + x = widget->style->xthickness + 1 +
......
...@@ -280,7 +280,7 @@ gtk_scale_get_value_size (GtkScale *scale, ...@@ -280,7 +280,7 @@ gtk_scale_get_value_size (GtkScale *scale,
range = GTK_RANGE (scale); range = GTK_RANGE (scale);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale)); layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL);
value = ABS (range->adjustment->lower); value = ABS (range->adjustment->lower);
if (value == 0) value = 1; if (value == 0) value = 1;
......
...@@ -167,8 +167,7 @@ gtk_vruler_draw_ticks (GtkRuler *ruler) ...@@ -167,8 +167,7 @@ gtk_vruler_draw_ticks (GtkRuler *ruler)
xthickness = widget->style->xthickness; xthickness = widget->style->xthickness;
ythickness = widget->style->ythickness; ythickness = widget->style->ythickness;
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, "012456789");
pango_layout_set_text (layout, "012456789", -1);
pango_layout_get_extents (layout, &ink_rect, &logical_rect); pango_layout_get_extents (layout, &ink_rect, &logical_rect);
digit_height = PANGO_PIXELS (ink_rect.height) + 2; digit_height = PANGO_PIXELS (ink_rect.height) + 2;
......
...@@ -530,8 +530,7 @@ gtk_vscale_draw_value (GtkScale *scale) ...@@ -530,8 +530,7 @@ gtk_vscale_draw_value (GtkScale *scale)
sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value); sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value);
layout = gtk_widget_create_pango_layout (widget); layout = gtk_widget_create_pango_layout (widget, buffer);
pango_layout_set_text (layout, buffer, strlen (buffer));
pango_layout_get_pixel_extents (layout, NULL, &logical_rect); pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
switch (scale->value_pos) switch (scale->value_pos)
......
...@@ -3293,6 +3293,7 @@ gtk_widget_create_pango_context (GtkWidget *widget) ...@@ -3293,6 +3293,7 @@ gtk_widget_create_pango_context (GtkWidget *widget)
/** /**
* gtk_widget_create_pango_layout: * gtk_widget_create_pango_layout:
* @widget: a #PangoWidget * @widget: a #PangoWidget
* @text: text to set on the layout (can be %NULL)
* *
* Create a new #PangoLayout with the appropriate colormap, * Create a new #PangoLayout with the appropriate colormap,
* font description, and base direction for drawing text for * font description, and base direction for drawing text for
...@@ -3306,7 +3307,8 @@ gtk_widget_create_pango_context (GtkWidget *widget) ...@@ -3306,7 +3307,8 @@ gtk_widget_create_pango_context (GtkWidget *widget)
* Return value: the new #PangoLayout * Return value: the new #PangoLayout
**/ **/
PangoLayout * PangoLayout *
gtk_widget_create_pango_layout (GtkWidget *widget) gtk_widget_create_pango_layout (GtkWidget *widget,
const gchar *text)
{ {
PangoLayout *layout; PangoLayout *layout;
PangoContext *context; PangoContext *context;
...@@ -3316,6 +3318,9 @@ gtk_widget_create_pango_layout (GtkWidget *widget) ...@@ -3316,6 +3318,9 @@ gtk_widget_create_pango_layout (GtkWidget *widget)
context = gtk_widget_get_pango_context (widget); context = gtk_widget_get_pango_context (widget);
layout = pango_layout_new (context); layout = pango_layout_new (context);
if (text)
pango_layout_set_text (layout, text, -1);
return layout; return layout;
} }
......
...@@ -575,9 +575,10 @@ void gtk_widget_restore_default_style (GtkWidget *widget); ...@@ -575,9 +575,10 @@ void gtk_widget_restore_default_style (GtkWidget *widget);
void gtk_widget_modify_style (GtkWidget *widget, void gtk_widget_modify_style (GtkWidget *widget,
GtkRcStyle *style); GtkRcStyle *style);
PangoContext *gtk_widget_create_pango_context (GtkWidget *widget); PangoContext *gtk_widget_create_pango_context (GtkWidget *widget);
PangoContext *gtk_widget_get_pango_context (GtkWidget *widget); PangoContext *gtk_widget_get_pango_context (GtkWidget *widget);
PangoLayout *gtk_widget_create_pango_layout (GtkWidget *widget); PangoLayout *gtk_widget_create_pango_layout (GtkWidget *widget,
const gchar *text);
/* handle composite names for GTK_COMPOSITE_CHILD widgets, /* handle composite names for GTK_COMPOSITE_CHILD widgets,
* the returned name is newly allocated. * the returned name is newly allocated.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment