From cb1c025f945fe46dab39b70712cbe4378ae24970 Mon Sep 17 00:00:00 2001 From: waker Date: Sat, 8 Oct 2011 13:30:01 +0200 Subject: port to GTK3 (WIP) --- plugins/gtkui/gdkdrawing.c | 56 +++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) (limited to 'plugins/gtkui/gdkdrawing.c') 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; -- cgit v1.2.3 From 106af524dc03ebebca8602a5df5d5c75ed93c99d Mon Sep 17 00:00:00 2001 From: waker Date: Sat, 8 Oct 2011 17:27:39 +0200 Subject: removed some deprecated code --- plugins/gtkui/ddblistview.c | 46 ++------------------------------------------- plugins/gtkui/ddbtabstrip.c | 3 --- plugins/gtkui/drawing.h | 6 ------ plugins/gtkui/gdkdrawing.c | 10 ---------- 4 files changed, 2 insertions(+), 63 deletions(-) (limited to 'plugins/gtkui/gdkdrawing.c') diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index f81333f4..88dab3cc 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -282,8 +282,7 @@ ddb_listview_class_init(DdbListviewClass *class) { GtkTableClass *widget_class = (GtkTableClass *) class; GObjectClass *object_class = (GObjectClass *) class; - // FIXME!!! - //object_class->destroy = ddb_listview_destroy; + object_class->finalize = ddb_listview_destroy; } static void @@ -831,48 +830,8 @@ ddb_listview_vscroll_value_changed (GtkRange *widget, return; } if (newscroll != ps->scrollpos) { - GtkWidget *widget = ps->list; - int di = newscroll - ps->scrollpos; - int d = abs (di); - GtkAllocation a; - gtk_widget_get_allocation (ps->list, &a); - int height = a.height; - if (d < height) { - if (di > 0) { - // scroll down - // copy scrolled part of buffer -#if !GTK_CHECK_VERSION(3,0,0) - // FIXME - gdk_draw_drawable (ps->list->window, widget->style->black_gc, ps->list->window, 0, d, 0, 0, a.width, a.height-d); -#else -// cairo_region_copy (); -#endif - // redraw other part - int start = height-d-1; - ps->scrollpos = newscroll; - // FIXME gtk_widget_queue_draw_area (ps->list, 0, start, ps->list->allocation.width, widget->allocation.height-start); - } - else { - // scroll up - // copy scrolled part of buffer -#if !GTK_CHECK_VERSION(3,0,0) - // FIXME - gdk_draw_drawable (ps->list->window, widget->style->black_gc, ps->list->window, 0, 0, 0, d, widget->allocation.width, widget->allocation.height-d); -#else -// cairo_region_copy (); -#endif - // redraw other part - ps->scrollpos = newscroll; - // FIXME gtk_widget_queue_draw_area (ps->list, 0, 0, ps->list->allocation.width, d+1); - } - } - else { - // scrolled more than view height, redraw everything - ps->scrollpos = newscroll; - // FIXME gtk_widget_queue_draw (ps->list); - } + ps->scrollpos = newscroll; gtk_widget_queue_draw (ps->list); -// draw_drawable (widget->window, widget->style->black_gc, ps->list->window, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); } } @@ -1289,7 +1248,6 @@ ddb_listview_list_render_row_background (DdbListview *ps, cairo_t *cr, DdbListvi if (theming) { #if !GTK_CHECK_VERSION(3,0,0) - // FIXME if (gtk_widget_get_style (treeview)->depth == -1) { return; // drawing was called too early } diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index 093d5fbb..31812e01 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -231,7 +231,6 @@ ddb_tabstrip_class_init(DdbTabStripClass *class) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); #if !GTK_CHECK_VERSION(3,0,0) -// FIXME? widget_class->expose_event = on_tabstrip_expose_event; #else widget_class->draw = on_tabstrip_draw; @@ -248,8 +247,6 @@ ddb_tabstrip_class_init(DdbTabStripClass *class) widget_class->drag_end = on_tabstrip_drag_end; widget_class->drag_data_received = on_tabstrip_drag_data_received; widget_class->drag_leave = on_tabstrip_drag_leave; - -// FIXME? object_class->destroy = ddb_tabstrip_destroy; } gboolean diff --git a/plugins/gtkui/drawing.h b/plugins/gtkui/drawing.h index fe3850f9..3556ec62 100644 --- a/plugins/gtkui/drawing.h +++ b/plugins/gtkui/drawing.h @@ -35,12 +35,6 @@ draw_begin (cairo_t *cr); void draw_end (void); -void -draw_copy (cairo_t *dest_canvas, cairo_t *src_canvas, int dx, int dy, int sx, int sy, int w, int h); - -void -draw_pixbuf (cairo_t *dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h); - void draw_set_fg_color (float *rgb); diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c index 7c610af8..9a86f2b4 100644 --- a/plugins/gtkui/gdkdrawing.c +++ b/plugins/gtkui/gdkdrawing.c @@ -45,16 +45,6 @@ draw_end (void) { drawable = NULL; } -void -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_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) { cairo_set_source_rgb (drawable, rgb[0], rgb[1], rgb[2]); -- cgit v1.2.3 From 1c89b325521ccd180b4e1248a44f8f25edfc4e0f Mon Sep 17 00:00:00 2001 From: waker Date: Sun, 9 Oct 2011 11:18:40 +0200 Subject: fixed separator line in group titles --- plugins/gtkui/gdkdrawing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/gtkui/gdkdrawing.c') diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c index 9a86f2b4..41967bb8 100644 --- a/plugins/gtkui/gdkdrawing.c +++ b/plugins/gtkui/gdkdrawing.c @@ -53,7 +53,7 @@ draw_set_fg_color (float *rgb) { void draw_line (float x1, float y1, float x2, float y2) { cairo_move_to (drawable, x1, y1); - cairo_move_to (drawable, x2, y2); + cairo_line_to (drawable, x2, y2); cairo_stroke (drawable); } -- cgit v1.2.3