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;
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)
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);
}
}
+#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;
return TRUE;
}
+#endif
static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
{
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);
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,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags);
+#endif
+
static gint gqv_cell_renderer_icon_activate(GtkCellRenderer *cell,
GdkEvent *event,
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);
}
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);
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,
GtkCellRendererState flags)
{
+ cairo_t *cr = gdk_cairo_create(window);
+#endif
GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell;
GdkPixbuf *pixbuf;
const gchar *text;
state = GTK_STATE_NORMAL;
}
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_style_context_set_state(context, state);
+#endif
+
if (pixbuf)
{
GdkRectangle pix_rect;
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,
draw_rect.height,
GDK_RGB_DITHER_NORMAL,
0, 0);
+*/
}
}
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);
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);
}
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
}
}
}
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
#ifndef __GQV_CELL_RENDERER_ICON_H__
#define __GQV_CELL_RENDERER_ICON_H__
-#include <gtk/gtkcellrenderer.h>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
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;
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)
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
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);
}
#include "collect.h"
#include "image.h"
#include "ui_fileops.h"
+#include "pixbuf_util.h"
GtkTargetEntry dnd_file_drag_types[] = {
}
}
+/*
static void pixbuf_draw_rect(GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h, guint8 val)
{
gboolean alpha;
}
}
}
-
+*/
void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pixbuf, gint items)
{
GdkPixbuf *dest;
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)
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,
allocation.x, allocation.y,
allocation.width - 1, allocation.height - 1);
}
+#endif
}
static gboolean image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data)
void image_to_root_window(ImageWindow *imd, gboolean scaled)
{
+#if !GTK_CHECK_VERSION(3,0,0)
GdkScreen *screen;
GdkWindow *rootwindow;
GdkPixmap *pixmap;
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)
{
g_object_unref(pixmap);
gdk_flush();
+#endif
}
void image_select(ImageWindow *imd, gboolean select)
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);
{
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),
allocation.x + 3, allocation.y + 3,
allocation.width - 6, allocation.height - 6);
-
+#endif
return FALSE;
}
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)
{
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)
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;
{
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);
}
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]);
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,
#ifdef G_OS_UNIX
#include <pwd.h>
#endif
+#include <locale.h>
#include "main.h"
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;
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);
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,
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",
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",
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;
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;
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;
}
}
+#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)
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;
return FALSE;
}
+#endif
/*
*-------------------------------------------------------------------
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);
}
#ifndef PIXBUF_RENDERER_H
#define PIXBUF_RENDERER_H
-#include <gtk/gtkeventbox.h>
-#include <gtk/gtkwindow.h>
-
-
#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))
gboolean zoom_2pass;
gboolean zoom_expand;
+#if !GTK_CHECK_VERSION(3,0,0)
GdkRgbDither dither_quality;
+#endif
PixbufRendererScrollResetType scroll_reset;
{
GdkPixbuf *buffer;
gint w, h;
- GdkGC *gc;
gint sx, sy;
gint dw, dh;
cairo_surface_t *source;
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;
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 */
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 */
{
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)
{
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;
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 &&
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);
}
}
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 &&
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)
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);
}
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;
}
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);
{
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
rt->overlay_buffer,
0, 0,
rx - px, ry - py, rw, rh);
+#endif
}
else
{
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,
rt->overlay_buffer,
0, 0,
sx - px, sy - py, sw, sh);
+#endif
}
}
}
if (!rt->overlay_list && rt->overlay_buffer)
{
- g_object_unref(rt->overlay_buffer);
+ cairo_surface_destroy(rt->overlay_buffer);
rt->overlay_buffer = NULL;
}
}
{
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;
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)],
rx - it->x, ry - it->y,
rw, rh,
pr->dither_quality, rx, ry);
+#endif
}
+ cairo_fill (cr);
+ cairo_destroy (cr);
}
}
}
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
{
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)
{
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)
{
!(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)],
x, y,
w, h,
pr->dither_quality, it->x + x, it->y + y);
+#endif
}
else
{
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)],
x, y,
w, h,
pr->dither_quality, it->x + x, it->y + y);
+#endif
}
#if 0
{
PixbufRenderer *pr = rt->pr;
GtkWidget *box;
+ GdkWindow *window;
+ cairo_t *cr;
/* clamp to visible */
if (it->x + x < rt->x_scroll)
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)
{
{
/* 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);
}
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)
{
}
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);
/* 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);
#ifndef RENDERER_TILES_H
#define RENDERER_TILES_H
-#include <gtk/gtkeventbox.h>
-#include <gtk/gtkwindow.h>
-
#include <pixbuf-renderer.h>
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,
GtkStateType state;
GtkAllocation allocation;
- gdk_region_get_clipbox(event->region, &clip);
if (sd->position & SIZER_POS_LEFT || sd->position & SIZER_POS_RIGHT)
{
}
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;
}
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