From dbe841868c0bf3532bf381223ae970f24b9214a3 Mon Sep 17 00:00:00 2001 From: "Eduardo Lima (Etrunko)" Date: Thu, 23 Jun 2016 16:04:34 -0300 Subject: [PATCH] Get rid of deprecated functions to customize widget colors Signed-off-by: Eduardo Lima (Etrunko) --- src/virt-viewer-notebook.c | 25 ++++++++++++++----------- src/virt-viewer-window.c | 10 ---------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/virt-viewer-notebook.c b/src/virt-viewer-notebook.c index 420c914..f02779c 100644 --- a/src/virt-viewer-notebook.c +++ b/src/virt-viewer-notebook.c @@ -71,25 +71,28 @@ static void virt_viewer_notebook_init (VirtViewerNotebook *self) { VirtViewerNotebookPrivate *priv; - GdkRGBA color; self->priv = GET_PRIVATE(self); priv = self->priv; - priv->status = gtk_label_new(""); + /* Check for Gtk+ 3.20 to set the custom colors, because with older versions + * it the background color will not be set correctly, so we will end up with + * the default theme color for background (usually light grey), while the + * foreground text color is white. + */ + if (gtk_check_version(3,20,0) == NULL) { + GtkStyleContext *style = gtk_widget_get_style_context(GTK_WIDGET(self)); + GtkCssProvider *css = gtk_css_provider_new(); + gtk_css_provider_load_from_data(css, "* { background-color: black; color: white; }", -1, NULL); + gtk_style_context_add_provider(style, GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(self), FALSE); gtk_notebook_set_show_border(GTK_NOTEBOOK(self), FALSE); + + priv->status = gtk_label_new(""); gtk_widget_show_all(priv->status); gtk_notebook_append_page(GTK_NOTEBOOK(self), priv->status, NULL); - gdk_rgba_parse(&color, "white"); - /* FIXME: - * This method has been deprecated in 3.16. - * For more details on how to deal with this in the future, please, see: - * https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-override-color - * For the bug report about this deprecated function, please, see: - * https://bugs.freedesktop.org/show_bug.cgi?id=94276 - */ - gtk_widget_override_color(priv->status, GTK_STATE_FLAG_NORMAL, &color); } void diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 1ebb423..c59fff5 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -297,7 +297,6 @@ virt_viewer_window_init (VirtViewerWindow *self) { VirtViewerWindowPrivate *priv; GtkWidget *vbox; - GdkRGBA color; GSList *accels; self->priv = GET_PRIVATE(self); @@ -340,15 +339,6 @@ virt_viewer_window_init (VirtViewerWindow *self) virt_viewer_window_toolbar_setup(self); gtk_box_pack_end(GTK_BOX(vbox), GTK_WIDGET(priv->notebook), TRUE, TRUE, 0); - gdk_rgba_parse(&color, "black"); - /* FIXME: - * This method has been deprecated in 3.16. - * For more details on how to deal with this in the future, please, see: - * https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-override-background-color - * For the bug report about this deprecated function, please, see: - * https://bugs.freedesktop.org/show_bug.cgi?id=94276 - */ - gtk_widget_override_background_color(GTK_WIDGET(priv->notebook), GTK_STATE_FLAG_NORMAL, &color); priv->window = GTK_WIDGET(gtk_builder_get_object(priv->builder, "viewer")); gtk_window_add_accel_group(GTK_WINDOW(priv->window), priv->accel_group); -- 2.5.5