summaryrefslogtreecommitdiff
path: root/plugins/gtkui/gdkdrawing.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-08 13:30:01 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-08 13:30:01 +0200
commitcb1c025f945fe46dab39b70712cbe4378ae24970 (patch)
tree05d617aa620119d6c424abd23fd2c0da3ab54ed5 /plugins/gtkui/gdkdrawing.c
parent1f411a09c45a3dec70162b916688a8d7e6c16b75 (diff)
port to GTK3 (WIP)
Diffstat (limited to 'plugins/gtkui/gdkdrawing.c')
-rw-r--r--plugins/gtkui/gdkdrawing.c56
1 files changed, 21 insertions, 35 deletions
diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c
index cb795ccb..7c610af8 100644
--- a/plugins/gtkui/gdkdrawing.c
+++ b/plugins/gtkui/gdkdrawing.c
@@ -27,8 +27,8 @@
#include "support.h"
#include "gtkui.h"
-static GdkDrawable *drawable;
-static GdkGC *gc;
+static cairo_t *drawable;
+//static GdkGC *gc;
static GdkColor clrfg;
static GdkColor clrbg;
static int pango_ready;
@@ -36,59 +36,41 @@ static PangoContext *pangoctx;
static PangoLayout *pangolayout;
void
-draw_begin (uintptr_t canvas) {
- drawable = GDK_DRAWABLE (canvas);
- gc = gdk_gc_new (drawable);
+draw_begin (cairo_t *cr) {
+ drawable = cr;
}
void
draw_end (void) {
drawable = NULL;
- if (gc) {
- g_object_unref (gc);
- gc = NULL;
- }
-}
-
-void
-draw_copy (uintptr_t dest_canvas, uintptr_t src_canvas, int dx, int dy, int sx, int sy, int w, int h) {
- gdk_draw_drawable (GDK_DRAWABLE (dest_canvas), gc, GDK_DRAWABLE (src_canvas), dx, dy, sx, sy, w, h);
}
void
-draw_pixbuf (uintptr_t dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h) {
- gdk_draw_pixbuf (GDK_DRAWABLE (dest_canvas), gc, GDK_PIXBUF (pixbuf), sx, sy, dx, dy, w, h, GDK_RGB_DITHER_NONE, 0, 0);
+draw_copy (cairo_t *dest_canvas, cairo_t *src_canvas, int dx, int dy, int sx, int sy, int w, int h) {
+// FIXME gdk_draw_drawable (GDK_DRAWABLE (dest_canvas), gc, GDK_DRAWABLE (src_canvas), dx, dy, sx, sy, w, h);
}
void
-draw_get_canvas_size (uintptr_t canvas, int *w, int *h) {
- gdk_drawable_get_size (GDK_DRAWABLE (canvas), w, h);
+draw_pixbuf (cairo_t *dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h) {
+// FIXME gdk_draw_pixbuf (GDK_DRAWABLE (dest_canvas), gc, GDK_PIXBUF (pixbuf), sx, sy, dx, dy, w, h, GDK_RGB_DITHER_NONE, 0, 0);
}
void
draw_set_fg_color (float *rgb) {
- clrfg.red = rgb[0] * 0xffff;
- clrfg.green = rgb[1] * 0xffff;
- clrfg.blue = rgb[2] * 0xffff;
- gdk_gc_set_rgb_fg_color (gc, &clrfg);
-}
-
-void
-draw_set_bg_color (float *rgb) {
- clrbg.red = rgb[0] * 0xffff;
- clrbg.green = rgb[1] * 0xffff;
- clrbg.blue = rgb[2] * 0xffff;
- gdk_gc_set_rgb_bg_color (gc, &clrbg);
+ cairo_set_source_rgb (drawable, rgb[0], rgb[1], rgb[2]);
}
void
draw_line (float x1, float y1, float x2, float y2) {
- gdk_draw_line (drawable, gc, x1, y1, x2, y2);
+ cairo_move_to (drawable, x1, y1);
+ cairo_move_to (drawable, x2, y2);
+ cairo_stroke (drawable);
}
void
draw_rect (float x, float y, float w, float h, int fill) {
- gdk_draw_rectangle (drawable, gc, fill, x, y, w, h);
+ cairo_rectangle (drawable, x, y, w, h);
+ fill ? cairo_fill (drawable) : cairo_stroke (drawable);
}
static GtkStyle *font_style = NULL;
@@ -165,7 +147,8 @@ draw_text (float x, float y, int width, int align, const char *text) {
pango_layout_set_width (pangolayout, width*PANGO_SCALE);
pango_layout_set_alignment (pangolayout, align ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT);
pango_layout_set_text (pangolayout, text, -1);
- gdk_draw_layout (drawable, gc, x, y, pangolayout);
+ cairo_move_to (drawable, x, y);
+ pango_cairo_show_layout (drawable, pangolayout);
}
void
@@ -174,7 +157,10 @@ draw_text_with_colors (float x, float y, int width, int align, const char *text)
pango_layout_set_width (pangolayout, width*PANGO_SCALE);
pango_layout_set_alignment (pangolayout, align ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT);
pango_layout_set_text (pangolayout, text, -1);
- gdk_draw_layout_with_colors (drawable, gc, x, y, pangolayout, &clrfg, &clrbg);
+// gdk_draw_layout_with_colors (drawable, gc, x, y, pangolayout, &clrfg, &clrbg);
+ cairo_move_to (drawable, x, y);
+ pango_cairo_show_layout (drawable, pangolayout);
+
}
void
@@ -233,7 +219,7 @@ gtkui_init_theme_colors (void) {
override_tabstrip_colors = deadbeef->conf_get_int ("gtkui.override_tabstrip_colors", 0);
extern GtkWidget *mainwin;
- GtkStyle *style = mainwin->style;
+ GtkStyle *style = gtk_widget_get_style (mainwin);
char color_text[100];
const char *clr;