Commit 4b47bcb3 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Get rid of gtk_style_get_font_for_display(), make gtk_style_get_font()

Thu Jun 20 15:17:14 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkstyle.[ch]: Get rid of gtk_style_get_font_for_display(),
        make gtk_style_get_font() warn for multihead if called
        on an unattached style.

        * gtk/gtktext.c: Remove use of gtk_style_get_font_for_display();
        this makes gtktext not multihead safe, but it doesn't matter;
        it's ENABLE_BROKEN anyways.

        * gtk/gtkmain.c gtk/gtkdebug.h: Add GTK_NOTE(MULTIHEAD,[])
parent 49be7176
......@@ -37,7 +37,8 @@ typedef enum {
GTK_DEBUG_TEXT = 1 << 2,
GTK_DEBUG_TREE = 1 << 3,
GTK_DEBUG_UPDATES = 1 << 4,
GTK_DEBUG_KEYBINDINGS = 1 << 5
GTK_DEBUG_KEYBINDINGS = 1 << 5,
GTK_DEBUG_MULTIHEAD = 1 << 6
} GtkDebugFlag;
#ifdef G_ENABLE_DEBUG
......
......@@ -150,7 +150,8 @@ static const GDebugKey gtk_debug_keys[] = {
{"text", GTK_DEBUG_TEXT},
{"tree", GTK_DEBUG_TREE},
{"updates", GTK_DEBUG_UPDATES},
{"keybindings", GTK_DEBUG_KEYBINDINGS}
{"keybindings", GTK_DEBUG_KEYBINDINGS},
{"multihead", GTK_DEBUG_MULTIHEAD}
};
static const guint gtk_ndebug_keys = sizeof (gtk_debug_keys) / sizeof (GDebugKey);
......
......@@ -811,7 +811,19 @@ gtk_style_detach (GtkStyle *style)
gdk_colormap_unref (style->colormap);
style->colormap = NULL;
if (style->private_font_desc)
{
if (style->private_font)
{
gdk_font_unref (style->private_font);
style->private_font = NULL;
}
pango_font_description_free (style->private_font_desc);
style->private_font_desc = NULL;
}
g_object_unref (style);
}
}
......@@ -3110,11 +3122,11 @@ gtk_default_draw_string (GtkStyle *style,
if (state_type == GTK_STATE_INSENSITIVE)
gdk_draw_string (window,
gtk_style_get_font_for_display (display, style),
gtk_style_get_font (style),
style->white_gc, x + 1, y + 1, string);
gdk_draw_string (window,
gtk_style_get_font_for_display (display, style),
gtk_style_get_font (style),
style->fg_gc[state_type], x, y, string);
if (area)
......@@ -5599,24 +5611,21 @@ gtk_border_get_type (void)
}
/**
* gtk_style_get_font_for_display:
* @display : a #GdkDisplay
* gtk_style_get_font:
* @style: a #GtkStyle
*
* Gets the #GdkFont to use for the given style. This is
* meant only as a replacement for direct access to style->font
* meant only as a replacement for direct access to @style->font
* and should not be used in new code. New code should
* use style->font_desc instead.
* use @style->font_desc instead.
*
* Return value: the #GdkFont for the style. This font is owned
* by the style; if you want to keep around a copy, you must
* call gdk_font_ref().
**/
GdkFont *
gtk_style_get_font_for_display (GdkDisplay *display,
GtkStyle *style)
gtk_style_get_font (GtkStyle *style)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
if (style->private_font && style->private_font_desc)
......@@ -5637,9 +5646,21 @@ gtk_style_get_font_for_display (GdkDisplay *display,
if (!style->private_font)
{
GdkDisplay *display;
if (style->colormap)
{
display = gdk_screen_get_display (gdk_colormap_get_screen (style->colormap));
}
else
{
display = gdk_get_default_display ();
GTK_NOTE (MULTIHEAD,
g_warning ("gtk_style_get_font() should not be called on an unattached style"));
}
if (style->font_desc)
{
/* no colormap, no screen */
style->private_font = gdk_font_from_description_for_display (display, style->font_desc);
style->private_font_desc = pango_font_description_copy (style->font_desc);
}
......@@ -5654,27 +5675,6 @@ gtk_style_get_font_for_display (GdkDisplay *display,
return style->private_font;
}
/**
* gtk_style_get_font:
* @style: a #GtkStyle
*
* Gets the #GdkFont to use for the given style. This is
* meant only as a replacement for direct access to @style->font
* and should not be used in new code. New code should
* use @style->font_desc instead.
*
* Return value: the #GdkFont for the style. This font is owned
* by the style; if you want to keep around a copy, you must
* call gdk_font_ref().
**/
GdkFont *
gtk_style_get_font (GtkStyle *style)
{
g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
return gtk_style_get_font_for_display (gdk_get_default_display (), style);
}
/**
* gtk_style_set_font:
* @style: a #GtkStyle.
......
......@@ -435,11 +435,7 @@ void gtk_style_detach (GtkStyle *style);
GtkStyle* gtk_style_ref (GtkStyle *style);
void gtk_style_unref (GtkStyle *style);
#ifndef GDK_MULTIHEAD_SAFE
GdkFont * gtk_style_get_font (GtkStyle *style);
#endif
GdkFont * gtk_style_get_font_for_display (GdkDisplay *display,
GtkStyle *style);
void gtk_style_set_font (GtkStyle *style,
GdkFont *font);
#endif /* GTK_DISABLE_DEPRECATED */
......
......@@ -73,8 +73,7 @@
#define MARK_CURRENT_FONT(text, mark) \
((MARK_CURRENT_PROPERTY(mark)->flags & PROPERTY_FONT) ? \
MARK_CURRENT_PROPERTY(mark)->font->gdk_font : \
gtk_style_get_font_for_display (gtk_widget_get_display (GTK_WIDGET (text)), \
GTK_WIDGET (text)->style))
gtk_style_get_font (GTK_WIDGET (text)->style))
#define MARK_CURRENT_FORE(text, mark) \
((MARK_CURRENT_PROPERTY(mark)->flags & PROPERTY_FOREGROUND) ? \
&MARK_CURRENT_PROPERTY(mark)->fore_color : \
......@@ -1000,7 +999,7 @@ gtk_text_insert (GtkText *text,
gtk_widget_ensure_style (widget);
if ((widget->style) &&
(gtk_style_get_font_for_display (gtk_widget_get_display (widget), widget->style)->type == GDK_FONT_FONTSET))
(gtk_style_get_font (widget->style)->type == GDK_FONT_FONTSET))
{
text->use_wchar = TRUE;
g_free (text->text.ch);
......@@ -1410,7 +1409,7 @@ gtk_text_style_set (GtkWidget *widget,
if (text->current_font)
text_font_unref (text->current_font);
text->current_font = get_text_font (gtk_style_get_font_for_display (gtk_widget_get_display (widget), widget->style));
text->current_font = get_text_font (gtk_style_get_font (widget->style));
}
static void
......@@ -1574,8 +1573,7 @@ gtk_text_size_request (GtkWidget *widget,
xthickness = widget->style->xthickness + TEXT_BORDER_ROOM;
ythickness = widget->style->ythickness + TEXT_BORDER_ROOM;
font = gtk_style_get_font_for_display (gtk_widget_get_display (widget),
widget->style);
font = gtk_style_get_font (widget->style);
char_height = MIN_TEXT_HEIGHT_LINES * (font->ascent +
font->descent);
......
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