[libwnck] WnckPager: remove the deprecated usage of GtkSymbolicColor for good



commit 03fb0b79ecbad2ed890a4f3f58348eea1252c7a5
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Sat Jul 20 19:54:09 2013 +0200

    WnckPager: remove the deprecated usage of GtkSymbolicColor for good
    
    The get_dark_color_for_state function is now replaced by the function
    draw_dark_rectangle that draws a rectangle using darker forground color.

 libwnck/pager.c |   58 +++++++++++++++++++++++++-----------------------------
 1 files changed, 27 insertions(+), 31 deletions(-)
---
diff --git a/libwnck/pager.c b/libwnck/pager.c
index 858880c..c4adf7b 100644
--- a/libwnck/pager.c
+++ b/libwnck/pager.c
@@ -1204,28 +1204,33 @@ workspace_at_point (WnckPager *pager,
 }
 
 static void
-get_dark_color_for_state (GtkStyleContext *context,
-                         GtkStateFlags    state,
-                         GdkRGBA         *dark)
+draw_dark_rectangle (GtkStyleContext *context,
+                     cairo_t *cr,
+                     GtkStateFlags state,
+                     int rx, int ry, int rw, int rh)
 {
-  GdkRGBA           bg;
-  GtkSymbolicColor *c1, *c2;
+  gtk_style_context_save (context);
+
+  gtk_style_context_set_state (context, state);
 
-  gtk_style_context_get_background_color (context, state, &bg);
+  cairo_push_group (cr);
 
-  c1 = gtk_symbolic_color_new_literal (&bg);
+  gtk_render_background (context, cr, rx, ry, rw, rh);
+  cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.3f);
+  cairo_rectangle (cr, rx, ry, rw, rh);
+  cairo_fill (cr);
 
-  c2 = gtk_symbolic_color_new_shade (c1, 0.7);
-  gtk_symbolic_color_resolve (c2, NULL, dark);
-  gtk_symbolic_color_unref (c2);
-  gtk_symbolic_color_unref (c1);
+  cairo_pop_group_to_source (cr);
+  cairo_paint (cr);
+
+  gtk_style_context_restore (context);
 }
 
 static void
 wnck_pager_draw_workspace (WnckPager    *pager,
                            cairo_t      *cr,
-                          int           workspace,
-                          GdkRectangle *rect,
+                           int           workspace,
+                           GdkRectangle *rect,
                            GdkPixbuf    *bg_pixbuf)
 {
   GList *windows;
@@ -1264,10 +1269,8 @@ wnck_pager_draw_workspace (WnckPager    *pager,
     {
       if (!wnck_workspace_is_virtual (space))
         {
-          get_dark_color_for_state (context, state, &color);
-          gdk_cairo_set_source_rgba (cr, &color);
-          cairo_rectangle (cr, rect->x, rect->y, rect->width, rect->height);
-          cairo_fill (cr);
+          draw_dark_rectangle (context, cr, state,
+                               rect->x, rect->y, rect->width, rect->height);
         }
       else
         {
@@ -1328,18 +1331,15 @@ wnck_pager_draw_workspace (WnckPager    *pager,
                     {
                       /* "+ j" is for the thin lines */
                       vy = rect->y + (height_ratio * screen_height) * j + j;
+                      GtkStateFlags rec_state = GTK_STATE_FLAG_NORMAL;
 
                       if (j == verti_views - 1)
                         vh = rect->height + rect->y - vy;
 
                       if (active_i == i && active_j == j)
-                       get_dark_color_for_state (context, GTK_STATE_FLAG_SELECTED, &color);
-                     else
-                       get_dark_color_for_state (context, GTK_STATE_FLAG_NORMAL, &color);
+                        rec_state = GTK_STATE_FLAG_SELECTED;
 
-                     gdk_cairo_set_source_rgba (cr, &color);
-                      cairo_rectangle (cr, vx, vy, vw, vh);
-                      cairo_fill (cr);
+                      draw_dark_rectangle (context, cr, rec_state, vx, vy, vw, vh);
                     }
                 }
             }
@@ -1349,10 +1349,8 @@ wnck_pager_draw_workspace (WnckPager    *pager,
               height_ratio = rect->height / (double) workspace_height;
 
               /* first draw non-active part of the viewport */
-             get_dark_color_for_state (context, GTK_STATE_FLAG_NORMAL, &color);
-              gdk_cairo_set_source_rgba (cr, &color);
-              cairo_rectangle (cr, rect->x, rect->y, rect->width, rect->height);
-              cairo_fill (cr);
+              draw_dark_rectangle (context, cr, GTK_STATE_FLAG_NORMAL,
+                                   rect->x, rect->y, rect->width, rect->height);
 
               if (is_current)
                 {
@@ -1364,10 +1362,8 @@ wnck_pager_draw_workspace (WnckPager    *pager,
                   vw = width_ratio * screen_width;
                   vh = height_ratio * screen_height;
 
-                 get_dark_color_for_state (context, GTK_STATE_FLAG_SELECTED, &color);
-                  gdk_cairo_set_source_rgba (cr, &color);
-                  cairo_rectangle (cr, vx, vy, vw, vh);
-                  cairo_fill (cr);
+                  draw_dark_rectangle (context, cr, GTK_STATE_FLAG_SELECTED,
+                                       vx, vy, vw, vh);
                 }
             }
         }


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