@@ -506,6 +506,51 @@ static PangoFontDescription* get_system_monospace_font(void)
506
506
return desc ;
507
507
}
508
508
509
+ static void
510
+ override_widget_font (GtkWidget * widget ,
511
+ PangoFontDescription * font )
512
+ {
513
+ static gboolean provider_added = FALSE;
514
+ GtkCssProvider * provider ;
515
+ gchar * css ;
516
+ gchar * family ;
517
+ gchar * weight ;
518
+ const gchar * style ;
519
+ gchar * size ;
520
+
521
+ family = g_strdup_printf ("font-family: %s;" , pango_font_description_get_family (font ));
522
+
523
+ weight = g_strdup_printf ("font-weight: %d;" , pango_font_description_get_weight (font ));
524
+
525
+ if (pango_font_description_get_style (font ) == PANGO_STYLE_NORMAL )
526
+ style = "font-style: normal;" ;
527
+ else if (pango_font_description_get_style (font ) == PANGO_STYLE_ITALIC )
528
+ style = "font-style: italic;" ;
529
+ else
530
+ style = "font-style: oblique;" ;
531
+
532
+ size = g_strdup_printf ("font-size: %d%s;" ,
533
+ pango_font_description_get_size (font ) / PANGO_SCALE ,
534
+ pango_font_description_get_size_is_absolute (font ) ? "px" : "pt" );
535
+
536
+ provider = gtk_css_provider_get_default ();
537
+
538
+ css = g_strdup_printf ("textview { %s %s %s %s }" , family , weight , style , size );
539
+ gtk_css_provider_load_from_data (provider , css , -1 , NULL );
540
+
541
+ if (!provider_added ) {
542
+ gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (widget ),
543
+ GTK_STYLE_PROVIDER (provider ),
544
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION );
545
+ provider_added = TRUE;
546
+ }
547
+
548
+ g_free (css );
549
+ g_free (family );
550
+ g_free (weight );
551
+ g_free (size );
552
+ }
553
+
509
554
void mateweather_dialog_update (MateWeatherDialog * dialog )
510
555
{
511
556
MateWeatherDialogPrivate * priv ;
@@ -546,7 +591,7 @@ void mateweather_dialog_update(MateWeatherDialog* dialog)
546
591
if (gw_applet -> mateweather_pref .location -> zone_valid ) {
547
592
font_desc = get_system_monospace_font ();
548
593
if (font_desc ) {
549
- gtk_widget_override_font (priv -> forecast_text , font_desc );
594
+ override_widget_font (priv -> forecast_text , font_desc );
550
595
pango_font_description_free (font_desc );
551
596
}
552
597
0 commit comments