diff options
author | zhuyaliang <[email protected]> | 2023-10-09 09:52:30 +0800 |
---|---|---|
committer | raveit65 <[email protected]> | 2023-10-11 12:02:17 +0200 |
commit | 9df51ef52b7c6e29dd02a1c44d488074893d0c28 (patch) | |
tree | 69857e72ccad8426d06e3b2c2194ac291bf9c7bd | |
parent | 8a4929783cc8720760589caeb5f2263c3dab744b (diff) | |
download | mate-control-center-9df51ef52b7c6e29dd02a1c44d488074893d0c28.tar.bz2 mate-control-center-9df51ef52b7c6e29dd02a1c44d488074893d0c28.tar.xz |
font-viewer: Fix compilation warnings and replace deprecated functions
-rw-r--r-- | font-viewer/font-view.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/font-viewer/font-view.c b/font-viewer/font-view.c index 826369d9..918d0087 100644 --- a/font-viewer/font-view.c +++ b/font-viewer/font-view.c @@ -549,6 +549,46 @@ font_view_ensure_model (FontViewApplication *self) } static void +set_override_background_color (GtkWidget *widget, + GdkRGBA *rgba) +{ + gchar *css; + GtkCssProvider *provider; + + provider = gtk_css_provider_new (); + + css = g_strdup_printf ("* { background-color: %s;}", + gdk_rgba_to_string (rgba)); + gtk_css_provider_load_from_data (provider, css, -1, NULL); + g_free (css); + + gtk_style_context_add_provider (gtk_widget_get_style_context (widget), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); +} + +static void +set_override_color (GtkWidget *widget, + GdkRGBA *rgba) +{ + gchar *css; + GtkCssProvider *provider; + + provider = gtk_css_provider_new (); + + css = g_strdup_printf ("* { color: %s;}", + gdk_rgba_to_string (rgba)); + gtk_css_provider_load_from_data (provider, css, -1, NULL); + g_free (css); + + gtk_style_context_add_provider (gtk_widget_get_style_context (widget), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); +} + +static void font_view_application_do_open (FontViewApplication *self, GFile *file, gint face_index) @@ -587,8 +627,8 @@ font_view_application_do_open (FontViewApplication *self, self->font_widget = GTK_WIDGET (sushi_font_widget_new (uri, face_index)); - gtk_widget_override_color (self->font_widget, GTK_STATE_NORMAL, &black); - gtk_widget_override_background_color (self->font_widget, GTK_STATE_FLAG_NORMAL, &white); + set_override_color (self->font_widget, &black); + set_override_background_color (self->font_widget, &white); w = gtk_viewport_new (NULL, NULL); gtk_viewport_set_shadow_type (GTK_VIEWPORT (w), GTK_SHADOW_NONE); |