[Xfce4-commits] <ristretto:master> Make monitor border-color themable
Stephan Arts
noreply at xfce.org
Mon Nov 28 19:44:04 CET 2011
Updating branch refs/heads/master
to e202ad2fa4d84fdd29fe3c5374628c61328d479b (commit)
from 6a7f20474768aedab0c6ce59d700550d41800405 (commit)
commit e202ad2fa4d84fdd29fe3c5374628c61328d479b
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Nov 28 19:41:05 2011 +0100
Make monitor border-color themable
src/monitor_chooser.c | 65 +++++++++++++++++++++++++++++++-----------------
1 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/src/monitor_chooser.c b/src/monitor_chooser.c
index f18b770..1600100 100644
--- a/src/monitor_chooser.c
+++ b/src/monitor_chooser.c
@@ -29,8 +29,7 @@
typedef struct {
gint width;
gint height;
-
- cairo_surface_t *image_surface;
+ GdkPixbuf *pixbuf;
} Monitor;
typedef struct {
@@ -75,7 +74,8 @@ static void
cb_rstto_button_press_event (GtkWidget *, GdkEventButton *event);
static void
-paint_monitor ( cairo_t *cr,
+paint_monitor ( GtkWidget *widget,
+ cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
@@ -279,7 +279,9 @@ rstto_monitor_chooser_paint(GtkWidget *widget)
}
label = g_strdup_printf("%d", id+1);
cairo_save (ctx);
- paint_monitor (ctx,
+ paint_monitor (
+ widget,
+ ctx,
((gdouble)widget->allocation.width/4) - (width/2.0),
((gdouble)widget->allocation.height - height)/2.0,
width,
@@ -308,7 +310,9 @@ rstto_monitor_chooser_paint(GtkWidget *widget)
label = g_strdup_printf("%d", id+1);
cairo_save (ctx);
- paint_monitor (ctx,
+ paint_monitor (
+ widget,
+ ctx,
((gdouble)widget->allocation.width/2)+
(((gdouble)widget->allocation.width/2)/
(row_width+1))*(id%(row_width)+1)-
@@ -344,7 +348,9 @@ rstto_monitor_chooser_paint(GtkWidget *widget)
width = 200;
}
cairo_save (ctx);
- paint_monitor (ctx,
+ paint_monitor (
+ widget,
+ ctx,
((gdouble)widget->allocation.width - width)/2.0,
((gdouble)widget->allocation.height - height)/2.0,
width,
@@ -362,7 +368,8 @@ rstto_monitor_chooser_paint(GtkWidget *widget)
}
static void
-paint_monitor ( cairo_t *cr,
+paint_monitor ( GtkWidget *widget,
+ cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
@@ -405,6 +412,8 @@ paint_monitor ( cairo_t *cr,
/*******************************************/
PangoLayout *layout;
PangoFontDescription *font_description;
+ GdkPixbuf *dst_pixbuf = NULL;
+ GdkColor *fg_color = &(widget->style->fg[GTK_STATE_NORMAL]);
g_return_if_fail (NULL != monitor);
@@ -420,15 +429,15 @@ paint_monitor ( cairo_t *cr,
cairo_pattern_add_color_stop_rgb (
monitor_pattern,
0.0,
- 0.4,
- 0.4,
- 0.4);
+ ((gdouble)fg_color->red / 65535.0)+0.4,
+ ((gdouble)fg_color->green / 65535.0)+0.4,
+ ((gdouble)fg_color->blue / 65535.0)+0.4);
cairo_pattern_add_color_stop_rgb (
monitor_pattern,
1.0,
- 0.0,
- 0.0,
- 0.0);
+ ((gdouble)fg_color->red / 65535.0)-0.4,
+ ((gdouble)fg_color->green / 65535.0)-0.4,
+ ((gdouble)fg_color->blue / 65535.0)-0.4);
cairo_new_sub_path (cr);
cairo_arc (
cr,
@@ -533,18 +542,18 @@ paint_monitor ( cairo_t *cr,
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
cairo_fill_preserve (cr);
- if (monitor->image_surface)
+ if (monitor->pixbuf)
{
cairo_clip_preserve (cr);
- hscale = monitor_width / (cairo_image_surface_get_width(monitor->image_surface));
- vscale = monitor_height / (cairo_image_surface_get_height(monitor->image_surface));
+ hscale = monitor_width / (gdk_pixbuf_get_width(monitor->pixbuf));
+ vscale = monitor_height / (gdk_pixbuf_get_height(monitor->pixbuf));
cairo_scale (cr, hscale, vscale);
- cairo_set_source_surface (
+ gdk_cairo_set_source_pixbuf (
cr,
- monitor->image_surface,
+ monitor->pixbuf,
monitor_x/hscale,
monitor_y/vscale);
cairo_paint(cr);
@@ -553,6 +562,12 @@ paint_monitor ( cairo_t *cr,
cairo_scale (cr, 1/hscale, 1/vscale);
}
+ if (NULL != dst_pixbuf)
+ {
+ g_object_unref (dst_pixbuf);
+ dst_pixbuf = NULL;
+ }
+
if (FALSE == active)
{
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
@@ -639,10 +654,10 @@ rstto_monitor_chooser_add (
}
gint
-rstto_monitor_chooser_set_image_surface (
+rstto_monitor_chooser_set_pixbuf (
RsttoMonitorChooser *chooser,
gint monitor_id,
- cairo_surface_t *surface,
+ GdkPixbuf *pixbuf,
GError **error)
{
Monitor *monitor;
@@ -654,13 +669,17 @@ rstto_monitor_chooser_set_image_surface (
if (monitor)
{
- if (monitor->image_surface)
+ if (monitor->pixbuf)
{
- cairo_surface_destroy(monitor->image_surface);
+ g_object_unref (monitor->pixbuf);
}
- monitor->image_surface = surface;
+ monitor->pixbuf = pixbuf;
+ if (monitor->pixbuf)
+ {
+ g_object_ref (monitor->pixbuf);
+ }
retval = monitor_id;
}
if (GTK_WIDGET_REALIZED (GTK_WIDGET(chooser)))
More information about the Xfce4-commits
mailing list