From b4c4a924121c3aa6b2f1eb7570dd3f419d2f4d83 Mon Sep 17 00:00:00 2001 From: Vladimir Nadvornik Date: Thu, 2 Aug 2012 00:15:16 +0200 Subject: [PATCH] use cairo for drawing cairo is the only supported drawing method in gtk3 --- src/bar_exif.c | 9 ++ src/bar_histogram.c | 26 ++++++ src/cellrenderericon.c | 110 +++++++++++++++++++--- src/cellrenderericon.h | 2 - src/collect-table.c | 44 ++++++--- src/dnd.c | 6 +- src/image.c | 13 ++- src/layout.c | 29 ++++-- src/layout_image.c | 2 +- src/logwindow.c | 6 +- src/main.c | 1 + src/options.c | 2 +- src/pixbuf-renderer.c | 44 ++++++++- src/pixbuf-renderer.h | 6 +- src/pixbuf_util.c | 1 - src/rcfile.c | 2 + src/renderer-tiles.c | 204 ++++++++++++++++++++++++++++++++++------- src/renderer-tiles.h | 3 - src/ui_bookmark.c | 3 +- src/ui_misc.c | 11 ++- src/ui_tree_edit.c | 4 + 21 files changed, 434 insertions(+), 94 deletions(-) diff --git a/src/bar_exif.c b/src/bar_exif.c index e07a4917..069bc441 100644 --- a/src/bar_exif.c +++ b/src/bar_exif.c @@ -712,6 +712,7 @@ static void bar_pane_exif_destroy(GtkWidget *widget, gpointer data) g_free(ped); } +#if !GTK_CHECK_VERSION(3,0,0) static void bar_pane_exif_size_request(GtkWidget *pane, GtkRequisition *requisition, gpointer data) { PaneExifData *ped = data; @@ -720,11 +721,15 @@ static void bar_pane_exif_size_request(GtkWidget *pane, GtkRequisition *requisit requisition->height = ped->min_height; } } +#endif static void bar_pane_exif_size_allocate(GtkWidget *pane, GtkAllocation *alloc, gpointer data) { PaneExifData *ped = data; ped->min_height = alloc->height; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_size_request(ped->widget, -1, ped->min_height); +#endif } static GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolean expanded) @@ -751,8 +756,12 @@ static GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolea g_object_set_data(G_OBJECT(ped->widget), "pane_data", ped); g_signal_connect_after(G_OBJECT(ped->widget), "destroy", G_CALLBACK(bar_pane_exif_destroy), ped); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_size_request(ped->widget, -1, ped->min_height); +#else g_signal_connect(G_OBJECT(ped->widget), "size-request", G_CALLBACK(bar_pane_exif_size_request), ped); +#endif g_signal_connect(G_OBJECT(ped->widget), "size-allocate", G_CALLBACK(bar_pane_exif_size_allocate), ped); diff --git a/src/bar_histogram.c b/src/bar_histogram.c index a0659a8b..01f68319 100644 --- a/src/bar_histogram.c +++ b/src/bar_histogram.c @@ -144,6 +144,26 @@ static void bar_pane_histogram_notify_cb(FileData *fd, NotifyType type, gpointer } } +#if GTK_CHECK_VERSION(3,0,0) +static gboolean bar_pane_histogram_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data) +{ + PaneHistogramData *phd = data; + if (!phd) return TRUE; + + if (phd->need_update) + { + bar_pane_histogram_update(phd); + } + + if (!phd->pixbuf) return TRUE; + + gdk_cairo_set_source_pixbuf(cr, phd->pixbuf, 0, 0); + cairo_paint (cr); + + return TRUE; +} + +#else static gboolean bar_pane_histogram_expose_event_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) { PaneHistogramData *phd = data; @@ -163,6 +183,7 @@ static gboolean bar_pane_histogram_expose_event_cb(GtkWidget *widget, GdkEventEx return TRUE; } +#endif static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data) { @@ -304,8 +325,13 @@ static GtkWidget *bar_pane_histogram_new(const gchar *id, const gchar *title, gi g_signal_connect_after(G_OBJECT(phd->drawing_area), "size_allocate", G_CALLBACK(bar_pane_histogram_size_cb), phd); +#if GTK_CHECK_VERSION(3,0,0) + g_signal_connect(G_OBJECT(phd->drawing_area), "draw", + G_CALLBACK(bar_pane_histogram_draw_cb), phd); +#else g_signal_connect(G_OBJECT(phd->drawing_area), "expose_event", G_CALLBACK(bar_pane_histogram_expose_event_cb), phd); +#endif gtk_box_pack_start(GTK_BOX(phd->widget), phd->drawing_area, TRUE, TRUE, 0); gtk_widget_show(phd->drawing_area); diff --git a/src/cellrenderericon.c b/src/cellrenderericon.c index 2538aea0..2a2a5baa 100644 --- a/src/cellrenderericon.c +++ b/src/cellrenderericon.c @@ -49,6 +49,14 @@ static void gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell, gint *y_offset, gint *width, gint *height); +#if GTK_CHECK_VERSION(3,0,0) +static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell, + cairo_t *cr, + GtkWidget *widget, + const GdkRectangle *background_area, + const GdkRectangle *cell_area, + GtkCellRendererState flags); +#else static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell, GdkWindow *window, GtkWidget *widget, @@ -56,6 +64,8 @@ static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags); +#endif + static gint gqv_cell_renderer_icon_activate(GtkCellRenderer *cell, GdkEvent *event, @@ -125,7 +135,7 @@ gqv_cell_renderer_icon_get_type(void) static void gqv_cell_renderer_icon_init(GQvCellRendererIcon *cellicon) { - GTK_CELL_RENDERER(cellicon)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; + g_object_set(G_OBJECT(cellicon), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); gtk_cell_renderer_set_padding(GTK_CELL_RENDERER(cellicon), 2, 2); } @@ -553,7 +563,7 @@ gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell, gint calc_width; gint calc_height; gint xpad, ypad; - gint xalign, yalign; + gfloat xalign, yalign; gtk_cell_renderer_get_padding(cell, &xpad, &ypad); gtk_cell_renderer_get_alignment(cell, &xalign, &yalign); @@ -619,6 +629,17 @@ gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell, if (height) *height = calc_height; } +#if GTK_CHECK_VERSION(3,0,0) +static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell, + cairo_t *cr, + GtkWidget *widget, + const GdkRectangle *background_area, + const GdkRectangle *cell_area, + GtkCellRendererState flags) + +{ + GtkStyleContext *context = gtk_widget_get_style_context(widget); +#else static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell, GdkWindow *window, @@ -629,6 +650,8 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, GtkCellRendererState flags) { + cairo_t *cr = gdk_cairo_create(window); +#endif GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell; GdkPixbuf *pixbuf; const gchar *text; @@ -676,6 +699,10 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, state = GTK_STATE_NORMAL; } +#if GTK_CHECK_VERSION(3,0,0) + gtk_style_context_set_state(context, state); +#endif + if (pixbuf) { GdkRectangle pix_rect; @@ -695,13 +722,24 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, pix_rect.y = cell_area->y + cell_rect.y; } - if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) && - gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)) + if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) +#if !GTK_CHECK_VERSION(3,0,0) + && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect) +#endif + ) { + gdk_cairo_set_source_pixbuf(cr, pixbuf, pix_rect.x, pix_rect.y); + cairo_rectangle (cr, + draw_rect.x, + draw_rect.y, + draw_rect.width, + draw_rect.height); + + cairo_fill (cr); +/* gdk_draw_pixbuf(window, widget->style->black_gc, pixbuf, - /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */ draw_rect.x - pix_rect.x, draw_rect.y - pix_rect.y, draw_rect.x, @@ -710,6 +748,7 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, draw_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0); +*/ } } @@ -719,7 +758,6 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, PangoRectangle text_rect; GdkRectangle pix_rect; GdkRectangle draw_rect; - layout = gqv_cell_renderer_icon_get_layout(cellicon, widget, TRUE); pango_layout_get_pixel_extents(layout, NULL, &text_rect); @@ -733,17 +771,24 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, pix_rect.y -= TOGGLE_SPACING; } - if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) && - gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)) + if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) +#if !GTK_CHECK_VERSION(3,0,0) + && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect) +#endif + ) { - gtk_paint_layout(widget->style, window, +#if GTK_CHECK_VERSION(3,0,0) + gtk_render_layout(context, cr, pix_rect.x - text_rect.x, pix_rect.y, layout); +#else + + gtk_paint_layout(gtk_widget_get_style(widget), window, state, TRUE, cell_area, widget, "cellrenderertext", pix_rect.x - text_rect.x, pix_rect.y, layout); +#endif } - g_object_unref(layout); } @@ -758,17 +803,48 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, pix_rect.x = cell_area->x + xpad + (cell_rect.width - pix_rect.width + 1) / 2 + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; pix_rect.y = cell_area->y + ypad + (cell_rect.height - pix_rect.height) + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; - if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) && - gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)) + if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) +#if !GTK_CHECK_VERSION(3,0,0) + && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect) +#endif + ) { for (i = 0; i < cellicon->num_marks; i++) { - gtk_paint_check(widget->style, window, +#if GTK_CHECK_VERSION(3,0,0) + state &= ~(GTK_STATE_FLAG_ACTIVE); + + if ((cellicon->marks & (1 << i))) + state |= GTK_STATE_FLAG_ACTIVE; + + cairo_save (cr); + + cairo_rectangle(cr, + pix_rect.x + i * TOGGLE_SPACING + (TOGGLE_WIDTH - TOGGLE_SPACING) / 2, + pix_rect.y, + TOGGLE_WIDTH, TOGGLE_WIDTH); + cairo_clip (cr); + + gtk_style_context_save(context); + gtk_style_context_set_state(context, state); + + gtk_style_context_add_class(context, GTK_STYLE_CLASS_CHECK); + + gtk_render_check(context, cr, + pix_rect.x + i * TOGGLE_SPACING + (TOGGLE_WIDTH - TOGGLE_SPACING) / 2, + pix_rect.y, + TOGGLE_WIDTH, TOGGLE_WIDTH); + gtk_style_context_restore(context); + cairo_restore(cr); + +#else + gtk_paint_check(gtk_widget_get_style(widget), window, state, (cellicon->marks & (1 << i)) ? GTK_SHADOW_IN : GTK_SHADOW_OUT, cell_area, widget, "cellcheck", pix_rect.x + i * TOGGLE_SPACING + (TOGGLE_WIDTH - TOGGLE_SPACING) / 2, pix_rect.y, TOGGLE_WIDTH, TOGGLE_WIDTH); +#endif } } } @@ -779,13 +855,19 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, if (cellicon->focused && GTK_WIDGET_HAS_FOCUS(widget)) #endif { - gtk_paint_focus(widget->style, window, +#if GTK_CHECK_VERSION(3,0,0) +#else + gtk_paint_focus(gtk_widget_get_style(widget), window, state, cell_area, widget, "cellrendererfocus", cell_area->x, cell_area->y, cell_area->width, cell_area->height); +#endif } +#if !GTK_CHECK_VERSION(3,0,0) + cairo_destroy(cr); +#endif } static gint diff --git a/src/cellrenderericon.h b/src/cellrenderericon.h index ce9411cb..9df54fa8 100644 --- a/src/cellrenderericon.h +++ b/src/cellrenderericon.h @@ -22,8 +22,6 @@ #ifndef __GQV_CELL_RENDERER_ICON_H__ #define __GQV_CELL_RENDERER_ICON_H__ -#include - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/src/collect-table.c b/src/collect-table.c index e54db835..69278ebe 100644 --- a/src/collect-table.c +++ b/src/collect-table.c @@ -1383,21 +1383,12 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, if (!ct->marker_window) { - GdkWindow *parent; + GdkWindow *parent = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(ct->listview)); GdkWindowAttr attributes; gint attributes_mask; - GdkPixmap *pixmap; - GdkBitmap *mask; - GdkPixbuf *pb; - gint w, h; - - parent = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(ct->listview)); - - pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm); - gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128); - g_object_unref(pb); - - gdk_pixmap_get_size(pixmap, &w, &h); + GdkPixbuf *pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm); + gint w = gdk_pixbuf_get_width(pb); + gint h = gdk_pixbuf_get_height(pb); attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; @@ -1407,11 +1398,34 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, attributes_mask = 0; ct->marker_window = gdk_window_new(parent, &attributes, attributes_mask); + +#if GTK_CHECK_VERSION(3,0,0) + cairo_region_t *mask; + cairo_pattern_t *pattern; + cairo_surface_t *img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + cairo_t *cr = cairo_create(img); + gdk_cairo_set_source_pixbuf(cr, pb, 0, 0); + cairo_paint(cr); + pattern = cairo_pattern_create_for_surface(img); + mask = gdk_cairo_region_create_from_surface(img); + gdk_window_shape_combine_region(ct->marker_window, mask, 0, 0); + gdk_window_set_background_pattern(ct->marker_window, pattern); + cairo_region_destroy(mask); + cairo_pattern_destroy(pattern); + cairo_destroy(cr); + cairo_surface_destroy(img); +#else + GdkPixmap *pixmap; + GdkBitmap *mask; + gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128); + gdk_window_set_back_pixmap(ct->marker_window, pixmap, FALSE); gdk_window_shape_combine_mask(ct->marker_window, mask, 0, 0); g_object_unref(pixmap); if (mask) g_object_unref(mask); +#endif + g_object_unref(pb); } if (info) @@ -1434,7 +1448,9 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, y = cell.y + (cell.height / 2) - (h / 2); gdk_window_move(ct->marker_window, x, y); +#if !GTK_CHECK_VERSION(3,0,0) gdk_window_clear(ct->marker_window); +#endif if (!gdk_window_is_visible(ct->marker_window)) gdk_window_show(ct->marker_window); } else @@ -2448,7 +2464,7 @@ static void collection_table_destroy(GtkWidget *widget, gpointer data) if (ct->popup) { - g_signal_handlers_disconnect_matched(GTK_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched(G_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA, 0, 0, 0, NULL, ct); gtk_widget_destroy(ct->popup); } diff --git a/src/dnd.c b/src/dnd.c index c50addb2..5394d820 100644 --- a/src/dnd.c +++ b/src/dnd.c @@ -17,6 +17,7 @@ #include "collect.h" #include "image.h" #include "ui_fileops.h" +#include "pixbuf_util.h" GtkTargetEntry dnd_file_drag_types[] = { @@ -72,6 +73,7 @@ static void pixbuf_draw_border(GdkPixbuf *pixbuf, gint w, gint h) } } +/* static void pixbuf_draw_rect(GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h, guint8 val) { gboolean alpha; @@ -96,7 +98,7 @@ static void pixbuf_draw_rect(GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h, } } } - +*/ void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pixbuf, gint items) { GdkPixbuf *dest; @@ -146,7 +148,7 @@ void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pi lw = CLAMP(lw, 0, w - x - 1); lh = CLAMP(lh, 0, h - y - 1); - pixbuf_draw_rect(dest, x, y, lw, lh, 128); + pixbuf_draw_rect_fill(dest, x, y, lw, lh, 128, 128, 128, 255); } if (layout) diff --git a/src/image.c b/src/image.c index a29668f2..81733e77 100644 --- a/src/image.c +++ b/src/image.c @@ -896,7 +896,7 @@ static void image_focus_paint(ImageWindow *imd, gboolean has_focus, GdkRectangle GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); - +#if !GTK_CHECK_VERSION(3,0,0) if (has_focus) { gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_ACTIVE, @@ -911,6 +911,7 @@ static void image_focus_paint(ImageWindow *imd, gboolean has_focus, GdkRectangle allocation.x, allocation.y, allocation.width - 1, allocation.height - 1); } +#endif } static gboolean image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) @@ -1622,6 +1623,7 @@ void image_set_delay_flip(ImageWindow *imd, gboolean delay) void image_to_root_window(ImageWindow *imd, gboolean scaled) { +#if !GTK_CHECK_VERSION(3,0,0) GdkScreen *screen; GdkWindow *rootwindow; GdkPixmap *pixmap; @@ -1636,7 +1638,7 @@ void image_to_root_window(ImageWindow *imd, gboolean scaled) screen = gtk_widget_get_screen(imd->widget); rootwindow = gdk_screen_get_root_window(screen); - if (gdk_drawable_get_visual(rootwindow) != gdk_visual_get_system()) return; + if (gdk_window_get_visual(rootwindow) != gdk_visual_get_system()) return; if (scaled) { @@ -1657,6 +1659,7 @@ void image_to_root_window(ImageWindow *imd, gboolean scaled) g_object_unref(pixmap); gdk_flush(); +#endif } void image_select(ImageWindow *imd, gboolean select) @@ -1765,7 +1768,7 @@ static void image_free(ImageWindow *imd) g_free(imd); } -static void image_destroy_cb(GtkObject *widget, gpointer data) +static void image_destroy_cb(GtkWidget *widget, gpointer data) { ImageWindow *imd = data; image_free(imd); @@ -1775,7 +1778,7 @@ gboolean selectable_frame_expose_cb(GtkWidget *widget, GdkEventExpose *event, gp { GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); - +#if !GTK_CHECK_VERSION(3,0,0) gtk_paint_flat_box(gtk_widget_get_style(widget), gtk_widget_get_window(widget), gtk_widget_get_state(widget), @@ -1786,7 +1789,7 @@ gboolean selectable_frame_expose_cb(GtkWidget *widget, GdkEventExpose *event, gp allocation.x + 3, allocation.y + 3, allocation.width - 6, allocation.height - 6); - +#endif return FALSE; } diff --git a/src/layout.c b/src/layout.c index 6abbb5a7..3487eb00 100644 --- a/src/layout.c +++ b/src/layout.c @@ -1038,20 +1038,35 @@ gboolean layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint * gboolean layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v) { + GtkAllocation h_allocation; + GtkAllocation v_allocation; + if (!layout_valid(&lw)) return FALSE; + + if (lw->h_pane) + { + GtkWidget *child = gtk_paned_get_child1(GTK_PANED(lw->h_pane)); + gtk_widget_get_allocation(child, &h_allocation); + } + + if (lw->v_pane) + { + GtkWidget *child = gtk_paned_get_child1(GTK_PANED(lw->v_pane)); + gtk_widget_get_allocation(child, &v_allocation); + } - if (lw->h_pane && gtk_paned_get_child1(GTK_PANED(lw->h_pane))->allocation.x >= 0) + if (lw->h_pane && h_allocation.x >= 0) { - *h = gtk_paned_get_child1(GTK_PANED(lw->h_pane))->allocation.width; + *h = h_allocation.width; } else if (h != &lw->options.main_window.hdivider_pos) { *h = lw->options.main_window.hdivider_pos; } - if (lw->v_pane && gtk_paned_get_child1(GTK_PANED(lw->v_pane))->allocation.x >= 0) + if (lw->v_pane && v_allocation.x >= 0) { - *v = gtk_paned_get_child1(GTK_PANED(lw->v_pane))->allocation.height; + *v = v_allocation.height; } else if (v != &lw->options.main_window.vdivider_pos) { @@ -1146,6 +1161,7 @@ static void layout_location_compute(LayoutLocation l1, LayoutLocation l2, gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos) { GdkWindow *window; + GtkAllocation allocation; if (!layout_valid(&lw)) return FALSE; #if GTK_CHECK_VERSION(2,20,0) @@ -1165,14 +1181,15 @@ gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gdk_window_get_root_origin(window, x, y); *w = gdk_window_get_width(window); *h = gdk_window_get_height(window); + gtk_widget_get_allocation(gtk_paned_get_child1(GTK_PANED(lw->tools_pane)), &allocation); if (GTK_IS_VPANED(lw->tools_pane)) { - *divider_pos = gtk_paned_get_child1(GTK_PANED(lw->tools_pane))->allocation.height; + *divider_pos = allocation.height; } else { - *divider_pos = gtk_paned_get_child1(GTK_PANED(lw->tools_pane))->allocation.width; + *divider_pos = allocation.width; } return TRUE; diff --git a/src/layout_image.c b/src/layout_image.c index cf5c515c..0876674a 100644 --- a/src/layout_image.c +++ b/src/layout_image.c @@ -567,7 +567,7 @@ static void layout_image_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean * { LayoutWindow *lw = data; - gdk_window_get_origin(lw->image->pr->window, x, y); + gdk_window_get_origin(gtk_widget_get_window(lw->image->pr), x, y); popup_menu_position_clamp(menu, x, y, 0); } diff --git a/src/logwindow.c b/src/logwindow.c index b2260b30..b94725bc 100644 --- a/src/logwindow.c +++ b/src/logwindow.c @@ -111,13 +111,15 @@ static LogWindow *log_window_create(void) static void log_window_init(LogWindow *logwin) { GtkTextBuffer *buffer; +#if !GTK_CHECK_VERSION(3,0,0) GdkColormap *colormap; +#endif gboolean success[LOG_COUNT]; gint i; g_assert(logwin != NULL); g_assert(logwin->colors != NULL); - +#if !GTK_CHECK_VERSION(3,0,0) for (i = LOG_NORMAL; i < LOG_COUNT; i++) { gboolean ok = gdk_color_parse(logdefs[i].color, &logwin->colors[i]); @@ -144,7 +146,7 @@ static void log_window_init(LogWindow *logwin) break; } } - +#endif buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text)); for (i = LOG_NORMAL; i < LOG_COUNT; i++) gtk_text_buffer_create_tag(buffer, logdefs[i].tag, diff --git a/src/main.c b/src/main.c index b01b07e1..fa9f22ec 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,7 @@ #ifdef G_OS_UNIX #include #endif +#include #include "main.h" diff --git a/src/options.c b/src/options.c index 49729676..3d8394c8 100644 --- a/src/options.c +++ b/src/options.c @@ -63,7 +63,7 @@ ConfOptions *init_options(ConfOptions *options) options->fullscreen.screen = -1; memset(&options->image.border_color, 0, sizeof(options->image.border_color)); - options->image.dither_quality = GDK_RGB_DITHER_NORMAL; +// options->image.dither_quality = GDK_RGB_DITHER_NORMAL; options->image.enable_read_ahead = TRUE; options->image.exif_rotate_enable = TRUE; options->image.fit_window_to_image = FALSE; diff --git a/src/pixbuf-renderer.c b/src/pixbuf-renderer.c index 0dc6deb4..1c7c68de 100644 --- a/src/pixbuf-renderer.c +++ b/src/pixbuf-renderer.c @@ -121,7 +121,11 @@ static void pixbuf_renderer_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void pixbuf_renderer_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +#if GTK_CHECK_VERSION(3,0,0) +static gboolean pixbuf_renderer_draw(GtkWidget *widget, cairo_t *cr); +#else static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event); +#endif static void pr_scroller_timer_set(PixbufRenderer *pr, gboolean start); @@ -182,7 +186,11 @@ static void pixbuf_renderer_class_init(PixbufRendererClass *class) gobject_class->finalize = pixbuf_renderer_finalize; - widget_class->expose_event = pixbuf_renderer_expose; +#if GTK_CHECK_VERSION(3,0,0) + widget_class->draw = pixbuf_renderer_draw; +#else + widget_class->expose_event = pixbuf_renderer_expose; +#endif g_object_class_install_property(gobject_class, PROP_ZOOM_MIN, @@ -229,7 +237,7 @@ static void pixbuf_renderer_class_init(PixbufRendererClass *class) NULL, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE)); - +#if !GTK_CHECK_VERSION(3,0,0) g_object_class_install_property(gobject_class, PROP_DITHER_QUALITY, g_param_spec_uint("dither_quality", @@ -239,7 +247,7 @@ static void pixbuf_renderer_class_init(PixbufRendererClass *class) GDK_RGB_DITHER_MAX, GDK_RGB_DITHER_NORMAL, G_PARAM_READABLE | G_PARAM_WRITABLE)); - +#endif g_object_class_install_property(gobject_class, PROP_SCROLL_RESET, g_param_spec_uint("scroll_reset", @@ -412,7 +420,9 @@ static void pixbuf_renderer_init(PixbufRenderer *pr) pr->scale = 1.0; pr->aspect_ratio = 1.0; +#if !GTK_CHECK_VERSION(3,0,0) pr->dither_quality = GDK_RGB_DITHER_NORMAL; +#endif pr->scroll_reset = PR_SCROLL_RESET_TOPLEFT; @@ -489,9 +499,11 @@ static void pixbuf_renderer_set_property(GObject *object, guint prop_id, case PROP_ZOOM_EXPAND: pr->zoom_expand = g_value_get_boolean(value); break; +#if !GTK_CHECK_VERSION(3,0,0) case PROP_DITHER_QUALITY: pr->dither_quality = g_value_get_uint(value); break; +#endif case PROP_SCROLL_RESET: pr->scroll_reset = g_value_get_uint(value); break; @@ -555,9 +567,11 @@ static void pixbuf_renderer_get_property(GObject *object, guint prop_id, case PROP_ZOOM_EXPAND: g_value_set_boolean(value, pr->zoom_expand); break; +#if !GTK_CHECK_VERSION(3,0,0) case PROP_DITHER_QUALITY: g_value_set_uint(value, pr->dither_quality); break; +#endif case PROP_SCROLL_RESET: g_value_set_uint(value, pr->scroll_reset); break; @@ -597,6 +611,26 @@ static void pixbuf_renderer_get_property(GObject *object, guint prop_id, } } +#if GTK_CHECK_VERSION(3,0,0) + +static gboolean pixbuf_renderer_draw(GtkWidget *widget, cairo_t *cr) +{ + if (gtk_widget_is_drawable(widget)) + { + if (gtk_widget_get_has_window(widget)) + { + GdkRectangle area; + if (gdk_cairo_get_clip_rectangle(cr, &area)) + { + pixbuf_renderer_paint(PIXBUF_RENDERER(widget), &area); + } + } + } + + return FALSE; +} + +#else static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event) { #if GTK_CHECK_VERSION(2,20,0) @@ -616,7 +650,6 @@ static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event) GdkRectangle area; gdk_window_get_position(event->window, &area.x, &area.y); - area.x += event->area.x; area.y += event->area.y; area.width = event->area.width; @@ -632,6 +665,7 @@ static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event) return FALSE; } +#endif /* *------------------------------------------------------------------- @@ -2455,7 +2489,9 @@ static void pr_set_pixbuf(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, P if (GTK_WIDGET_REALIZED(box)) #endif { +#if !GTK_CHECK_VERSION(3,0,0) gdk_window_clear(gtk_widget_get_window(box)); +#endif pr->renderer->overlay_draw(pr->renderer, 0, 0, pr->viewport_width, pr->viewport_height); if (pr->renderer2) pr->renderer2->overlay_draw(pr->renderer2, 0, 0, pr->viewport_width, pr->viewport_height); } diff --git a/src/pixbuf-renderer.h b/src/pixbuf-renderer.h index b2bcf3e7..948f1c75 100644 --- a/src/pixbuf-renderer.h +++ b/src/pixbuf-renderer.h @@ -13,10 +13,6 @@ #ifndef PIXBUF_RENDERER_H #define PIXBUF_RENDERER_H -#include -#include - - #define TYPE_PIXBUF_RENDERER (pixbuf_renderer_get_type()) #define PIXBUF_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_PIXBUF_RENDERER, PixbufRenderer)) #define PIXBUF_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_PIXBUF_RENDERER, PixbufRendererClass)) @@ -145,7 +141,9 @@ struct _PixbufRenderer gboolean zoom_2pass; gboolean zoom_expand; +#if !GTK_CHECK_VERSION(3,0,0) GdkRgbDither dither_quality; +#endif PixbufRendererScrollResetType scroll_reset; diff --git a/src/pixbuf_util.c b/src/pixbuf_util.c index c1681725..1614c0d4 100644 --- a/src/pixbuf_util.c +++ b/src/pixbuf_util.c @@ -782,7 +782,6 @@ void pixbuf_draw_layout(GdkPixbuf *pixbuf, PangoLayout *layout, GtkWidget *widge { GdkPixbuf *buffer; gint w, h; - GdkGC *gc; gint sx, sy; gint dw, dh; cairo_surface_t *source; diff --git a/src/rcfile.c b/src/rcfile.c index b61c4db2..be64c5c6 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -618,7 +618,9 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_INT(*options, image.tile_cache_max)) continue; if (READ_INT(*options, image.image_cache_max)) continue; if (READ_UINT_CLAMP(*options, image.zoom_quality, GDK_INTERP_NEAREST, GDK_INTERP_HYPER)) continue; +#if !GTK_CHECK_VERSION(3,0,0) if (READ_UINT_CLAMP(*options, image.dither_quality, GDK_RGB_DITHER_NONE, GDK_RGB_DITHER_MAX)) continue; +#endif if (READ_INT(*options, image.zoom_increment)) continue; if (READ_BOOL(*options, image.enable_read_ahead)) continue; if (READ_BOOL(*options, image.exif_rotate_enable)) continue; diff --git a/src/renderer-tiles.c b/src/renderer-tiles.c index 24a8a421..e5f54964 100644 --- a/src/renderer-tiles.c +++ b/src/renderer-tiles.c @@ -59,7 +59,7 @@ typedef struct _QueueData QueueData; struct _ImageTile { - GdkPixmap *pixmap; /* off screen buffer */ + cairo_surface_t *surface; /* off screen buffer */ GdkPixbuf *pixbuf; /* pixbuf area for zooming */ gint x; /* x offset into image */ gint y; /* y offset into image */ @@ -126,7 +126,7 @@ struct _RendererTiles GList *draw_queue_2pass;/* list when 2 pass is enabled */ GList *overlay_list; - GdkPixmap *overlay_buffer; + cairo_surface_t *overlay_buffer; guint draw_idle_id; /* event source id */ @@ -194,11 +194,17 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) { PixbufRenderer *pr = rt->pr; GtkWidget *box; + GdkWindow *window; gint rx, ry, rw, rh; + cairo_t *cr; box = GTK_WIDGET(pr); + window = gtk_widget_get_window(box); + + if (!window) return; + + cr = gdk_cairo_create(window); - if (!box->window) return; if (!pr->pixbuf && !pr->source_tiles_enabled) { @@ -207,7 +213,10 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->viewport_width, pr->viewport_height, &rx, &ry, &rw, &rh)) { - gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_fill(cr); + cairo_destroy(cr); rt_overlay_draw(rt, rx, ry, rw, rh, NULL); } return; @@ -221,7 +230,9 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->x_offset, pr->viewport_height, &rx, &ry, &rw, &rh)) { - gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_fill(cr); rt_overlay_draw(rt, rx, ry, rw, rh, NULL); } if (pr->viewport_width - pr->vis_width - pr->x_offset > 0 && @@ -230,7 +241,9 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->viewport_width - pr->vis_width - pr->x_offset, pr->viewport_height, &rx, &ry, &rw, &rh)) { - gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_fill(cr); rt_overlay_draw(rt, rx, ry, rw, rh, NULL); } } @@ -242,7 +255,9 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->vis_width, pr->y_offset, &rx, &ry, &rw, &rh)) { - gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_fill(cr); rt_overlay_draw(rt, rx, ry, rw, rh, NULL); } if (pr->viewport_height - pr->vis_height - pr->y_offset > 0 && @@ -251,10 +266,13 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->vis_width, pr->viewport_height - pr->vis_height - pr->y_offset, &rx, &ry, &rw, &rh)) { - gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); + cairo_fill(cr); rt_overlay_draw(rt, rx, ry, rw, rh, NULL); } } + cairo_destroy(cr); } static void rt_border_clear(RendererTiles *rt) @@ -291,7 +309,7 @@ static void rt_tile_free(ImageTile *it) if (!it) return; if (it->pixbuf) g_object_unref(it->pixbuf); - if (it->pixmap) g_object_unref(it->pixmap); + if (it->surface) cairo_surface_destroy(it->surface); g_free(it); } @@ -466,29 +484,31 @@ static ImageTile *rt_tile_get(RendererTiles *rt, gint x, gint y, gboolean only_e return rt_tile_add(rt, x, y); } -static gint pixmap_calc_size(GdkPixmap *pixmap) +static gint pixmap_calc_size(cairo_surface_t *surface) { - gint w, h, d; +// gint w, h, d; - d = gdk_drawable_get_depth(pixmap); - gdk_drawable_get_size(pixmap, &w, &h); - return w * h * (d / 8); +// d = gdk_drawable_get_depth(pixmap); +// gdk_drawable_get_size(pixmap, &w, &h); + return PR_TILE_SIZE * PR_TILE_SIZE * 4 / 8; } static void rt_tile_prepare(RendererTiles *rt, ImageTile *it) { PixbufRenderer *pr = rt->pr; - if (!it->pixmap) + if (!it->surface) { - GdkPixmap *pixmap; + cairo_surface_t *surface; guint size; - pixmap = gdk_pixmap_new(((GtkWidget *)pr)->window, rt->tile_width, rt->tile_height, -1); + surface = gdk_window_create_similar_surface(gtk_widget_get_window((GtkWidget *)pr), + CAIRO_CONTENT_COLOR, + rt->tile_width, rt->tile_height); - size = pixmap_calc_size(pixmap); + size = pixmap_calc_size(surface); rt_tile_free_space(rt, size, it); - it->pixmap = pixmap; + it->surface = surface; it->size += size; rt->tile_cache_size += size; } @@ -553,7 +573,7 @@ static void rt_overlay_init_window(RendererTiles *rt, OverlayData *od) attributes.event_mask = GDK_EXPOSURE_MASK; attributes_mask = 0; - od->window = gdk_window_new(GTK_WIDGET(pr)->window, &attributes, attributes_mask); + od->window = gdk_window_new(gtk_widget_get_window(GTK_WIDGET(pr)), &attributes, attributes_mask); gdk_window_set_user_data(od->window, pr); gdk_window_move(od->window, px + rt->stereo_off_x, py + rt->stereo_off_y); gdk_window_show(od->window); @@ -585,11 +605,33 @@ static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, { if (!rt->overlay_buffer) { - rt->overlay_buffer = gdk_pixmap_new(((GtkWidget *)pr)->window, rt->tile_width, rt->tile_height, -1); + rt->overlay_buffer = gdk_window_create_similar_surface(gtk_widget_get_window((GtkWidget *)pr), + CAIRO_CONTENT_COLOR, + rt->tile_width, rt->tile_height); } if (it) { + cairo_t *cr; + + cr = cairo_create(rt->overlay_buffer); + cairo_set_source_surface(cr, it->surface, (pr->x_offset + (it->x - rt->x_scroll)) - rx, (pr->y_offset + (it->y - rt->y_scroll)) - ry); + cairo_rectangle(cr, 0, 0, rw, rh); + cairo_fill_preserve(cr); + + gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px - rx, py - ry); + cairo_fill (cr); + cairo_destroy (cr); + + cr = gdk_cairo_create(od->window); + cairo_set_source_surface(cr, rt->overlay_buffer, rx - px, ry - py); + cairo_rectangle (cr, rx - px, ry - py, rw, rh); + cairo_fill (cr); + cairo_destroy (cr); + +#if 0 + + #if GTK_CHECK_VERSION(2,20,0) gdk_draw_drawable(rt->overlay_buffer, box->style->fg_gc[gtk_widget_get_state(box)], #else @@ -617,6 +659,7 @@ static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, rt->overlay_buffer, 0, 0, rx - px, ry - py, rw, rh); +#endif } else { @@ -627,10 +670,27 @@ static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, for (sy = ry; sy < ry + rh; sy += rt->tile_height) { gint sw, sh; + cairo_t *cr; sw = MIN(rx + rw - sx, rt->tile_width); sh = MIN(ry + rh - sy, rt->tile_height); + cr = cairo_create(rt->overlay_buffer); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_rectangle(cr, 0, 0, sw, sh); + cairo_fill_preserve(cr); + + gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px - sx, py - sy); + cairo_fill (cr); + cairo_destroy (cr); + + cr = gdk_cairo_create(od->window); + cairo_set_source_surface(cr, rt->overlay_buffer, sx - px, sy - py); + cairo_rectangle (cr, sx - px, sy - py, sw, sh); + cairo_fill(cr); + cairo_destroy(cr); + +#if 0 gdk_draw_rectangle(rt->overlay_buffer, #if GTK_CHECK_VERSION(2,20,0) box->style->bg_gc[gtk_widget_get_state(box)], TRUE, @@ -656,6 +716,7 @@ static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, rt->overlay_buffer, 0, 0, sx - px, sy - py, sw, sh); +#endif } } } @@ -776,7 +837,7 @@ static void rt_overlay_free(RendererTiles *rt, OverlayData *od) if (!rt->overlay_list && rt->overlay_buffer) { - g_object_unref(rt->overlay_buffer); + cairo_surface_destroy(rt->overlay_buffer); rt->overlay_buffer = NULL; } } @@ -796,7 +857,7 @@ static void rt_overlay_list_reset_window(RendererTiles *rt) { GList *work; - if (rt->overlay_buffer) g_object_unref(rt->overlay_buffer); + if (rt->overlay_buffer) cairo_surface_destroy(rt->overlay_buffer); rt->overlay_buffer = NULL; work = rt->overlay_list; @@ -1140,13 +1201,22 @@ static gboolean rt_source_tile_render(RendererTiles *rt, ImageTile *it, it->x + x, it->y + y, w, h, &rx, &ry, &rw, &rh)) { + cairo_t *cr; + cr = cairo_create(it->surface); + cairo_rectangle (cr, rx - st->x, ry - st->y, rw, rh); + if (st->blank) { + cairo_set_source_rgb(cr, 0, 0, 0); +#if 0 gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE, rx - st->x, ry - st->y, rw, rh); +#endif } else /* (pr->zoom == 1.0 || pr->scale == 1.0) */ { + gdk_cairo_set_source_pixbuf(cr, st->pixbuf, it->x + st->x, it->y + st->y); +#if 0 gdk_draw_pixbuf(it->pixmap, #if GTK_CHECK_VERSION(2,20,0) box->style->fg_gc[gtk_widget_get_state(box)], @@ -1158,7 +1228,10 @@ static gboolean rt_source_tile_render(RendererTiles *rt, ImageTile *it, rx - it->x, ry - it->y, rw, rh, pr->dither_quality, rx, ry); +#endif } + cairo_fill (cr); + cairo_destroy (cr); } } } @@ -1203,10 +1276,19 @@ static gboolean rt_source_tile_render(RendererTiles *rt, ImageTile *it, it->x + x, it->y + y, w, h, &rx, &ry, &rw, &rh)) { + if (st->blank) { + cairo_t *cr; + cr = cairo_create(it->surface); + cairo_rectangle (cr, rx - st->x, ry - st->y, rw, rh); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_fill (cr); + cairo_destroy (cr); +#if 0 gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE, rx - st->x, ry - st->y, rw, rh); +#endif } else { @@ -1298,7 +1380,7 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, gboolean draw = FALSE; gint orientation = rt_get_orientation(rt); - if (it->render_todo == TILE_RENDER_NONE && it->pixmap && !new_data) return; + if (it->render_todo == TILE_RENDER_NONE && it->surface && !new_data) return; if (it->render_done != TILE_RENDER_ALL) { @@ -1330,8 +1412,16 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, if (it->blank) { /* no data, do fast rect fill */ + cairo_t *cr; + cr = cairo_create(it->surface); + cairo_rectangle (cr, 0, 0, it->w, it->h); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_fill (cr); + cairo_destroy (cr); +#if 0 gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE, 0, 0, it->w, it->h); +#endif } else if (pr->source_tiles_enabled) { @@ -1345,6 +1435,14 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, !(rt->stereo_mode & PR_STEREO_ANAGLYPH)) { /* special case: faster, simple, scale 1.0, base orientation, no postprocessing */ + cairo_t *cr; + cr = cairo_create(it->surface); + cairo_rectangle (cr, x, y, w, h); + gdk_cairo_set_source_pixbuf(cr, pr->pixbuf, -it->x - GET_RIGHT_PIXBUF_OFFSET(rt), -it->y); + cairo_fill (cr); + cairo_destroy (cr); + +#if 0 gdk_draw_pixbuf(it->pixmap, #if GTK_CHECK_VERSION(2,20,0) box->style->fg_gc[gtk_widget_get_state(box)], @@ -1356,6 +1454,7 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, x, y, w, h, pr->dither_quality, it->x + x, it->y + y); +#endif } else { @@ -1427,10 +1526,17 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, if (draw && it->pixbuf && !it->blank) { + cairo_t *cr; if (pr->func_post_process && !(pr->post_process_slow && fast)) pr->func_post_process(pr, &it->pixbuf, x, y, w, h, pr->post_process_user_data); + cr = cairo_create(it->surface); + cairo_rectangle (cr, x, y, w, h); + gdk_cairo_set_source_pixbuf(cr, it->pixbuf, 0, 0); + cairo_fill (cr); + cairo_destroy (cr); +#if 0 gdk_draw_pixbuf(it->pixmap, #if GTK_CHECK_VERSION(2,20,0) box->style->fg_gc[gtk_widget_get_state(box)], @@ -1442,6 +1548,7 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, x, y, w, h, pr->dither_quality, it->x + x, it->y + y); +#endif } #if 0 @@ -1460,6 +1567,8 @@ static void rt_tile_expose(RendererTiles *rt, ImageTile *it, { PixbufRenderer *pr = rt->pr; GtkWidget *box; + GdkWindow *window; + cairo_t *cr; /* clamp to visible */ if (it->x + x < rt->x_scroll) @@ -1486,14 +1595,23 @@ static void rt_tile_expose(RendererTiles *rt, ImageTile *it, rt_tile_render(rt, it, x, y, w, h, new_data, fast); box = GTK_WIDGET(pr); + window = gtk_widget_get_window(box); + + cr = gdk_cairo_create(window); + cairo_set_source_surface(cr, it->surface, pr->x_offset + (it->x - rt->x_scroll) + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + rt->stereo_off_y); + cairo_rectangle (cr, pr->x_offset + (it->x - rt->x_scroll) + x + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + y + rt->stereo_off_y, w, h); + cairo_fill (cr); + cairo_destroy (cr); +#if 0 #if GTK_CHECK_VERSION(2,20,0) - gdk_draw_drawable(box->window, box->style->fg_gc[gtk_widget_get_state(box)], + gdk_draw_drawable(window, box->style->fg_gc[gtk_widget_get_state(box)], #else - gdk_draw_drawable(box->window, box->style->fg_gc[GTK_WIDGET_STATE(box)], + gdk_draw_drawable(window, box->style->fg_gc[GTK_WIDGET_STATE(box)], #endif it->pixmap, x, y, pr->x_offset + (it->x - rt->x_scroll) + x + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + y + rt->stereo_off_y, w, h); +#endif if (rt->overlay_list) { @@ -1628,7 +1746,7 @@ static gboolean rt_queue_draw_idle_cb(gpointer data) { /* if new pixel data, and we already have a pixmap, update the tile */ qd->it->blank = FALSE; - if (qd->it->pixmap && qd->it->render_done == TILE_RENDER_ALL) + if (qd->it->surface && qd->it->render_done == TILE_RENDER_ALL) { rt_tile_render(rt, qd->it, qd->x, qd->y, qd->w, qd->h, qd->new_data, fast); } @@ -1904,8 +2022,11 @@ static void rt_scroll(RendererTiles *rt, gint x_off, gint y_off) gint x1, y1; gint x2, y2; GtkWidget *box; - GdkGC *gc; + GdkWindow *window; +// GdkGC *gc; GdkEvent *event; + cairo_t *cr; + cairo_surface_t *surface; if (x_off < 0) { @@ -1930,14 +2051,31 @@ static void rt_scroll(RendererTiles *rt, gint x_off, gint y_off) } box = GTK_WIDGET(pr); - - gc = gdk_gc_new(box->window); + window = gtk_widget_get_window(box); + + cr = gdk_cairo_create(window); + surface = cairo_get_target(cr); + /* clipping restricts the intermediate surface's size, so it's a good idea + * to use it. */ + cairo_rectangle(cr, x1 + pr->x_offset + rt->stereo_off_x, y1 + pr->y_offset + rt->stereo_off_y, w, h); + cairo_clip (cr); + /* Now push a group to change the target */ + cairo_push_group (cr); + cairo_set_source_surface(cr, surface, x1 - x2, y1 - y2); + cairo_paint(cr); + /* Now copy the intermediate target back */ + cairo_pop_group_to_source(cr); + cairo_paint(cr); + cairo_destroy(cr); +#if 0 + gc = gdk_gc_new(window); gdk_gc_set_exposures(gc, TRUE); - gdk_draw_drawable(box->window, gc, - box->window, + gdk_draw_drawable(window, gc, + window, x2 + pr->x_offset + rt->stereo_off_x, y2 + pr->y_offset + rt->stereo_off_y, x1 + pr->x_offset + rt->stereo_off_x, y1 + pr->y_offset + rt->stereo_off_y, w, h); g_object_unref(gc); +#endif rt_overlay_queue_all(rt, x2, y2, x1, y1); @@ -1960,7 +2098,7 @@ static void rt_scroll(RendererTiles *rt, gint x_off, gint y_off) /* process exposures here, "expose_event" seems to miss a few with obstructed windows */ #if ! GTK_CHECK_VERSION(2,18,0) - while ((event = gdk_event_get_graphics_expose(box->window)) != NULL) + while ((event = gdk_event_get_graphics_expose(window)) != NULL) { renderer_redraw((void *) rt, event->expose.area.x, event->expose.area.y, event->expose.area.width, event->expose.area.height, FALSE, TILE_RENDER_ALL, FALSE, FALSE); diff --git a/src/renderer-tiles.h b/src/renderer-tiles.h index 6356d3e5..b15e4f8b 100644 --- a/src/renderer-tiles.h +++ b/src/renderer-tiles.h @@ -13,9 +13,6 @@ #ifndef RENDERER_TILES_H #define RENDERER_TILES_H -#include -#include - #include diff --git a/src/ui_bookmark.c b/src/ui_bookmark.c index 3a0e5eb8..68259608 100644 --- a/src/ui_bookmark.c +++ b/src/ui_bookmark.c @@ -510,10 +510,11 @@ static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpoi pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, allocation.width, allocation.height); +#if !GTK_CHECK_VERSION(3,0,0) gdk_pixbuf_get_from_drawable(pixbuf, gtk_widget_get_window(button), NULL, allocation.x, allocation.y, 0, 0, allocation.width, allocation.height); - +#endif gdk_window_get_pointer(gtk_widget_get_window(button), &x, &y, &mask); gtk_drag_set_icon_pixbuf(context, pixbuf, diff --git a/src/ui_misc.c b/src/ui_misc.c index fcc35ce9..22f5fd38 100644 --- a/src/ui_misc.c +++ b/src/ui_misc.c @@ -1387,7 +1387,6 @@ static gboolean sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpoint GtkStateType state; GtkAllocation allocation; - gdk_region_get_clipbox(event->region, &clip); if (sd->position & SIZER_POS_LEFT || sd->position & SIZER_POS_RIGHT) { @@ -1408,11 +1407,21 @@ static gboolean sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpoint } gtk_widget_get_allocation(widget, &allocation); +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); + + gtk_render_handle (gtk_widget_get_style_context (widget), + cr, allocation.x, allocation.y, allocation.width, allocation.height); + cairo_destroy(cr); +#else + gdk_region_get_clipbox(event->region, &clip); + gtk_paint_handle(gtk_widget_get_style(widget), gtk_widget_get_window(widget), state, GTK_SHADOW_NONE, &clip, widget, "paned", 0, 0, allocation.width, allocation.height, orientation); +#endif return TRUE; } diff --git a/src/ui_tree_edit.c b/src/ui_tree_edit.c index 03147d0d..0b8ae763 100644 --- a/src/ui_tree_edit.c +++ b/src/ui_tree_edit.c @@ -285,7 +285,11 @@ gboolean tree_view_get_cell_origin(GtkTreeView *widget, GtkTreePath *tpath, gint if (gtk_tree_view_get_headers_visible(widget)) { GtkAllocation allocation; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_allocation(gtk_tree_view_column_get_button(tv_column), &allocation); +#else gtk_widget_get_allocation(tv_column->button, &allocation); +#endif header_size = allocation.height; } else -- 2.20.1