[virt-tools-list] [virt-viewer 5/5] cleanup: Don't use gtk_widget_modify_fg()
Jonathon Jongsma
jjongsma at redhat.com
Tue Feb 23 17:08:44 UTC 2016
On Tue, 2016-02-23 at 15:24 +0100, Fabiano Fidêncio wrote:
> This function has been deprecated since Gtk 3.0 and is recommended to
> use gtk_widget_override_color() instead.
> As the new function takes a GdkRGBA as parameter, let's use
> gdk_rgba_parse() instead of gdk_color_parse().
> ---
> src/virt-viewer-notebook.c | 6 +++---
> src/virt-viewer-window.c | 6 +++---
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/virt-viewer-notebook.c b/src/virt-viewer-notebook.c
> index 98b663f..0c3ab72 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,8 @@ 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");
> + 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..e7ec109 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,8 @@ 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");
> + gtk_widget_override_color(priv->layout, GTK_STATE_FLAG_NORMAL, &color);
This should probably be gtk_widget_override_background_color(). *However*, i
just noticed that these functions are also deprecated since 3.16:
"gtk_widget_override_color has been deprecated since version 3.16 and should
not be used in newly-written code.Use a custom style provider and style
classes instead"
>
> priv->window = GTK_WIDGET(gtk_builder_get_object(priv->builder,
> "viewer"));
> gtk_window_add_accel_group(GTK_WINDOW(priv->window), priv->accel_group);
Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com>
More information about the virt-tools-list
mailing list