[Xfce4-commits] <xfce4-panel:devel> * Use xfce_panel_cairo_set_source_rgba() and remove the previously used function from private.c/h.

Nick Schermer nick at xfce.org
Tue Aug 11 20:22:28 CEST 2009


Updating branch refs/heads/devel
         to 4822294efaf85a4a7b199403dffebea0f16550c4 (commit)
       from 795a2099699180824ed5dad8d27f5cc18647789a (commit)

commit 4822294efaf85a4a7b199403dffebea0f16550c4
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Jun 21 11:19:32 2008 +0200

    * Use xfce_panel_cairo_set_source_rgba() and remove the
      previously used function from private.c/h.

 panel/panel-private.c |   28 ----------------------------
 panel/panel-private.h |    4 ----
 panel/panel-window.c  |   16 ++++++++--------
 3 files changed, 8 insertions(+), 40 deletions(-)

diff --git a/panel/panel-private.c b/panel/panel-private.c
index 3112ac9..e7bac19 100644
--- a/panel/panel-private.c
+++ b/panel/panel-private.c
@@ -73,31 +73,3 @@ _window_set_opacity (GtkWindow *window,
 
 }
 #endif
-
-
-
-void
-_set_source_rgba (cairo_t  *cr,
-                  GdkColor *color,
-                  gdouble   alpha)
-{
-  panel_return_if_fail (alpha >= 0.00 && alpha <= 1.00);
-
-  if (alpha == 1.00)
-    {
-      /* set normal source color */
-      cairo_set_source_rgb (cr,
-                            color->red / 65535.00,
-                            color->green / 65535.00,
-                            color->blue / 65535.00);
-    }
-  else
-    {
-      /* set source color with alpha */
-      cairo_set_source_rgba (cr,
-                             color->red / 65535.00,
-                             color->green / 65535.00,
-                             color->blue / 65535.00,
-                             alpha);
-    }
-}
diff --git a/panel/panel-private.h b/panel/panel-private.h
index d0bf9a1..853b6e5 100644
--- a/panel/panel-private.h
+++ b/panel/panel-private.h
@@ -35,10 +35,6 @@ void _window_set_opacity      (GtkWindow   *window,
                                gdouble      opacity);
 #endif
 
-void _set_source_rgba         (cairo_t     *cr,
-                               GdkColor    *color,
-                               gdouble      alpha);
-
 G_END_DECLS
 
 #endif /* !__PANEL_PRIVATE_H__ */
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 06edc2e..03ed0b2 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -136,7 +136,7 @@ struct _PanelWindow
   /* whether we span monitors */
   guint                span_monitors : 1;
 
-  /* whether the panel has an rgba colormap */
+  /* whether the panel has a rgba colormap */
   guint                is_composited : 1;
 
   /* whether the panel is locked */
@@ -340,6 +340,7 @@ panel_window_expose_event (GtkWidget      *widget,
   cairo_t      *cr;
   GdkColor     *color;
   GtkStateType  state = GTK_STATE_NORMAL;
+  gdouble       alpha = window->is_composited ? window->background_alpha : 1.00;
 
   if (GTK_WIDGET_DRAWABLE (widget))
     {
@@ -350,14 +351,13 @@ panel_window_expose_event (GtkWidget      *widget,
       if (G_UNLIKELY (window->is_active_panel))
         state = GTK_STATE_SELECTED;
 
-      if (window->is_active_panel ||
-          (window->is_composited && window->background_alpha < 1.00))
+      if (alpha < 1.00 || window->is_active_panel)
         {
           /* get the background gdk color */
           color = &(widget->style->bg[state]);
 
           /* set the cairo source color */
-          _set_source_rgba (cr, color, window->background_alpha);
+          xfce_panel_cairo_set_source_rgba (cr, color, alpha);
 
           /* create retangle */
           cairo_rectangle (cr, event->area.x, event->area.y,
@@ -1058,7 +1058,7 @@ panel_window_paint_handle (PanelWindow  *window,
         color = &(widget->style->dark[state]);
 
       /* set source color */
-      _set_source_rgba (cr, color, alpha);
+      xfce_panel_cairo_set_source_rgba (cr, color, alpha);
 
       /* draw the dots */
       for (xx = 0; xx < width; xx += 3)
@@ -1087,7 +1087,7 @@ panel_window_paint_border (PanelWindow  *window,
 
   /* dark color */
   color = &(widget->style->dark[state]);
-  _set_source_rgba (cr, color, alpha);
+  xfce_panel_cairo_set_source_rgba (cr, color, alpha);
 
   /* set start position to bottom left */
   cairo_move_to (cr, alloc->x, alloc->y + alloc->height);
@@ -1103,7 +1103,7 @@ panel_window_paint_border (PanelWindow  *window,
 
   /* light color */
   color = &(widget->style->light[state]);
-  _set_source_rgba (cr, color, alpha);
+  xfce_panel_cairo_set_source_rgba (cr, color, alpha);
 
   /* set start position to bottom left */
   cairo_move_to (cr, alloc->x, alloc->y + alloc->height);
@@ -1503,7 +1503,7 @@ panel_window_set_colormap (PanelWindow *window)
     }
 
   /* set the colormap */
-  if (G_LIKELY (colormap))
+  if (colormap)
     gtk_widget_set_colormap (widget, colormap);
 
   /* restore the window */



More information about the Xfce4-commits mailing list