[gnome-system-log] window: ensure we actually set a monospace font description
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-log] window: ensure we actually set a monospace font description
- Date: Fri, 29 Jun 2012 01:56:31 +0000 (UTC)
commit 55d71d51e43dbe72b0a5f92f9a17c1325f10b0fd
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Jun 28 21:52:15 2012 -0400
window: ensure we actually set a monospace font description
We were calling gtk_widget_modify_font() with the monospace font
description and then immediately calling
gtk_widget_create_pango_context() to query its pango description,
assuming it was the same we just set.
Since this assumption is not true anymore with recent GTK, own the
monospace pango description ourselves and always query from that.
src/logview-window.c | 36 +++++++++++++++++-------------------
1 files changed, 17 insertions(+), 19 deletions(-)
---
diff --git a/src/logview-window.c b/src/logview-window.c
index a3477c9..86dbe90 100644
--- a/src/logview-window.c
+++ b/src/logview-window.c
@@ -43,6 +43,8 @@ struct _LogviewWindowPrivate {
GtkActionGroup *action_group;
GtkActionGroup *filter_action_group;
+ PangoFontDescription *monospace_description;
+
GtkWidget *find_bar;
GtkWidget *loglist;
GtkWidget *sidebar;
@@ -229,29 +231,30 @@ static void
logview_set_font (LogviewWindow *logview,
const char *fontname)
{
- PangoFontDescription *font_desc;
+ LogviewWindowPrivate *priv = logview->priv;
if (fontname == NULL)
fontname = DEFAULT_LOGVIEW_FONT;
- font_desc = pango_font_description_from_string (fontname);
- if (font_desc) {
- gtk_widget_modify_font (logview->priv->text_view, font_desc);
- pango_font_description_free (font_desc);
- }
+ if (priv->monospace_description != NULL)
+ pango_font_description_free (priv->monospace_description);
+
+ priv->monospace_description = pango_font_description_from_string (fontname);
+ gtk_widget_override_font (priv->text_view, priv->monospace_description);
+
+ /* remember the original font size */
+ priv->original_fontsize =
+ pango_font_description_get_size (priv->monospace_description) / PANGO_SCALE;
}
static void
logview_set_fontsize (LogviewWindow *logview, gboolean store)
{
- PangoFontDescription *fontdesc;
- PangoContext *context;
LogviewWindowPrivate *priv = logview->priv;
- context = gtk_widget_get_pango_context (priv->text_view);
- fontdesc = pango_context_get_font_description (context);
- pango_font_description_set_size (fontdesc, (priv->fontsize) * PANGO_SCALE);
- gtk_widget_modify_font (priv->text_view, fontdesc);
+ pango_font_description_set_size (priv->monospace_description,
+ (priv->fontsize) * PANGO_SCALE);
+ gtk_widget_override_font (priv->text_view, priv->monospace_description);
if (store) {
logview_prefs_store_fontsize (logview->priv->prefs, priv->fontsize);
@@ -1186,6 +1189,8 @@ logview_window_finalize (GObject *object)
LogviewWindow *logview = LOGVIEW_WINDOW (object);
g_object_unref (logview->priv->ui_manager);
+ pango_font_description_free (logview->priv->monospace_description);
+
G_OBJECT_CLASS (logview_window_parent_class)->finalize (object);
}
@@ -1196,8 +1201,6 @@ logview_window_init (LogviewWindow *logview)
GtkAccelGroup *accel_group;
GError *error = NULL;
GtkWidget *hpaned, *main_view, *vbox, *w;
- PangoContext *context;
- PangoFontDescription *fontdesc;
gchar *monospace_font_name;
LogviewWindowPrivate *priv;
int width, height;
@@ -1305,11 +1308,6 @@ logview_window_init (LogviewWindow *logview)
logview_set_font (logview, monospace_font_name);
g_free (monospace_font_name);
- /* remember the original font size */
- context = gtk_widget_get_pango_context (priv->text_view);
- fontdesc = pango_context_get_font_description (context);
- priv->original_fontsize = pango_font_description_get_size (fontdesc) / PANGO_SCALE;
-
/* restore saved zoom */
priv->fontsize = logview_prefs_get_stored_fontsize (priv->prefs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]