Use font from widget's style

master
Yevgen Muntyan 2006-03-27 02:11:07 -06:00
parent 47aaa0569a
commit 5b1a4494f9
4 changed files with 39 additions and 38 deletions

View File

@ -11,7 +11,6 @@ AC_DEFUN([MOO_AC_DEBUG],[
MOO_DEBUG="no"
else
MOO_DEBUG="yes"
MOO_DEBUG="yes"
fi
],[
MOO_DEBUG="no"

View File

@ -70,47 +70,47 @@ moo_term_font_new (PangoContext *ctx)
}
void
moo_term_set_font_from_string (MooTerm *term,
const char *font)
static void
moo_term_update_font (MooTerm *term)
{
PangoFontDescription *font_desc;
PangoFontDescription *font;
GtkWidget *widget = GTK_WIDGET (term);
if (font)
{
font_desc = pango_font_description_from_string (font);
}
else
{
GtkWidget *widget = GTK_WIDGET (term);
gtk_widget_ensure_style (widget);
font_desc =
pango_font_description_copy_static (widget->style->font_desc);
}
_moo_term_init_font_stuff (term);
font = widget->style->font_desc;
g_return_if_fail (font_desc != NULL);
if (!pango_font_description_get_size (font_desc))
if (!pango_font_description_get_size (font))
{
pango_font_description_free (font_desc);
g_return_if_reached ();
}
g_free (term->priv->font->name);
term->priv->font->name = g_strdup (font);
pango_context_set_font_description (term->priv->font->ctx, font_desc);
pango_context_set_font_description (term->priv->font->ctx, font);
font_calculate (term->priv->font);
if (GTK_WIDGET_REALIZED (term))
_moo_term_size_changed (term);
pango_font_description_free (font_desc);
}
void
_moo_term_init_font_stuff (MooTerm *term)
moo_term_set_font_from_string (MooTerm *term,
const char *fontname)
{
PangoFontDescription *font;
g_return_if_fail (MOO_IS_TERM (term));
g_return_if_fail (fontname != NULL);
font = pango_font_description_from_string (fontname);
g_return_if_fail (font != NULL);
gtk_widget_modify_font (GTK_WIDGET (term), font);
pango_font_description_free (font);
}
void
_moo_term_init_font_stuff (MooTerm *term)
{
PangoContext *ctx;
@ -139,7 +139,6 @@ _moo_term_font_free (MooTermFont *font)
if (font)
{
g_object_unref (font->ctx);
g_free (font->name);
g_free (font);
}
}
@ -345,12 +344,16 @@ void
_moo_term_style_set (GtkWidget *widget,
G_GNUC_UNUSED GtkStyle *previous_style)
{
MooTerm *term = MOO_TERM (widget);
g_return_if_fail (widget->style != NULL);
moo_term_set_text_colors (MOO_TERM (widget),
moo_term_set_text_colors (term,
&widget->style->text[GTK_STATE_NORMAL],
&widget->style->text[GTK_STATE_NORMAL],
&widget->style->base[GTK_STATE_NORMAL]);
moo_term_update_text_colors (MOO_TERM (widget));
moo_term_update_text_colors (term);
moo_term_update_font (term);
}

View File

@ -50,7 +50,11 @@ G_BEGIN_DECLS
#define SCROLL_GRANULARITY 3
#define DEFAULT_MONOSPACE_FONT "Monospace 10"
#ifdef MOO_DEBUG
#define DEFAULT_MONOSPACE_FONT "Courier New 11"
#else
#define DEFAULT_MONOSPACE_FONT "Monospace 10"
#endif
typedef enum {
@ -291,7 +295,6 @@ void _moo_term_dsr (MooTerm *term,
struct _MooTermFont {
PangoContext *ctx;
char *name;
guint width;
guint height;
guint ascent;

View File

@ -97,7 +97,7 @@ enum {
};
enum {
PROP_0 = 0,
PROP_0,
PROP_CURSOR_BLINKS,
PROP_FONT_NAME
};
@ -151,7 +151,7 @@ static void moo_term_class_init (MooTermClass *klass)
"font-name",
"font-name",
DEFAULT_MONOSPACE_FONT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
signals[SET_SCROLL_ADJUSTMENTS] =
g_signal_new ("set-scroll-adjustments",
@ -443,10 +443,6 @@ static void moo_term_get_property (GObject *object,
g_value_set_boolean (value, term->priv->cursor_blinks);
break;
case PROP_FONT_NAME:
g_value_set_string (value, term->priv->font->name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;