[gnome-system-log] window: don't use GtkStyle to get a dim color



commit 9c4c0d238833b93019a9d954b74cfa264bf2afba
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Jun 28 22:10:28 2012 -0400

    window: don't use GtkStyle to get a dim color
    
    Use the "dim-label" style class instead

 src/logview-window.c |   33 ++++++++++++++-------------------
 1 files changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/src/logview-window.c b/src/logview-window.c
index 86dbe90..603bfd5 100644
--- a/src/logview-window.c
+++ b/src/logview-window.c
@@ -147,22 +147,28 @@ populate_tag_table (GtkTextTagTable *tag_table)
 
 
 static void
-populate_style_tag_table (GtkStyle *style,
-                          GtkTextTagTable *tag_table)
+populate_style_tag_table (LogviewWindow *logview)
 {
+  GtkTextTagTable *tag_table = logview->priv->tag_table;
   GtkTextTag *tag;
-  GdkColor color;
+  GtkStyleContext *context;
+  GdkRGBA rgba;
 
   tag = gtk_text_tag_table_lookup (tag_table, "gray");
 
   if (tag) {
-    /* FIXME: do we need a way to update the buffer/view? */
     gtk_text_tag_table_remove (tag_table, tag);
   }
 
   tag = gtk_text_tag_new ("gray");
-  color = style->text[GTK_STATE_INSENSITIVE];
-  g_object_set (tag, "foreground-gdk", &color, "foreground-set", TRUE, NULL);
+
+  context = gtk_widget_get_style_context (logview->priv->text_view);
+  gtk_style_context_save (context);
+  gtk_style_context_add_class (context, "dim-label");
+  gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &rgba);
+  gtk_style_context_restore (context);
+
+  g_object_set (tag, "foreground-rgba", &rgba, "foreground-set", TRUE, NULL);
 
   gtk_text_tag_table_add (tag_table, tag);
 }
@@ -1052,17 +1058,6 @@ font_changed_cb (LogviewPrefs *prefs,
   logview_set_font (window, font_name);
 }
 
-static void
-style_set_cb (GtkWidget *widget,
-              GtkStyle *prev,
-              gpointer user_data)
-{
-  LogviewWindow *logview = user_data;
-  GtkStyle *style = gtk_widget_get_style (widget);
-
-  populate_style_tag_table (style, logview->priv->tag_table);
-}
-
 static const struct {
   guint keyval;
   GdkModifierType modifier;
@@ -1297,8 +1292,10 @@ logview_window_init (LogviewWindow *logview)
 
   priv->tag_table = gtk_text_tag_table_new ();
   populate_tag_table (priv->tag_table);
+
   priv->text_view = gtk_text_view_new ();
   g_object_set (priv->text_view, "editable", FALSE, NULL);
+  populate_style_tag_table (logview);
 
   gtk_container_add (GTK_CONTAINER (w), priv->text_view);
   gtk_widget_show (priv->text_view);
@@ -1351,8 +1348,6 @@ logview_window_init (LogviewWindow *logview)
                     G_CALLBACK (font_changed_cb), logview);
   g_signal_connect (priv->manager, "active-changed",
                     G_CALLBACK (active_log_changed_cb), logview);
-  g_signal_connect (logview, "style-set",
-                    G_CALLBACK (style_set_cb), logview);
   g_signal_connect (logview, "key-press-event",
                     G_CALLBACK (key_press_event_cb), logview);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]