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,[])
GTK_DEBUG_TEXT = 1 << 2,
GTK_DEBUG_TREE = 1 << 3,
GTK_DEBUG_UPDATES = 1 << 4,
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
} GtkDebugFlag;
#ifdef G_ENABLE_DEBUG
{"text", GTK_DEBUG_TEXT},
{"tree", GTK_DEBUG_TREE},
{"updates", GTK_DEBUG_UPDATES},
{"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);
};
static const guint gtk_ndebug_keys = sizeof (gtk_debug_keys) / sizeof (GDebugKey);
gdk_colormap_unref (style->colormap);
style->colormap = NULL;
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);
}
}
g_object_unref (style);
}
}
if (state_type == GTK_STATE_INSENSITIVE)
gdk_draw_string (window,
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,
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)
style->fg_gc[state_type], x, y, string);
if (area)
- * gtk_style_get_font_for_display:
- * @display : a #GdkDisplay
* @style: a #GtkStyle
*
* Gets the #GdkFont to use for the given style. This is
* @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
* 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 *
*
* 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)
g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
if (style->private_font && style->private_font_desc)
if (!style->private_font)
{
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"));
+ }
+
- /* 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);
}
style->private_font = gdk_font_from_description_for_display (display, style->font_desc);
style->private_font_desc = pango_font_description_copy (style->font_desc);
}
return style->private_font;
}
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.
/**
* gtk_style_set_font:
* @style: a #GtkStyle.
GtkStyle* gtk_style_ref (GtkStyle *style);
void gtk_style_unref (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);
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 */
void gtk_style_set_font (GtkStyle *style,
GdkFont *font);
#endif /* GTK_DISABLE_DEPRECATED */
#define MARK_CURRENT_FONT(text, mark) \
((MARK_CURRENT_PROPERTY(mark)->flags & PROPERTY_FONT) ? \
MARK_CURRENT_PROPERTY(mark)->font->gdk_font : \
#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 : \
#define MARK_CURRENT_FORE(text, mark) \
((MARK_CURRENT_PROPERTY(mark)->flags & PROPERTY_FOREGROUND) ? \
&MARK_CURRENT_PROPERTY(mark)->fore_color : \
gtk_widget_ensure_style (widget);
if ((widget->style) &&
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);
{
text->use_wchar = TRUE;
g_free (text->text.ch);
if (text->current_font)
text_font_unref (text->current_font);
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));
xthickness = widget->style->xthickness + TEXT_BORDER_ROOM;
ythickness = widget->style->ythickness + TEXT_BORDER_ROOM;
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);
char_height = MIN_TEXT_HEIGHT_LINES * (font->ascent +
font->descent);