More reliable way to set the fonts from rc style.
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 9 Feb 2009 13:30:15 +0000 (13:30 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 9 Feb 2009 13:30:15 +0000 (13:30 +0000)
pmo-trunk-r7432

src/widgets/modest-account-view.c
src/widgets/modest-folder-view.c
src/widgets/modest-header-view.c

index b4e4765..dc963c2 100644 (file)
@@ -482,37 +482,36 @@ bold_if_default_account_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer
                                    GtkTreeModel *tree_model,  GtkTreeIter *iter,  gpointer user_data)
 {
        gboolean is_default;
-#ifdef MODEST_TOOLKIT_HILDON2
        GtkStyle *style;
        const gchar *font_style;
        PangoAttribute *attr;
        PangoAttrList *attr_list = NULL;
        GtkWidget *widget;
-#endif
+
        gtk_tree_model_get (tree_model, iter, MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN,
                            &is_default, -1);
 
-#ifdef MODEST_TOOLKIT_HILDON2
        widget = gtk_tree_view_column_get_tree_view (column);
        font_style = is_default?"EmpSystemFont":"SystemFont";
        style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (GTK_WIDGET(widget)),
                                           font_style, NULL,
                                           G_TYPE_NONE);
-       attr = pango_attr_font_desc_new (pango_font_description_copy (style->font_desc));
+       if (style) {
+               attr = pango_attr_font_desc_new (pango_font_description_copy (style->font_desc));
 
-       attr_list = pango_attr_list_new ();
-       pango_attr_list_insert (attr_list, attr);
+               attr_list = pango_attr_list_new ();
+               pango_attr_list_insert (attr_list, attr);
 
-       g_object_set (G_OBJECT(renderer),
-                     "attributes", attr_list, 
-                     NULL);
+               g_object_set (G_OBJECT(renderer),
+                             "attributes", attr_list, 
+                             NULL);
 
-       pango_attr_list_unref (attr_list);
-#else
-       g_object_set (G_OBJECT(renderer),
-                     "weight", is_default ? 800: 400,
-                     NULL);
-#endif
+               pango_attr_list_unref (attr_list);
+       } else {
+               g_object_set (G_OBJECT(renderer),
+                             "weight", is_default ? 800: 400,
+                             NULL);
+       }
 }
 
 static void
@@ -520,37 +519,36 @@ bold_if_default_last_updated_cell_data  (GtkTreeViewColumn *column,  GtkCellRend
                                         GtkTreeModel *tree_model,  GtkTreeIter *iter,  gpointer user_data)
 {
        gboolean is_default;
-#ifdef MODEST_TOOLKIT_HILDON2
        GtkStyle *style;
        const gchar *font_style;
        PangoAttribute *attr;
        PangoAttrList *attr_list = NULL;
        GtkWidget *widget;
-#endif
+
        gtk_tree_model_get (tree_model, iter, MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN,
                            &is_default, -1);
 
-#ifdef MODEST_TOOLKIT_HILDON2
        widget = gtk_tree_view_column_get_tree_view (column);
        font_style = is_default?"EmpSmallSystemFont":"SmallSystemFont";
        style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (GTK_WIDGET(widget)),
                                           font_style, NULL,
                                           G_TYPE_NONE);
-       attr = pango_attr_font_desc_new (pango_font_description_copy (style->font_desc));
+       if (style) {
+               attr = pango_attr_font_desc_new (pango_font_description_copy (style->font_desc));
 
-       attr_list = pango_attr_list_new ();
-       pango_attr_list_insert (attr_list, attr);
+               attr_list = pango_attr_list_new ();
+               pango_attr_list_insert (attr_list, attr);
 
-       g_object_set (G_OBJECT(renderer),
-                     "attributes", attr_list, 
-                     NULL);
+               g_object_set (G_OBJECT(renderer),
+                             "attributes", attr_list, 
+                             NULL);
 
-       pango_attr_list_unref (attr_list);
-#else
-       g_object_set (G_OBJECT(renderer),
-                     "weight", is_default ? 800: 400,
-                     NULL);
-#endif
+               pango_attr_list_unref (attr_list);
+       } else {
+               g_object_set (G_OBJECT(renderer),
+                             "weight", is_default ? 800: 400,
+                             NULL);
+       }
 }
 
 static void
index 29cc917..628f449 100644 (file)
@@ -3573,17 +3573,19 @@ update_style (ModestFolderView *self)
        style = gtk_rc_get_style_by_paths (gtk_widget_get_settings
                                           (GTK_WIDGET(self)),
                                           "SmallSystemFont", NULL,
-                                          G_TYPE_NONE);  
-       attr = pango_attr_font_desc_new (pango_font_description_copy
-                                        (style->font_desc));
-       pango_attr_list_insert (attr_list, attr);
-
-       g_object_set (G_OBJECT (priv->messages_renderer),
-                     "foreground-gdk", &style_color,
-                     "foreground-set", TRUE,
-                     "attributes", attr_list,
-                     NULL);
-       pango_attr_list_unref (attr_list);
+                                          G_TYPE_NONE);
+       if (style) {
+               attr = pango_attr_font_desc_new (pango_font_description_copy
+                                                (style->font_desc));
+               pango_attr_list_insert (attr_list, attr);
+
+               g_object_set (G_OBJECT (priv->messages_renderer),
+                             "foreground-gdk", &style_color,
+                             "foreground-set", TRUE,
+                             "attributes", attr_list,
+                             NULL);
+               pango_attr_list_unref (attr_list);
+       }
 }
 
 static void 
index 9ec52e4..25c026b 100644 (file)
@@ -2367,21 +2367,23 @@ update_style (ModestHeaderView *self)
        style = gtk_rc_get_style_by_paths (gtk_widget_get_settings
                                           (GTK_WIDGET(self)),
                                           "SmallSystemFont", NULL,
-                                          G_TYPE_NONE);  
-       attr = pango_attr_font_desc_new (pango_font_description_copy
-                                        (style->font_desc));
-       pango_attr_list_insert (attr_list, attr);
-
-       g_object_set (G_OBJECT (priv->renderer_address),
-                     "foreground-gdk", &style_color,
-                     "foreground-set", TRUE,
-                     "attributes", attr_list,
-                     NULL);
-       g_object_set (G_OBJECT (priv->renderer_date_status),
-                     "foreground-gdk", &style_color,
-                     "foreground-set", TRUE,
-                     "attributes", attr_list,
-                     NULL);
-       pango_attr_list_unref (attr_list);
+                                          G_TYPE_NONE);
+       if (style) {
+               attr = pango_attr_font_desc_new (pango_font_description_copy
+                                                (style->font_desc));
+               pango_attr_list_insert (attr_list, attr);
+
+               g_object_set (G_OBJECT (priv->renderer_address),
+                             "foreground-gdk", &style_color,
+                             "foreground-set", TRUE,
+                             "attributes", attr_list,
+                             NULL);
+               g_object_set (G_OBJECT (priv->renderer_date_status),
+                             "foreground-gdk", &style_color,
+                             "foreground-set", TRUE,
+                             "attributes", attr_list,
+                             NULL);
+               pango_attr_list_unref (attr_list);
+       }
 }