[metacity] don't use deprecated gtk_widget_override_background_color



commit 542a2b49433c4955fe342579aee2a5af614438f7
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Nov 24 17:36:49 2014 +0200

    don't use deprecated gtk_widget_override_background_color

 src/tools/metacity-window-demo.c |   22 +++++++++++++++++++++-
 src/ui/theme-viewer.c            |   26 +++++++++++++++++++++++---
 2 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/src/tools/metacity-window-demo.c b/src/tools/metacity-window-demo.c
index 940e230..888de80 100644
--- a/src/tools/metacity-window-demo.c
+++ b/src/tools/metacity-window-demo.c
@@ -665,6 +665,26 @@ dock_cb (GSimpleAction *action,
 }
 
 static void
+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
 desktop_cb (GSimpleAction *action,
             GVariant      *parameter,
             gpointer       callback_data)
@@ -685,7 +705,7 @@ desktop_cb (GSimpleAction *action,
   desktop_color.blue = 0.65;
   desktop_color.alpha = 1.0;
 
-  gtk_widget_override_background_color (window, 0, &desktop_color);
+  override_background_color (window, &desktop_color);
 
   label = focus_label (window);
 
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index e614521..42245c4 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -357,6 +357,26 @@ menu_contents (void)
   return frame;
 }
 
+static void
+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 GtkWidget*
 border_only_contents (void)
 {
@@ -371,7 +391,7 @@ border_only_contents (void)
   color.green = 0;
   color.blue = 0.6;
   color.alpha = 1.0;
-  gtk_widget_override_background_color (event_box, 0, &color);
+  override_background_color (event_box, &color);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
@@ -517,7 +537,7 @@ preview_collection (int font_size,
   desktop_color.blue = 0.65;
   desktop_color.alpha = 1.0;
 
-  gtk_widget_override_background_color (eventbox, 0, &desktop_color);
+  override_background_color (eventbox, &desktop_color);
 
   i = 0;
   while (i < META_FRAME_TYPE_LAST)
@@ -741,7 +761,7 @@ previews_of_button_layouts (void)
   desktop_color.blue = 0.65;
   desktop_color.alpha = 1.0;
 
-  gtk_widget_override_background_color (eventbox, 0, &desktop_color);
+  override_background_color (eventbox, &desktop_color);
 
   i = 0;
   while (i < BUTTON_LAYOUT_COMBINATIONS)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]