Commit bf87b7c6 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Use pango_layout_get_pixel_extents() to remove a large number of '/

Sun Jul  2 17:06:40 2000  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
	gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
	pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.

	* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
	PANGO_PIXELS() macro.
parent b02ebc65
Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
PANGO_PIXELS() macro.
Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
that returns a PangoContext owned by the widget and updated to
match future changes in the widget. Also, make
gtk_widget_create_pango_layout() use this context. If we ever
add a ::changed signal to PangoContext, this will make things
much more convenient.
* gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
in the appropriate places instead of destroying the layouts and
creating new ones.
* gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
in a few strategic places.
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
......
Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
PANGO_PIXELS() macro.
Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
that returns a PangoContext owned by the widget and updated to
match future changes in the widget. Also, make
gtk_widget_create_pango_layout() use this context. If we ever
add a ::changed signal to PangoContext, this will make things
much more convenient.
* gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
in the appropriate places instead of destroying the layouts and
creating new ones.
* gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
in a few strategic places.
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
......
Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
PANGO_PIXELS() macro.
Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
that returns a PangoContext owned by the widget and updated to
match future changes in the widget. Also, make
gtk_widget_create_pango_layout() use this context. If we ever
add a ::changed signal to PangoContext, this will make things
much more convenient.
* gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
in the appropriate places instead of destroying the layouts and
creating new ones.
* gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
in a few strategic places.
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
......
Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
PANGO_PIXELS() macro.
Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
that returns a PangoContext owned by the widget and updated to
match future changes in the widget. Also, make
gtk_widget_create_pango_layout() use this context. If we ever
add a ::changed signal to PangoContext, this will make things
much more convenient.
* gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
in the appropriate places instead of destroying the layouts and
creating new ones.
* gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
in a few strategic places.
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
......
Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
PANGO_PIXELS() macro.
Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
that returns a PangoContext owned by the widget and updated to
match future changes in the widget. Also, make
gtk_widget_create_pango_layout() use this context. If we ever
add a ::changed signal to PangoContext, this will make things
much more convenient.
* gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
in the appropriate places instead of destroying the layouts and
creating new ones.
* gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
in a few strategic places.
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
......
Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
PANGO_PIXELS() macro.
Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
that returns a PangoContext owned by the widget and updated to
match future changes in the widget. Also, make
gtk_widget_create_pango_layout() use this context. If we ever
add a ::changed signal to PangoContext, this will make things
much more convenient.
* gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
in the appropriate places instead of destroying the layouts and
creating new ones.
* gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
in a few strategic places.
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
......
Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
* gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
PANGO_PIXELS() macro.
Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
that returns a PangoContext owned by the widget and updated to
match future changes in the widget. Also, make
gtk_widget_create_pango_layout() use this context. If we ever
add a ::changed signal to PangoContext, this will make things
much more convenient.
* gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
in the appropriate places instead of destroying the layouts and
creating new ones.
* gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
in a few strategic places.
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
......
......@@ -231,7 +231,7 @@ gtk_accel_label_size_request (GtkWidget *widget,
{
GtkAccelLabel *accel_label;
PangoLayout *layout;
PangoRectangle logical_rect;
gint width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ACCEL_LABEL (widget));
......@@ -244,9 +244,9 @@ gtk_accel_label_size_request (GtkWidget *widget,
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, accel_label->accel_string, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_size (layout, &width, NULL);
accel_label->accel_string_width = width;
accel_label->accel_string_width = logical_rect.width / PANGO_SCALE;
g_object_unref (G_OBJECT (layout));
}
......
......@@ -1182,20 +1182,20 @@ gtk_calendar_size_request (GtkWidget *widget,
for (i = 0; i < 12; i++)
{
pango_layout_set_text (layout, default_monthname[i], -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->max_month_width = MAX (private_data->max_month_width,
logical_rect.width / PANGO_SCALE + 8);
max_header_height = MAX (max_header_height, logical_rect.height / PANGO_SCALE);
logical_rect.width + 8);
max_header_height = MAX (max_header_height, logical_rect.height);
}
private_data->max_year_width = 0;
for (i=0; i<10; i++)
{
sprintf (buffer, "%d%d%d%d", i,i,i,i);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->max_year_width = MAX (private_data->max_year_width,
logical_rect.width / PANGO_SCALE + 8);
max_header_height = MAX (max_header_height, logical_rect.height / PANGO_SCALE);
logical_rect.width + 8);
max_header_height = MAX (max_header_height, logical_rect.height);
}
}
else
......@@ -1220,14 +1220,14 @@ gtk_calendar_size_request (GtkWidget *widget,
{
sprintf (buffer, "%d%d", i, i);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->min_day_width = MAX (private_data->max_day_char_width,
logical_rect.width / PANGO_SCALE);
logical_rect.width);
private_data->max_day_char_ascent = MAX (private_data->max_label_char_ascent,
PANGO_ASCENT (logical_rect) / PANGO_SCALE);
PANGO_ASCENT (logical_rect));
private_data->max_day_char_descent = MAX (private_data->max_label_char_descent,
PANGO_DESCENT (logical_rect) / PANGO_SCALE);
PANGO_DESCENT (logical_rect));
}
/* We add one to max_day_char_width to be able to make the marked day "bold" */
private_data->max_day_char_width = private_data->min_day_width / 2 +1;
......@@ -1236,13 +1236,13 @@ gtk_calendar_size_request (GtkWidget *widget,
for (i = 0; i < 7; i++)
{
pango_layout_set_text (layout, default_abbreviated_dayname[i], -1);
pango_layout_line_get_extents (pango_layout_get_lines (layout)->data, NULL, &logical_rect);
pango_layout_line_get_pixel_extents (pango_layout_get_lines (layout)->data, NULL, &logical_rect);
private_data->min_day_width = MAX (private_data->min_day_width, logical_rect.width / PANGO_SCALE);
private_data->min_day_width = MAX (private_data->min_day_width, logical_rect.width);
private_data->max_label_char_ascent = MAX (private_data->max_label_char_ascent,
PANGO_ASCENT (logical_rect) / PANGO_SCALE);
PANGO_ASCENT (logical_rect));
private_data->max_label_char_descent = MAX (private_data->max_label_char_descent,
PANGO_DESCENT (logical_rect) / PANGO_SCALE);
PANGO_DESCENT (logical_rect));
}
private_data->max_week_char_width = 0;
......@@ -1251,9 +1251,9 @@ gtk_calendar_size_request (GtkWidget *widget,
{
sprintf (buffer, "%d%d", i, i);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->max_week_char_width = MAX (private_data->max_week_char_width,
logical_rect.width / PANGO_SCALE / 2);
logical_rect.width / 2);
}
main_width = (7 * (private_data->min_day_width + DAY_XPAD * 2) + (DAY_XSEP * 6) + CALENDAR_MARGIN * 2
......@@ -1565,19 +1565,19 @@ gtk_calendar_paint_header (GtkWidget *widget)
sprintf (buffer, "%d", calendar->year);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
/* Draw title */
y = (private_data->header_h - logical_rect.height / PANGO_SCALE) / 2;
y = (private_data->header_h - logical_rect.height) / 2;
/* Draw year and its arrows */
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
x = header_width - (3 + max_year_width
- (max_year_width - logical_rect.width / PANGO_SCALE)/2);
- (max_year_width - logical_rect.width)/2);
else
x = header_width - (3 + private_data->arrow_width + max_year_width
- (max_year_width - logical_rect.width / PANGO_SCALE)/2);
- (max_year_width - logical_rect.width)/2);
gdk_gc_set_foreground (gc, HEADER_FG_COLOR (GTK_WIDGET (calendar)));
......@@ -1586,12 +1586,12 @@ gtk_calendar_paint_header (GtkWidget *widget)
/* Draw month */
sprintf (buffer, "%s", default_monthname[calendar->month]);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
x = 3 + (max_month_width - logical_rect.width / PANGO_SCALE) / 2;
x = 3 + (max_month_width - logical_rect.width) / 2;
else
x = 3 + private_data->arrow_width + (max_month_width - logical_rect.width / PANGO_SCALE)/2;
x = 3 + private_data->arrow_width + (max_month_width - logical_rect.width)/2;
gdk_draw_layout (private_data->header_win, gc, x, y, layout);
......@@ -1679,14 +1679,14 @@ gtk_calendar_paint_day_names (GtkWidget *widget)
sprintf (buffer, "%s", default_abbreviated_dayname[day]);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
gdk_draw_layout (private_data->day_name_win, gc,
((private_data->week_width ? CALENDAR_XSEP : CALENDAR_MARGIN)
+ day_wid_sep * i
+ private_data->week_width
+ (day_width - logical_rect.width / PANGO_SCALE)/2),
CALENDAR_MARGIN + DAY_YPAD + private_data->max_label_char_ascent + logical_rect.y / PANGO_SCALE,
+ (day_width - logical_rect.width)/2),
CALENDAR_MARGIN + DAY_YPAD + private_data->max_label_char_ascent + logical_rect.y,
layout);
}
......@@ -1768,12 +1768,12 @@ gtk_calendar_paint_week_numbers (GtkWidget *widget)
sprintf (buffer, "%d", week);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
y_loc = top_y_for_row (calendar, row) + (day_height - logical_rect.height / PANGO_SCALE) / 2;
y_loc = top_y_for_row (calendar, row) + (day_height - logical_rect.height) / 2;
x_loc = (private_data->week_width
- logical_rect.width / PANGO_SCALE
- logical_rect.width
- CALENDAR_XSEP - DAY_XPAD);
gdk_draw_layout (private_data->week_win, gc, x_loc, y_loc, layout);
......@@ -1904,11 +1904,11 @@ gtk_calendar_paint_day (GtkWidget *widget,
sprintf (buffer, "%d", day);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
x_loc -= logical_rect.width / PANGO_SCALE;
x_loc -= logical_rect.width;
y_loc = y_top + (day_height - logical_rect.height / PANGO_SCALE) / 2;
y_loc = y_top + (day_height - logical_rect.height) / 2;
gdk_draw_layout (private_data->main_win, gc,
x_loc, y_loc, layout);
if (calendar->marked_date[day-1]
......
......@@ -2557,10 +2557,10 @@ cell_size_request (GtkCList *clist,
layout = _gtk_clist_create_cell_layout (clist, clist_row, column);
if (layout)
{
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
requisition->width = logical_rect.width / PANGO_SCALE;
requisition->height = logical_rect.height / PANGO_SCALE;
requisition->width = logical_rect.width;
requisition->height = logical_rect.height;
g_object_unref (G_OBJECT (layout));
}
......@@ -3019,7 +3019,7 @@ gtk_clist_set_row_height (GtkCList *clist,
if (widget->style->font_desc)
{
PangoContext *context = gtk_widget_create_pango_context (widget);
PangoContext *context = gtk_widget_get_pango_context (widget);
PangoFontMetrics metrics;
PangoFont *font = pango_context_load_font (context, widget->style->font_desc);
gchar *lang = pango_context_get_lang (context);
......@@ -3028,10 +3028,9 @@ gtk_clist_set_row_height (GtkCList *clist,
g_free (lang);
g_object_unref (G_OBJECT (font));
g_object_unref (G_OBJECT (context));
if (!GTK_CLIST_ROW_HEIGHT_SET(clist))
clist->row_height = (metrics.ascent + metrics.descent) / PANGO_SCALE;
clist->row_height = PANGO_PIXELS (metrics.ascent + metrics.descent);
}
CLIST_REFRESH (clist);
......@@ -5847,8 +5846,8 @@ draw_row (GtkCList *clist,
layout = _gtk_clist_create_cell_layout (clist, clist_row, i);
if (layout)
{
pango_layout_get_extents (layout, NULL, &logical_rect);
width = logical_rect.width / PANGO_SCALE;
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
width = logical_rect.width;
}
else
width = 0;
......@@ -5914,7 +5913,7 @@ draw_row (GtkCList *clist,
case GTK_CELL_TEXT:
if (layout)
{
gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height / PANGO_SCALE - 1) / 2;
gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height - 1) / 2;
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
gdk_draw_layout (clist->clist_window, fg_gc,
......
......@@ -1791,8 +1791,8 @@ draw_row (GtkCList *clist,
layout = _gtk_clist_create_cell_layout (clist, clist_row, i);
if (layout)
{
pango_layout_get_extents (layout, NULL, &logical_rect);
width = logical_rect.width / PANGO_SCALE;
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
width = logical_rect.width;
}
else
width = 0;
......@@ -1872,7 +1872,7 @@ draw_row (GtkCList *clist,
case GTK_CELL_TEXT:
if (layout)
{
gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height / PANGO_SCALE - 1) / 2;
gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height - 1) / 2;
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
gdk_draw_layout (clist->clist_window, fg_gc,
......@@ -1935,7 +1935,7 @@ draw_row (GtkCList *clist,
if (layout)
{
gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height / PANGO_SCALE - 1) / 2;
gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height - 1) / 2;
if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
{
......@@ -2815,10 +2815,10 @@ cell_size_request (GtkCList *clist,
layout = _gtk_clist_create_cell_layout (clist, clist_row, column);
if (layout)
{
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
requisition->width = logical_rect.width / PANGO_SCALE;
requisition->height = logical_rect.height / PANGO_SCALE;
requisition->width = logical_rect.width;
requisition->height = logical_rect.height;
g_object_unref (G_OBJECT (layout));
}
......
......@@ -1975,10 +1975,7 @@ gtk_entry_style_set (GtkWidget *widget,
}
if (entry->layout)
{
g_object_unref (G_OBJECT (entry->layout));
entry->layout = NULL;
}
pango_layout_context_changed (entry->layout);
}
static void
......@@ -1988,10 +1985,7 @@ gtk_entry_direction_changed (GtkWidget *widget,
GtkEntry *entry = GTK_ENTRY (widget);
if (entry->layout)
{
g_object_unref (G_OBJECT (entry->layout));
entry->layout = NULL;
}
pango_layout_context_changed (entry->layout);
GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
}
......
......@@ -178,7 +178,6 @@ gtk_font_selection_init(GtkFontSelection *fontsel)
GtkWidget *text_box;
GtkWidget *table, *label;
fontsel->context = gtk_widget_create_pango_context (GTK_WIDGET (fontsel));
fontsel->font_desc = pango_font_description_from_string ("sans 12");
/* Create the table of font, style & size. */
......@@ -348,7 +347,6 @@ gtk_font_selection_finalize (GObject *object)
fontsel = GTK_FONT_SELECTION (object);
g_object_unref (G_OBJECT (fontsel->context));
pango_font_description_free (fontsel->font_desc);
if (fontsel->font)
......@@ -449,7 +447,8 @@ gtk_font_selection_show_available_fonts (GtkFontSelection *fontsel)
gchar **families;
int n_families, i;
pango_context_list_families (fontsel->context, &families, &n_families);
pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
&families, &n_families);
qsort (families, n_families, sizeof(char *), cmp_strings);
gtk_clist_freeze (GTK_CLIST (fontsel->font_clist));
......@@ -562,7 +561,8 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
gint match_row = 0;
gchar *str;
pango_context_list_fonts (fontsel->context, fontsel->font_desc->family_name, &descs, &n_descs);
pango_context_list_fonts (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
fontsel->font_desc->family_name, &descs, &n_descs);
qsort (descs, n_descs, sizeof(PangoFontDescription *), font_description_sort_func);
gtk_clist_freeze (GTK_CLIST (fontsel->font_style_clist));
......@@ -833,7 +833,8 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
/* Check to make sure that this is in the list of allowed fonts */
pango_context_list_fonts (fontsel->context, new_desc->family_name, &descs, &n_descs);
pango_context_list_fonts (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
new_desc->family_name, &descs, &n_descs);
for (i=0; i<n_descs; i++)
{
......
......@@ -79,7 +79,6 @@ struct _GtkFontSelection
GtkWidget *filter_button;
GtkWidget *preview_entry;
PangoContext *context;
PangoFontDescription *font_desc;
GdkFont *font; /* Cache for gdk_font_selection_get_font, so we can preserve
* refcounting behavior
......
......@@ -169,14 +169,14 @@ gtk_hruler_draw_ticks (GtkRuler *ruler)
xthickness = widget->style->xthickness;
ythickness = widget->style->ythickness;
digit_height = ink_rect.height / PANGO_SCALE + 2;
digit_height = PANGO_PIXELS (ink_rect.height) + 2;
digit_offset = ink_rect.y;
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, "012456789", -1);
pango_layout_get_extents (layout, &ink_rect, &logical_rect);
digit_height = ink_rect.height / PANGO_SCALE + 1;
digit_height = PANGO_PIXELS (ink_rect.height) + 1;
digit_offset = ink_rect.y;
width = widget->allocation.width;
......@@ -263,7 +263,7 @@ gtk_hruler_draw_ticks (GtkRuler *ruler)
pango_layout_get_extents (layout, &logical_rect, NULL);
gdk_draw_layout (ruler->backing_store, gc,
pos + 2, ythickness + (logical_rect.y - digit_offset) / PANGO_SCALE,
pos + 2, ythickness + PANGO_PIXELS (logical_rect.y - digit_offset),
layout);
}
}
......
......@@ -528,7 +528,7 @@ gtk_hscale_draw_value (GtkScale *scale)
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
switch (scale->value_pos)
{
......@@ -536,15 +536,15 @@ gtk_hscale_draw_value (GtkScale *scale)
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width / PANGO_SCALE;
y += (height - logical_rect.height / PANGO_SCALE) / 2;
x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width;
y += (height - logical_rect.height) / 2;
break;
case GTK_POS_RIGHT:
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
x += width + SCALE_CLASS (scale)->value_spacing;
y += (height - logical_rect.height / PANGO_SCALE) / 2;
y += (height - logical_rect.height) / 2;
break;
case GTK_POS_TOP:
gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
......@@ -552,10 +552,10 @@ gtk_hscale_draw_value (GtkScale *scale)
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
x += widget->allocation.x + (width - logical_rect.width / PANGO_SCALE) / 2;
x += widget->allocation.x + (width - logical_rect.width) / 2;
x = CLAMP (x, widget->allocation.x,
widget->allocation.x + widget->allocation.width - logical_rect.width / PANGO_SCALE);
y -= logical_rect.height / PANGO_SCALE;
widget->allocation.x + widget->allocation.width - logical_rect.width);
y -= logical_rect.height;
break;
case GTK_POS_BOTTOM:
gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
......@@ -563,9 +563,9 @@ gtk_hscale_draw_value (GtkScale *scale)
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
x += widget->allocation.x + (width - logical_rect.width / PANGO_SCALE) / 2;
x += widget->allocation.x + (width - logical_rect.width) / 2;
x = CLAMP (x, widget->allocation.x,
widget->allocation.x + widget->allocation.width - logical_rect.width / PANGO_SCALE);
widget->allocation.x + widget->allocation.width - logical_rect.width);
y += height;
break;
}
......
......@@ -443,7 +443,7 @@ gtk_label_size_request (GtkWidget *widget,
pango_layout_get_extents (label->layout, NULL, &logical_rect);
requisition->width += aux_info->width;
requisition->height += logical_rect.height / PANGO_SCALE;
requisition->height += PANGO_PIXELS (logical_rect.height);
}
else
{
......@@ -510,8 +510,8 @@ gtk_label_size_request (GtkWidget *widget,
}
pango_layout_set_width (label->layout, width);
requisition->width += real_width / PANGO_SCALE;
requisition->height += height / PANGO_SCALE;
requisition->width += PANGO_PIXELS (real_width);
requisition->height += PANGO_PIXELS (height);
}
}
else /* !label->wrap */
......@@ -519,8 +519,8 @@ gtk_label_size_request (GtkWidget *widget,
pango_layout_set_width (label->layout, -1);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
requisition->width += logical_rect.width / PANGO_SCALE;
requisition->height += logical_rect.height / PANGO_SCALE;
requisition->width += PANGO_PIXELS (logical_rect.width);
requisition->height += PANGO_PIXELS (logical_rect.height);
}
}
......@@ -535,10 +535,7 @@ gtk_label_style_set (GtkWidget *widget,
label = GTK_LABEL (widget);
if (previous_style && label->layout)
{
g_object_unref (G_OBJECT (label->layout));
label->layout = NULL;
}
pango_layout_context_changed (label->layout);
}
static void
......@@ -548,10 +545,7 @@ gtk_label_direction_changed (GtkWidget *widget,
GtkLabel *label = GTK_LABEL (widget);
if (label->layout)
{
g_object_unref (G_OBJECT (label->layout));
label->layout = NULL;
}
pango_layout_context_changed (label->layout);
GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
}
......
......@@ -365,7 +365,7 @@ gtk_progress_bar_size_request (GtkWidget *widget,
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, buf, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
g_object_unref (G_OBJECT (layout));
g_free (buf);
......@@ -378,11 +378,11 @@ gtk_progress_bar_size_request (GtkWidget *widget,
{
requisition->width = MAX (MIN_HORIZONTAL_BAR_WIDTH,
2 * widget->style->xthickness + 3 +
logical_rect.width / PANGO_SCALE + 2 * TEXT_SPACING);
logical_rect.width + 2 * TEXT_SPACING);
requisition->height = MAX (MIN_HORIZONTAL_BAR_HEIGHT,
2 * widget->style->ythickness + 3 +
logical_rect.height / PANGO_SCALE + 2 * TEXT_SPACING);
logical_rect.height + 2 * TEXT_SPACING);
}
else
{
......@@ -396,11 +396,11 @@ gtk_progress_bar_size_request (GtkWidget *widget,
{
requisition->width = MAX (MIN_VERTICAL_BAR_WIDTH,
2 * widget->style->xthickness + 3 +
logical_rect.width / PANGO_SCALE + 2 * TEXT_SPACING);
logical_rect.width + 2 * TEXT_SPACING);
requisition->height = MAX (MIN_VERTICAL_BAR_HEIGHT,
2 * widget->style->ythickness + 3 +
logical_rect.height / PANGO_SCALE + 2 * TEXT_SPACING);
logical_rect.height + 2 * TEXT_SPACING);
} </