[virt-tools-list] [virt-viewer v2 5/5] cleanup: Don't use gtk_widget_modify_{fg, bg}()

Fabiano Fidêncio fidencio at redhat.com
Wed Feb 24 07:04:59 UTC 2016


These function have been deprecated since Gtk 3.0 and is recommended to
use _override_color() and _override_background_color() instead.
As these new functions take a GdkRGBA as parameter, let's use
gdk_rgba_parse() instead of gdk_color_parse().

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 src/virt-viewer-notebook.c | 11 ++++++++---
 src/virt-viewer-window.c   | 11 ++++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/virt-viewer-notebook.c b/src/virt-viewer-notebook.c
index 98b663f..bce77e3 100644
--- a/src/virt-viewer-notebook.c
+++ b/src/virt-viewer-notebook.c
@@ -71,7 +71,7 @@ static void
 virt_viewer_notebook_init (VirtViewerNotebook *self)
 {
     VirtViewerNotebookPrivate *priv;
-    GdkColor color;
+    GdkRGBA color;
 
     self->priv = GET_PRIVATE(self);
     priv = self->priv;
@@ -81,8 +81,13 @@ virt_viewer_notebook_init (VirtViewerNotebook *self)
     gtk_notebook_set_show_border(GTK_NOTEBOOK(self), FALSE);
     gtk_widget_show_all(priv->status);
     gtk_notebook_append_page(GTK_NOTEBOOK(self), priv->status, NULL);
-    gdk_color_parse("white", &color);
-    gtk_widget_modify_fg(priv->status, GTK_STATE_NORMAL, &color);
+    gdk_rgba_parse(&color, "white");
+    /* FIXME:
+     * This method has been depracated 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
+     */
+    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 3da50fb..237bffd 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -293,7 +293,7 @@ virt_viewer_window_init (VirtViewerWindow *self)
 {
     VirtViewerWindowPrivate *priv;
     GtkWidget *vbox;
-    GdkColor color;
+    GdkRGBA color;
     GSList *accels;
 
     self->priv = GET_PRIVATE(self);
@@ -334,8 +334,13 @@ virt_viewer_window_init (VirtViewerWindow *self)
     virt_viewer_window_toolbar_setup(self);
 
     gtk_box_pack_end(GTK_BOX(vbox), priv->layout, TRUE, TRUE, 0);
-    gdk_color_parse("black", &color);
-    gtk_widget_modify_bg(priv->layout, GTK_STATE_NORMAL, &color);
+    gdk_rgba_parse(&color, "black");
+    /* FIXME:
+     * This method has been depracated 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
+     */
+    gtk_widget_override_background_color(priv->layout, 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.0




More information about the virt-tools-list mailing list