diff --git a/SConstruct b/SConstruct index 5330989..59629a2 100644 --- a/SConstruct +++ b/SConstruct @@ -137,7 +137,7 @@ env.Append(CPPPATH=[], ] ) -env.ParseConfig("${PKGCONFIG} --cflags --libs gtk+-2.0 glib-2.0 gio-2.0 gmodule-2.0 gthread-2.0") +env.ParseConfig("${PKGCONFIG} --cflags --libs gtk+-3.0 glib-2.0 gio-2.0 gmodule-2.0 gthread-2.0") env.SConscript(['src/SConscript', 'doc/SConscript', diff --git a/aclocal.m4 b/aclocal.m4 index b4caa9f..1ff3e41 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -79,11 +79,11 @@ AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run if test x"$no_gtk" = x ; then GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags` GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs` - gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_gtktest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" @@ -119,7 +119,7 @@ main () (gtk_minor_version != $gtk_config_minor_version) || (gtk_micro_version != $gtk_config_micro_version)) { - printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", + printf("\n*** 'pkg-config --modversion gtk+-3.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, gtk_major_version, gtk_minor_version, gtk_micro_version); printf ("*** was found! If pkg-config was correct, then it is best\n"); diff --git a/configure.in b/configure.in index 8b099d9..8b14ed5 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ AM_CONFIG_HEADER(config.h) PACKAGE=givwidget GIVWIDGET_API_VERSION=2.0 -AM_INIT_AUTOMAKE(giv, 0.9.26) +AM_INIT_AUTOMAKE(giv, 0.9.30) dnl Use libtool to get shared libraries LT_PREREQ @@ -23,8 +23,8 @@ AC_ISC_POSIX AC_HEADER_STDC AM_PROG_CC_C_O -GTK_REQUIRED_VERSION=2.0.0 -REQ_PACKAGES="gtk+-2.0" +GTK_REQUIRED_VERSION=3.0.0 +REQ_PACKAGES="gtk+-3.0" AM_PATH_GTK_2_0($GTK_REQUIRED_VERSION, :, AC_MSG_ERROR([ diff --git a/src/SConscript b/src/SConscript index e73661c..1e890a0 100644 --- a/src/SConscript +++ b/src/SConscript @@ -71,7 +71,6 @@ src_giv_widget = ["giv-widget.cc", "GivRenderer.cc", "GivStringArray.c", "giv-data.cc", - "giv-backstore.cc", "giv-markup.cc", "giv_agg_arrowhead.cc", "giv-settings.cc", @@ -149,7 +148,7 @@ if not env['SBOX']: env.Command(["giv-color-map.h", "giv-color-map.c"], "giv-color-map.vala", - ["valac -C --pkg=gtk+-2.0 -H giv-color-map.h --vapi=giv-color-map.vapi giv-color-map.vala"], + ["valac -C --pkg=gtk+-3.0 -H giv-color-map.h --vapi=giv-color-map.vapi giv-color-map.vala"], chdir=True) env.SConscript(['agg/SConscript', diff --git a/src/dov_image_viewer/SConscript b/src/dov_image_viewer/SConscript index b07000b..d783208 100644 --- a/src/dov_image_viewer/SConscript +++ b/src/dov_image_viewer/SConscript @@ -2,7 +2,7 @@ import re Import('env') -#env.ParseConfig("env PKG_CONFIG_PATH=${PKG_CONFIG_PATH} pkg-config --cflags --libs gtk+-2.0") +#env.ParseConfig("env PKG_CONFIG_PATH=${PKG_CONFIG_PATH} pkg-config --cflags --libs gtk+-3.0") # The following python subroutine and the subsequent scons command # shows how to do general template filling. This system should perhaps diff --git a/src/dov_image_viewer/dov-image-viewer-fixed.cc b/src/dov_image_viewer/dov-image-viewer-fixed.cc index 7d92058..d42b4a4 100644 --- a/src/dov_image_viewer/dov-image-viewer-fixed.cc +++ b/src/dov_image_viewer/dov-image-viewer-fixed.cc @@ -1671,8 +1671,8 @@ dov_image_viewer_redraw (DovImageViewer * self, gboolean clear_cache) if (GTK_WIDGET(self)->window) dov_image_viewer_expose_area(self, 0,0, - GTK_WIDGET(self)->allocation.width, - GTK_WIDGET(self)->allocation.height); + gtk_widget_get_allocated_width(GTK_WIDGET(self)), + gtk_widget_get_allocated_height(GTK_WIDGET(self));); return FALSE; }} #line 1679 "dov-image-viewer.cc" @@ -2123,7 +2123,7 @@ dov_image_viewer_canv_coord_to_img_coord (DovImageViewer * self, double cx, doub #if 0 if (selfp->do_flip_vertical) - *imgy = -(cy-selfp->current_y0-GTK_WIDGET(self)->allocation.height)/selfp->current_scale_y; + *imgy = -(cy-selfp->current_y0-gtk_widget_get_allocated_height(GTK_WIDGET(self));)/selfp->current_scale_y; else *imgy=(cy+selfp->current_y0)/selfp->current_scale_y; #endif @@ -2525,17 +2525,17 @@ view_changed(DovImageViewer *self, widget->window, src_x, src_y, dst_x, dst_y, - GTK_WIDGET(self)->allocation.width - abs (dx), - GTK_WIDGET(self)->allocation.height - abs (dy)); + gtk_widget_get_allocated_width(GTK_WIDGET(self)) - abs (dx), + gtk_widget_get_allocated_height(GTK_WIDGET(self)); - abs (dy)); DBG2(g_print("Filling in: dx dy = %d %d\n", dx, dy)); /* And fill in the new areas */ if (dx) { - expose_rect.x = (dx < 0) ? 0 : GTK_WIDGET(self)->allocation.width - dx; + expose_rect.x = (dx < 0) ? 0 : gtk_widget_get_allocated_width(GTK_WIDGET(self)) - dx; expose_rect.y = 0; expose_rect.width = abs(dx); - expose_rect.height = GTK_WIDGET(self)->allocation.height; + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self));; gdk_window_invalidate_rect(widget->window, &expose_rect, @@ -2547,8 +2547,8 @@ view_changed(DovImageViewer *self, if (dy) { expose_rect.x = 0; - expose_rect.y = (dy < 0) ? 0 : GTK_WIDGET(self)->allocation.height - dy;; - expose_rect.width = GTK_WIDGET(self)->allocation.width; + expose_rect.y = (dy < 0) ? 0 : gtk_widget_get_allocated_height(GTK_WIDGET(self)); - dy;; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); expose_rect.height = abs(dy); gdk_window_invalidate_rect(widget->window, @@ -2575,8 +2575,8 @@ view_changed(DovImageViewer *self, expose_rect.x = 0; expose_rect.y = 0; - expose_rect.width = GTK_WIDGET(self)->allocation.width; - expose_rect.height = GTK_WIDGET(self)->allocation.height; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self));; /* gdk_window_ref (expose_event.window); */ gdk_window_invalidate_rect(widget->window, diff --git a/src/dov_image_viewer/dov-image-viewer.cc b/src/dov_image_viewer/dov-image-viewer.cc index 1cc3666..57bc847 100644 --- a/src/dov_image_viewer/dov-image-viewer.cc +++ b/src/dov_image_viewer/dov-image-viewer.cc @@ -1671,8 +1671,8 @@ dov_image_viewer_redraw (DovImageViewer * self, gboolean clear_cache) if (GTK_WIDGET(self)->window) dov_image_viewer_expose_area(self, 0,0, - GTK_WIDGET(self)->allocation.width, - GTK_WIDGET(self)->allocation.height); + gtk_widget_get_allocated_width(GTK_WIDGET(self)), + gtk_widget_get_allocated_height(GTK_WIDGET(self));); return FALSE; }} #line 1679 "dov-image-viewer.cc" @@ -2123,7 +2123,7 @@ dov_image_viewer_canv_coord_to_img_coord (DovImageViewer * self, double cx, doub #if 0 if (selfp->do_flip_vertical) - *imgy = -(cy-selfp->current_y0-GTK_WIDGET(self)->allocation.height)/selfp->current_scale_y; + *imgy = -(cy-selfp->current_y0-gtk_widget_get_allocated_height(GTK_WIDGET(self));)/selfp->current_scale_y; else *imgy=(cy+selfp->current_y0)/selfp->current_scale_y; #endif @@ -2525,17 +2525,17 @@ view_changed(DovImageViewer *self, widget->window, src_x, src_y, dst_x, dst_y, - GTK_WIDGET(self)->allocation.width - abs (dx), - GTK_WIDGET(self)->allocation.height - abs (dy)); + gtk_widget_get_allocated_width(GTK_WIDGET(self)) - abs (dx), + gtk_widget_get_allocated_height(GTK_WIDGET(self)); - abs (dy)); DBG2(g_print("Filling in: dx dy = %d %d\n", dx, dy)); /* And fill in the new areas */ if (dx) { - expose_rect.x = (dx < 0) ? 0 : GTK_WIDGET(self)->allocation.width - dx; + expose_rect.x = (dx < 0) ? 0 : gtk_widget_get_allocated_width(GTK_WIDGET(self)) - dx; expose_rect.y = 0; expose_rect.width = abs(dx); - expose_rect.height = GTK_WIDGET(self)->allocation.height; + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self));; gdk_window_invalidate_rect(widget->window, &expose_rect, @@ -2547,8 +2547,8 @@ view_changed(DovImageViewer *self, if (dy) { expose_rect.x = 0; - expose_rect.y = (dy < 0) ? 0 : GTK_WIDGET(self)->allocation.height - dy;; - expose_rect.width = GTK_WIDGET(self)->allocation.width; + expose_rect.y = (dy < 0) ? 0 : gtk_widget_get_allocated_height(GTK_WIDGET(self)); - dy;; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); expose_rect.height = abs(dy); gdk_window_invalidate_rect(widget->window, @@ -2575,8 +2575,8 @@ view_changed(DovImageViewer *self, expose_rect.x = 0; expose_rect.y = 0; - expose_rect.width = GTK_WIDGET(self)->allocation.width; - expose_rect.height = GTK_WIDGET(self)->allocation.height; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self));; /* gdk_window_ref (expose_event.window); */ gdk_window_invalidate_rect(widget->window, diff --git a/src/dov_image_viewer/dov-image-viewer.gob b/src/dov_image_viewer/dov-image-viewer.gob index be6f96d..4d8aeeb 100644 --- a/src/dov_image_viewer/dov-image-viewer.gob +++ b/src/dov_image_viewer/dov-image-viewer.gob @@ -1144,8 +1144,8 @@ class Dov:Image:Viewer from Gtk:Widget if (GTK_WIDGET(self)->window) dov_image_viewer_expose_area(self, 0,0, - GTK_WIDGET(self)->allocation.width, - GTK_WIDGET(self)->allocation.height); + gtk_widget_get_allocated_width(GTK_WIDGET(self)), + gtk_widget_get_allocated_height(GTK_WIDGET(self));); return FALSE; } @@ -1409,7 +1409,7 @@ class Dov:Image:Viewer from Gtk:Widget #if 0 if (selfp->do_flip_vertical) - *imgy = -(cy-selfp->current_y0-GTK_WIDGET(self)->allocation.height)/selfp->current_scale_y; + *imgy = -(cy-selfp->current_y0-gtk_widget_get_allocated_height(GTK_WIDGET(self));)/selfp->current_scale_y; else *imgy=(cy+selfp->current_y0)/selfp->current_scale_y; #endif @@ -1700,17 +1700,17 @@ view_changed(DovImageViewer *self, widget->window, src_x, src_y, dst_x, dst_y, - GTK_WIDGET(self)->allocation.width - abs (dx), - GTK_WIDGET(self)->allocation.height - abs (dy)); + gtk_widget_get_allocated_width(GTK_WIDGET(self)) - abs (dx), + gtk_widget_get_allocated_height(GTK_WIDGET(self)); - abs (dy)); DBG2(g_print("Filling in: dx dy = %d %d\n", dx, dy)); /* And fill in the new areas */ if (dx) { - expose_rect.x = (dx < 0) ? 0 : GTK_WIDGET(self)->allocation.width - dx; + expose_rect.x = (dx < 0) ? 0 : gtk_widget_get_allocated_width(GTK_WIDGET(self)) - dx; expose_rect.y = 0; expose_rect.width = abs(dx); - expose_rect.height = GTK_WIDGET(self)->allocation.height; + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self));; gdk_window_invalidate_rect(widget->window, &expose_rect, @@ -1722,8 +1722,8 @@ view_changed(DovImageViewer *self, if (dy) { expose_rect.x = 0; - expose_rect.y = (dy < 0) ? 0 : GTK_WIDGET(self)->allocation.height - dy;; - expose_rect.width = GTK_WIDGET(self)->allocation.width; + expose_rect.y = (dy < 0) ? 0 : gtk_widget_get_allocated_height(GTK_WIDGET(self)); - dy; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); expose_rect.height = abs(dy); gdk_window_invalidate_rect(widget->window, @@ -1750,8 +1750,8 @@ view_changed(DovImageViewer *self, expose_rect.x = 0; expose_rect.y = 0; - expose_rect.width = GTK_WIDGET(self)->allocation.width; - expose_rect.height = GTK_WIDGET(self)->allocation.height; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self)); /* gdk_window_ref (expose_event.window); */ gdk_window_invalidate_rect(widget->window, diff --git a/src/dov_image_viewer/dov-image-viewer.gob.save b/src/dov_image_viewer/dov-image-viewer.gob.save index 7afe54f..bf76e4b 100644 --- a/src/dov_image_viewer/dov-image-viewer.gob.save +++ b/src/dov_image_viewer/dov-image-viewer.gob.save @@ -205,7 +205,7 @@ class Dov:Image:Viewer from Gtk:Widget } - old_cnv_w = GTK_WIDGET(self)->allocation.width; + old_cnv_w = gtk_widget_get_allocated_width(GTK_WIDGET(self)); old_cnv_h = selfp->canvas_height; selfp->canvas_width = widget->allocation.width; selfp->canvas_height = widget->allocation.height; @@ -219,7 +219,7 @@ class Dov:Image:Viewer from Gtk:Widget double scale_y = selfp->current_scale_y; int img_w = (int)(gdk_pixbuf_get_width(selfp->image)*scale_x); int img_h = (int)(gdk_pixbuf_get_height(selfp->image)*scale_y); - int cnv_w = GTK_WIDGET(self)->allocation.width; + int cnv_w = gtk_widget_get_allocated_width(GTK_WIDGET(self)); int cnv_h = GTK_WIDGET(self)->allocation.height; DBG(fprintf(stderr,"Resize: x0 y0 img_w img_h cnv_w cnv_h = %f %f %d %d %d %d\n", @@ -461,7 +461,7 @@ class Dov:Image:Viewer from Gtk:Widget if (selfp->image) { /* Canvas size */ - int cnv_w = GTK_WIDGET(self)->allocation.width; + int cnv_w = gtk_widget_get_allocated_width(GTK_WIDGET(self)); int cnv_h = GTK_WIDGET(self)->allocation.height; int img_w, img_h; /* Image's size (pixels) */ int img_x0 = 0; @@ -776,7 +776,7 @@ class Dov:Image:Viewer from Gtk:Widget // Flip the scale and shift if we are flipped if (selfp->do_flip_horizontal) { - int w = GTK_WIDGET(self)->allocation.width; + int w = gtk_widget_get_allocated_width(GTK_WIDGET(self)); signal_shift_x = selfp->current_x0 + w - exp_x0; signal_scale_x = - signal_scale_x; } @@ -849,7 +849,7 @@ class Dov:Image:Viewer from Gtk:Widget if (GTK_WIDGET(self)->window) dov_image_viewer_expose_area(self, 0,0, - GTK_WIDGET(self)->allocation.width, + gtk_widget_get_allocated_width(GTK_WIDGET(self)), GTK_WIDGET(self)->allocation.height); return FALSE; } @@ -872,7 +872,7 @@ class Dov:Image:Viewer from Gtk:Widget double new_y) { double old_scale_x, old_scale_y, old_x0, old_y0, new_x0, new_y0; - int w = GTK_WIDGET(self)->allocation.width; + int w = gtk_widget_get_allocated_width(GTK_WIDGET(self)); int h = GTK_WIDGET(self)->allocation.height; printf("zoom_around_fixed_point: nsx nsy old_x old_y new_x new_y = %f %f %f %f %f %f\n", new_scale_x, new_scale_y, @@ -1074,7 +1074,7 @@ class Dov:Image:Viewer from Gtk:Widget { if (selfp->do_flip_horizontal) { - int w = GTK_WIDGET(self)->allocation.width; + int w = gtk_widget_get_allocated_width(GTK_WIDGET(self)); *imgx = (selfp->current_x0+w-cx)/selfp->current_scale_x; } else @@ -1093,7 +1093,7 @@ class Dov:Image:Viewer from Gtk:Widget { if (selfp->do_flip_horizontal) { - int w = GTK_WIDGET(self)->allocation.width; + int w = gtk_widget_get_allocated_width(GTK_WIDGET(self)); *canvx = (selfp->current_x0+w-imgx*selfp->current_scale_x); } else @@ -1253,7 +1253,7 @@ view_changed(DovImageViewer *self, || (selfp->scroll_width > 0 && selfp->scroll_height > 0) ) { - int cwidth = GTK_WIDGET(self)->allocation.width; + int cwidth = gtk_widget_get_allocated_width(GTK_WIDGET(self)); int cheight = GTK_WIDGET(self)->allocation.height; double height, width; @@ -1328,14 +1328,14 @@ view_changed(DovImageViewer *self, widget->window, src_x, src_y, dst_x, dst_y, - GTK_WIDGET(self)->allocation.width - abs (dx), + gtk_widget_get_allocated_width(GTK_WIDGET(self)) - abs (dx), GTK_WIDGET(self)->allocation.height - abs (dy)); DBG2(g_print("Filling in: dx dy = %d %d\n", dx, dy)); /* And fill in the new areas */ if (dx) { - expose_rect.x = (dx < 0) ? 0 : GTK_WIDGET(self)->allocation.width - dx; + expose_rect.x = (dx < 0) ? 0 : gtk_widget_get_allocated_width(GTK_WIDGET(self)) - dx; expose_rect.y = 0; expose_rect.width = abs(dx); expose_rect.height = GTK_WIDGET(self)->allocation.height; @@ -1350,8 +1350,8 @@ view_changed(DovImageViewer *self, if (dy) { expose_rect.x = 0; - expose_rect.y = (dy < 0) ? 0 : GTK_WIDGET(self)->allocation.height - dy;; - expose_rect.width = GTK_WIDGET(self)->allocation.width; + expose_rect.y = (dy < 0) ? 0 : GTK_WIDGET(self)->allocation.height - dy; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); expose_rect.height = abs(dy); gdk_window_invalidate_rect(widget->window, @@ -1378,7 +1378,7 @@ view_changed(DovImageViewer *self, expose_rect.x = 0; expose_rect.y = 0; - expose_rect.width = GTK_WIDGET(self)->allocation.width; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); expose_rect.height = GTK_WIDGET(self)->allocation.height; /* gdk_window_ref (expose_event.window); */ @@ -1430,7 +1430,7 @@ zoom_in(DovImageViewer *self, int x, int y) zoom_factor[0], zoom_factor[1], x, y, - GTK_WIDGET(self)->allocation.width/2, + gtk_widget_get_allocated_width(GTK_WIDGET(self))/2, GTK_WIDGET(self)->allocation.height/2); return 1; @@ -1462,9 +1462,9 @@ zoom_out(DovImageViewer *self, int x, int y) dov_image_viewer_zoom_around_fixed_point(self, zoom_factor[0], zoom_factor[1], - GTK_WIDGET(self)->allocation.width/2, + gtk_widget_get_allocated_width(GTK_WIDGET(self))/2, GTK_WIDGET(self)->allocation.height/2, - GTK_WIDGET(self)->allocation.width/2, + gtk_widget_get_allocated_width(GTK_WIDGET(self))/2, GTK_WIDGET(self)->allocation.height/2); return 1; } @@ -1566,7 +1566,7 @@ static void update_adjustments(DovImageViewer *self) selfp->hadjustment->lower = 0; selfp->hadjustment->upper = 1.0; selfp->hadjustment->step_increment = 0.01; - selfp->hadjustment->page_size = GTK_WIDGET(self)->allocation.width / (selfp->scroll_width * selfp->current_scale_x); + selfp->hadjustment->page_size = gtk_widget_get_allocated_width(GTK_WIDGET(self)) / (selfp->scroll_width * selfp->current_scale_x); double s = selfp->current_scale_x; //*** if (selfp->do_flip_horizontal) //*** s = -s; diff --git a/src/dovtk-lasso.c b/src/dovtk-lasso.c index 80a023a..1c84918 100644 --- a/src/dovtk-lasso.c +++ b/src/dovtk-lasso.c @@ -17,16 +17,16 @@ typedef struct { typedef struct { DovtkLasso parent; - gulong expose_handler_id; + gulong draw_handler_id; GtkWidget *widget; DovtkLassoDrawing drawing_cb; DovtkLassoRectangleList *old_rect_list; gpointer user_data; } DovtkLassoPrivate ; -static int lasso_cb_expose(GtkWidget *widget, - GdkEventExpose *event, - gpointer user_data); +static int lasso_cb_draw(GtkWidget *widget, + cairo_t *cr, + gpointer user_data); static DovtkLassoRectangleList *dovtk_lasso_rectangle_list_new(int num_rectangles); static void dovtk_lasso_rectangle_list_destroy(DovtkLassoRectangleList *rectangcle_list); @@ -38,10 +38,10 @@ DovtkLasso *dovtk_lasso_create(GtkWidget *widget, // This binding doesn't work if the default expose handler // returns TRUE! - selfp->expose_handler_id + selfp->draw_handler_id = g_signal_connect_after(widget, - "expose-event", - G_CALLBACK(lasso_cb_expose), + "draw", + G_CALLBACK(lasso_cb_draw), selfp); selfp->widget = widget; selfp->drawing_cb = drawing_cb; @@ -54,7 +54,7 @@ void dovtk_lasso_destroy(DovtkLasso *lasso) { DovtkLassoPrivate *selfp = (DovtkLassoPrivate*)lasso; g_signal_handler_disconnect(selfp->widget, - selfp->expose_handler_id); + selfp->draw_handler_id); // This gets rid of the overlay. Is this always needed? dovtk_lasso_update(lasso); @@ -70,9 +70,9 @@ void dovtk_lasso_clear_exprects(DovtkLasso *lasso) selfp->old_rect_list = dovtk_lasso_rectangle_list_new(0); } -static int lasso_cb_expose(GtkWidget *widget, - GdkEventExpose *event, - gpointer user_data) +static int lasso_cb_draw(GtkWidget *widget, + cairo_t *cr, + gpointer user_data) { DovtkLassoPrivate *selfp = (DovtkLassoPrivate*)user_data; // printf("dovtk-lasso.c: expose\n"); @@ -84,16 +84,8 @@ static int lasso_cb_expose(GtkWidget *widget, g_signal_handler_unblock(widget, selfp->expose_handler_id); #endif - cairo_t *cr; - cr = gdk_cairo_create(widget->window); - cairo_rectangle(cr, event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip(cr); - selfp->drawing_cb(cr, DOVTK_LASSO_CONTEXT_PAINT, selfp->user_data); - cairo_destroy(cr); - return TRUE; } @@ -104,8 +96,8 @@ static DovtkLassoRectangleList *get_exprects_from_drawing(DovtkLassoPrivate *sel // Call drawing_cb to and use it to generate the rectangle list DovtkLassoRectangleList *rect_list = NULL; int scale_factor = 32; - int low_res_width = (selfp->widget->allocation.width+scale_factor-1) / scale_factor; - int low_res_height = (selfp->widget->allocation.height+scale_factor-1) / scale_factor; + int low_res_width = (gtk_widget_get_allocated_width(selfp->widget)+scale_factor-1) / scale_factor; + int low_res_height = (gtk_widget_get_allocated_height(selfp->widget)+scale_factor-1) / scale_factor; // This should be created in the creation of DovtkLasso cairo_t *cr = NULL; @@ -195,7 +187,7 @@ void dovtk_lasso_update(DovtkLasso *lasso) printf("Invalidate region (%d,%d,%d,%d).\n", rect.x,rect.y,rect.width,rect.height); #endif - gdk_window_invalidate_rect(selfp->widget->window, + gdk_window_invalidate_rect(gtk_widget_get_window(selfp->widget), &rect, TRUE); } diff --git a/src/giv-calibrate-dialog.gob b/src/giv-calibrate-dialog.gob index 642ca5a..f89ebb5 100644 --- a/src/giv-calibrate-dialog.gob +++ b/src/giv-calibrate-dialog.gob @@ -60,7 +60,7 @@ class Giv:Calibrate:Dialog from Gtk:Dialog { int row_idx=0; - w_vbox = GTK_DIALOG(self)->vbox; + w_vbox = gtk_dialog_get_content_area(GTK_DIALOG(self)); w_table = gtk_table_new(3,2, false); gtk_box_pack_start(GTK_BOX(w_vbox), w_table, FALSE, FALSE, 0); @@ -72,13 +72,13 @@ class Giv:Calibrate:Dialog from Gtk:Dialog { GtkAttachOptions(GTK_FILL), GtkAttachOptions(0), 0,0); - GtkWidget *w_combo_measure = gtk_combo_box_new_text(); + GtkWidget *w_combo_measure = gtk_combo_box_text_new(); g_signal_connect(w_combo_measure,"changed", G_CALLBACK(cb_combo_changed), self); selfp->w_combo_measure = w_combo_measure; - gtk_combo_box_append_text(GTK_COMBO_BOX(w_combo_measure), "Pixel"); - gtk_combo_box_append_text(GTK_COMBO_BOX(w_combo_measure), "Last measure"); - gtk_combo_box_append_text(GTK_COMBO_BOX(w_combo_measure), "Image width"); - gtk_combo_box_append_text(GTK_COMBO_BOX(w_combo_measure), "Image height"); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(w_combo_measure), "Pixel"); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(w_combo_measure), "Last measure"); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(w_combo_measure), "Image width"); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(w_combo_measure), "Image height"); gtk_combo_box_set_active(GTK_COMBO_BOX(w_combo_measure), 0); gtk_table_attach(GTK_TABLE(w_table), w_combo_measure, diff --git a/src/giv-color-map.vala b/src/giv-color-map.vala index b8dd74a..4fca052 100644 --- a/src/giv-color-map.vala +++ b/src/giv-color-map.vala @@ -46,7 +46,8 @@ public class GivColorMap : DrawingArea { public void redraw() { queue_draw_area(0,0, - allocation.width, allocation.height); + get_allocated_width(), + get_allocated_height()); } public void show_text(Cairo.Context cr, @@ -145,16 +146,10 @@ public class GivColorMap : DrawingArea { return ""; } - public override bool expose_event(Gdk.EventExpose event) + public override bool draw(Context cr) { - var cr = Gdk.cairo_create (this.window); - var w = allocation.width; - var h = allocation.height; - - // Set clipping area to minimize redrawing - cr.rectangle (event.area.x, event.area.y, - event.area.width, event.area.height); - cr.clip (); + var w = get_allocated_width(); + var h = get_allocated_height(); if (!is_horizontal) { // Draw 256 with colors from start to end diff --git a/src/giv-contrast.gob b/src/giv-contrast.gob index 09ca379..8cc531e 100644 --- a/src/giv-contrast.gob +++ b/src/giv-contrast.gob @@ -66,7 +66,7 @@ class Giv:Contrast from Gtk:Dialog { gtk_window_set_default_size (GTK_WINDOW (self), 400, 350); - w_vbox = GTK_DIALOG(self)->vbox; + w_vbox = gtk_dialog_get_content_area(GTK_DIALOG(self)); w_frame = gtk_frame_new("Contrast"); gtk_box_pack_start(GTK_BOX(w_vbox), w_frame, FALSE, FALSE, 0); @@ -302,10 +302,10 @@ static gint cb_histo_scroll_event(GtkWidget *widget, delta_value = -delta_value; double old_value = gtk_adjustment_get_value(adjustment); double new_value = old_value + delta_value; - if (new_value < adjustment->lower) - new_value = adjustment->lower; - if (new_value > adjustment->upper-adjustment->page_size) - new_value = adjustment->upper-adjustment->page_size; + if (new_value < gtk_adjustment_get_lower(adjustment)) + new_value = gtk_adjustment_get_lower(adjustment); + if (new_value > gtk_adjustment_get_upper(adjustment)-gtk_adjustment_get_page_size(adjustment)) + new_value = gtk_adjustment_get_upper(adjustment)-gtk_adjustment_get_page_size(adjustment); if (new_value != old_value) { gtk_adjustment_set_value(adjustment, new_value); diff --git a/src/giv-histo.gob b/src/giv-histo.gob index 7b61103..d22b0ac 100644 --- a/src/giv-histo.gob +++ b/src/giv-histo.gob @@ -124,20 +124,15 @@ class Giv:Histo from Gtk:Drawing:Area { } override (Gtk:Widget) gboolean - expose_event (Gtk:Widget *_self, - Gdk:Event:Expose *event) + draw (Gtk:Widget *_self, + cairo_t *cr) { GivHisto *self = GIV_HISTO(_self); - cairo_t *cr = gdk_cairo_create(GTK_WIDGET(self)->window); - int width = GTK_WIDGET(self)->allocation.width; - int height = GTK_WIDGET(self)->allocation.height; + int width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); + int height = gtk_widget_get_allocated_height(GTK_WIDGET(self)); double histo_width = width - 2*selfp->margin; double histo_height = height - 2*selfp->margin; - cairo_rectangle(cr, event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip(cr); - cairo_set_source_rgb(cr, 0.4,0.4,0.5); // short cuts @@ -213,7 +208,7 @@ class Giv:Histo from Gtk:Drawing:Area { double x1 = selfp->cursor_x1; double x2 = selfp->cursor_x2; double xc = 0.5*(x1+x2); - int height = GTK_WIDGET(self)->allocation.height; + int height = gtk_widget_get_allocated_height(GTK_WIDGET(self)); double h1 = 5; double w1 = 5; double r = 5; @@ -321,7 +316,7 @@ class Giv:Histo from Gtk:Drawing:Area { { double x1 = selfp->cursor_x1; double x2 = selfp->cursor_x2; - int height = GTK_WIDGET(self)->allocation.height; + int height = gtk_widget_get_allocated_height(GTK_WIDGET(self)); double h1 = 5; double w1 = 5; double xc = 0.5*(x1+x2); @@ -370,7 +365,7 @@ class Giv:Histo from Gtk:Drawing:Area { private double canvas_x_to_gl(self, double x) { - int width = GTK_WIDGET(self)->allocation.width; + int width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); double histo_width = width - 2*selfp->margin; // short cuts double min = selfp->img_gl_min; @@ -382,7 +377,7 @@ class Giv:Histo from Gtk:Drawing:Area { private double gl_to_canvas_x(self, double gl) { - int width = GTK_WIDGET(self)->allocation.width; + int width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); double histo_width = width - 2*selfp->margin; // short cuts double min = selfp->img_gl_min; diff --git a/src/giv-info.gob b/src/giv-info.gob index c604335..de20e15 100644 --- a/src/giv-info.gob +++ b/src/giv-info.gob @@ -44,7 +44,7 @@ class Giv:Info from Gtk:Dialog GTK_RESPONSE_ACCEPT, NULL); - vbox = GTK_DIALOG(self)->vbox; + vbox = gtk_dialog_get_content_area(GTK_DIALOG(self)); selfp->w_scrolled_window = gtk_scrolled_window_new (NULL, NULL); selfp->vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(selfp->w_scrolled_window)); g_signal_connect(selfp->vadj, "changed", @@ -150,7 +150,7 @@ static void on_value_changed(GtkAdjustment *adjustment, gpointer user_data) { GivInfo *self = GIV_INFO(user_data); - selfp->need_readjust_vadj = fabs(selfp->vadj->value - selfp->preserve_vadj_value) >= selfp->vadj->step_increment/2; + selfp->need_readjust_vadj = fabs(gtk_adjustment_get_value((selfp->vadj)) - selfp->preserve_vadj_value) >= gtk_adjustment_get_step_increment(selfp->vadj)/2; } %} diff --git a/src/giv-mark-tree-dialog.gob b/src/giv-mark-tree-dialog.gob index 485d0cb..13514f1 100644 --- a/src/giv-mark-tree-dialog.gob +++ b/src/giv-mark-tree-dialog.gob @@ -61,7 +61,7 @@ class Giv:Mark:Tree:Dialog from Gtk:Dialog { gtk_window_set_default_size (GTK_WINDOW (self), 400, 350); - vbox = GTK_DIALOG(self)->vbox; + vbox = gtk_dialog_get_content_area(GTK_DIALOG(self)); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, diff --git a/src/giv-settings-editor.gob b/src/giv-settings-editor.gob index 6db9fee..38bb708 100644 --- a/src/giv-settings-editor.gob +++ b/src/giv-settings-editor.gob @@ -44,11 +44,11 @@ class Giv:Settings:Editor from Gtk:Dialog // Use HIG recommendation using frames without border. GtkWidget *w_frame = hig_like_frame_new("File Browsing"); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(self)->vbox), + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(self))), w_frame, FALSE, FALSE, 0); GtkWidget *w_table = gtk_table_new(8,8,FALSE); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(self)->vbox), + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(self))), w_table, FALSE, FALSE, 0); // Whether to hide names diff --git a/src/giv-widget.gob b/src/giv-widget.gob index 0a43b67..40ecde1 100644 --- a/src/giv-widget.gob +++ b/src/giv-widget.gob @@ -72,7 +72,6 @@ static void cb_set_vlock(gboolean vlock, %} %privateheader{ -#include "giv-backstore.h" %} class Giv:Widget from Gtk:Image:Viewer @@ -228,15 +227,15 @@ class Giv:Widget from Gtk:Image:Viewer int balloon_x, balloon_y; if (mark_set->balloon_string) - gtk_label_set(GTK_LABEL(selfp->w_balloon_label), + gtk_label_set_text(GTK_LABEL(selfp->w_balloon_label), mark_set->balloon_string->str); else if (mark_set->path_name) - gtk_label_set(GTK_LABEL(selfp->w_balloon_label), + gtk_label_set_text(GTK_LABEL(selfp->w_balloon_label), mark_set->path_name); else { GString *balloon_string = g_string_new(""); g_string_sprintfa(balloon_string, "label = %d", label); - gtk_label_set(GTK_LABEL(selfp->w_balloon_label), + gtk_label_set_text(GTK_LABEL(selfp->w_balloon_label), balloon_string->str); g_string_free(balloon_string, TRUE); } @@ -691,10 +690,9 @@ cb_image_annotate(GivWidget *self, if (!selfp->is_dragging && selfp->do_show_marks) renderer.paint(); - gint li_width, li_height; - gdk_window_get_size(GTK_WIDGET(self)->window, - &li_width, &li_height - ); + gint li_width = gdk_window_get_width(gtk_widget_get_window(GTK_WIDGET(self))); + gint li_height = gdk_window_get_height(gtk_widget_get_window(GTK_WIDGET(self))); + if (selfp->do_show_cross_hair && selfp->img_org) { int w = gdk_pixbuf_get_width(selfp->img_org); int h = gdk_pixbuf_get_height(selfp->img_org); diff --git a/src/giv-win.gob b/src/giv-win.gob index 0c8c33b..61cbd57 100644 --- a/src/giv-win.gob +++ b/src/giv-win.gob @@ -761,7 +761,7 @@ class Giv:Win from Gtk:Window num_top_levels++; g_signal_connect (G_OBJECT(self), "destroy", - GTK_SIGNAL_FUNC (giv_win_destroy), self); + G_CALLBACK (giv_win_destroy), self); w_vbox = gtk_vbox_new(0,0); @@ -1417,12 +1417,12 @@ class Giv:Win from Gtk:Window new_title = g_strdup_printf("giv: %s", basename); if (selfp->img_org &&selfp->img_org->depth>1) - gtk_label_set(GTK_LABEL(selfp->w_info_label), - slipprintf("Loaded: %s, Slice %d", - basename, selfp->current_slice+1)); + gtk_label_set_text(GTK_LABEL(selfp->w_info_label), + slipprintf("Loaded: %s, Slice %d", + basename, selfp->current_slice+1)); else - gtk_label_set(GTK_LABEL(selfp->w_info_label), - slipprintf("Loaded: %s", basename)); + gtk_label_set_text(GTK_LABEL(selfp->w_info_label), + slipprintf("Loaded: %s", basename)); gtk_window_set_title(GTK_WINDOW(self), new_title); @@ -1537,8 +1537,8 @@ class Giv:Win from Gtk:Window new_height = (int)(0.75*s_height); // Get current scrolled win - int old_width = selfp->w_scrolled_win->allocation.width; - int old_height = selfp->w_scrolled_win->allocation.height; + int old_width = gtk_widget_get_allocated_width(selfp->w_scrolled_win); + int old_height = gtk_widget_get_allocated_height(selfp->w_scrolled_win); #if 0 gtk_widget_set_size_request(GTK_WIDGET(selfp->w_scrolled_win), new_width, new_height); @@ -1547,14 +1547,14 @@ class Giv:Win from Gtk:Window #if 0 // TBD - add everything that is not part of the window if (GTK_WIDGET_VISIBLE(selfp->w_menubox)) - new_height+= selfp->w_menubox->allocation.height; - new_height+= selfp->w_info_label->allocation.height; + new_height+= selfp->w_menubox->get_allocated_height(); + new_height+= selfp->w_info_label->get_allocated_height(); #endif gtk_image_viewer_one_shot_block_fill_on_resize(GTK_IMAGE_VIEWER(selfp->w_imgv)); - int old_window_width = GTK_WIDGET(self)->allocation.width; - int old_window_height = GTK_WIDGET(self)->allocation.height; + int old_window_width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); + int old_window_height = gtk_widget_get_allocated_height(GTK_WIDGET(self)); gtk_window_resize(GTK_WINDOW(self), old_window_width + (new_width-old_width), old_window_height + (new_height-old_height) ); @@ -1831,7 +1831,7 @@ cb_button_release_event (GtkWidget * widget, selfp->measure_y2); char label[64]; sprintf(label, "%d marks in rectangle", num_marks); - gtk_label_set(GTK_LABEL(selfp->w_info_label), label); + gtk_label_set_text(GTK_LABEL(selfp->w_info_label), label); } selfp->picking_mode = 0; selfp->measure_point_index = 0; @@ -1888,32 +1888,32 @@ cb_key_press_event (GtkWidget * widget, giv_win_shrink_wrap(self); return 1; } - if (k==GDK_Escape) + if (k==GDK_KEY_Escape) { if (selfp->do_pick_coordinate) giv_win_json_pick_reply(self, "Aborted", -1,-1); } if (// reload - k == GDK_KP_Enter - || k == GDK_Return + k == GDK_KEY_KP_Enter + || k == GDK_KEY_Return // forward || k == ' ' - || k == GDK_Right - || k == GDK_KP_Right + || k == GDK_KEY_Right + || k == GDK_KEY_KP_Right // backward - || k == GDK_BackSpace - || k == GDK_Left - || k == GDK_KP_Left + || k == GDK_KEY_BackSpace + || k == GDK_KEY_Left + || k == GDK_KEY_KP_Left ) { int index_delta = 0; if (k == ' ' - || k == GDK_Right - || k == GDK_KP_Right) + || k == GDK_KEY_Right + || k == GDK_KEY_KP_Right) index_delta = 1; - else if (k == GDK_BackSpace - || k == GDK_Left - || k == GDK_KP_Left ) + else if (k == GDK_KEY_BackSpace + || k == GDK_KEY_Left + || k == GDK_KEY_KP_Left ) index_delta = -1; #if 0 app_error(self, @@ -1949,15 +1949,15 @@ cb_key_press_event (GtkWidget * widget, // giv_window_set_current_file(self, new_index); return 1; } - if (k == GDK_Up - || k == GDK_KP_Up - || k == GDK_Down - || k == GDK_KP_Down + if (k == GDK_KEY_Up + || k == GDK_KEY_KP_Up + || k == GDK_KEY_Down + || k == GDK_KEY_KP_Down ) { int s = selfp->cb_names->len; int dir = 1; - if (k == GDK_Down - || k == GDK_KP_Down) + if (k == GDK_KEY_Down + || k == GDK_KEY_KP_Down) dir = -1; // Check if multislice @@ -2159,7 +2159,7 @@ cb_motion_event(GtkWidget *widget, #endif if (do_update_label) - gtk_label_set(GTK_LABEL(selfp->w_info_label), info_label->str); + gtk_label_set_text(GTK_LABEL(selfp->w_info_label), info_label->str); g_string_free(info_label, TRUE); selfp->last_move_x = x; @@ -2173,7 +2173,7 @@ cb_motion_event(GtkWidget *widget, static void cb_view_menu_bar (GtkAction *action, gpointer data) { GivWin *self = GIV_WIN(data); - if (GTK_WIDGET_VISIBLE(selfp->w_menubox)) + if (gtk_widget_is_visible(selfp->w_menubox)) gtk_widget_hide(selfp->w_menubox); else gtk_widget_show(selfp->w_menubox); @@ -2499,7 +2499,7 @@ cb_menu_count_marks (GtkAction *action, gpointer data) //selfp->back_store = NULL; dovtk_lasso_destroy(selfp->lasso); selfp->lasso = NULL; - gdk_window_set_cursor(selfp->w_imgv->window, NULL); + gdk_window_set_cursor(gtk_widget_get_window(selfp->w_imgv), NULL); selfp->current_cursor = NULL; } @@ -2558,14 +2558,15 @@ menu_measure_distance (GivWin *self, GtkAction *action, int measure_type) else dovtk_lasso_update(selfp->lasso); } - else { + else + { // TBD - reset the menus. //free_giv_backstore (selfp->back_store); //selfp->back_store = NULL; - gdk_window_set_cursor(selfp->w_imgv->window, NULL); + gdk_window_set_cursor(gtk_widget_get_window(selfp->w_imgv), NULL); dovtk_lasso_destroy(selfp->lasso); selfp->lasso = NULL; - } + } return; } @@ -2619,7 +2620,7 @@ cb_calib_changed(GtkWidget *calib_dialog, GString *info_label = g_string_new(""); giv_win_update_pixelsize_info(self, info_label); - gtk_label_set(GTK_LABEL(selfp->w_info_label), info_label->str); + gtk_label_set_text(GTK_LABEL(selfp->w_info_label), info_label->str); g_string_free(info_label, TRUE); } @@ -2779,7 +2780,7 @@ cb_menu_open (GtkAction *action, gpointer data) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (selfp->w_filechooser), last_image_path); - g_signal_connect (GTK_OBJECT (selfp->w_filechooser), + g_signal_connect (G_OBJECT (selfp->w_filechooser), "response", G_CALLBACK (cb_menu_open_response), self); @@ -2849,9 +2850,10 @@ cb_menu_export_response(GtkWidget *dialog, { GivWin *self = GIV_WIN(user_data); - if (response == GTK_RESPONSE_ACCEPT) { - int width = selfp->w_imgv->allocation.width; - int height = selfp->w_imgv->allocation.height; + if (response == GTK_RESPONSE_ACCEPT) + { + int width = gtk_widget_get_allocated_width(GTK_WIDGET(selfp->w_imgv)); + int height = gtk_widget_get_allocated_height(GTK_WIDGET(selfp->w_imgv)); gchar *selected_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(selfp->w_filechooser)); @@ -2884,7 +2886,7 @@ cb_menu_export (GtkAction *action, gpointer data) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (selfp->w_filechooser), last_image_path); - g_signal_connect (GTK_OBJECT (selfp->w_filechooser), + g_signal_connect (G_OBJECT (selfp->w_filechooser), "response", G_CALLBACK (cb_menu_export_response), self); @@ -2928,12 +2930,13 @@ void draw_to_cairo(cairo_t *cr, &shift_x, &shift_y); // TBD: * turn on cairo clip area // * draw image - int cnv_width = selfp->w_imgv->allocation.width; - int cnv_height = selfp->w_imgv->allocation.height; - if (cnv_width <= 1) { + int cnv_width = gtk_widget_get_allocated_width(selfp->w_imgv); + int cnv_height = gtk_widget_get_allocated_height(selfp->w_imgv); + if (cnv_width <= 1) + { cnv_width = width; cnv_height = height; - } + } cairo_set_line_width (cr, 2); cairo_rectangle(cr, 0,0,cnv_width, cnv_height); @@ -3061,7 +3064,7 @@ void draw_page (GtkPrintOperation *operation, height = gtk_print_context_get_height (context); // * draw image - int cnv_width = selfp->w_imgv->allocation.width; + int cnv_width = gtk_widget_get_allocated_width(selfp->w_imgv); // shift adjust for printing double draw_width = 150; // mm @@ -3134,7 +3137,7 @@ cb_menu_about(GtkAction *action, vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about_window)->vbox), vbox, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG (about_window))), vbox, FALSE, FALSE, 0); icon = gdk_pixbuf_new_from_inline(sizeof(logo_150_inline), logo_150_inline, @@ -3214,7 +3217,7 @@ cb_menu_copyright(GtkAction *action, // Insert copyright here scroll_window = gtk_scrolled_window_new(NULL, NULL); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(copyright_window)->vbox), + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(copyright_window))), scroll_window, TRUE, TRUE, 0); w_text = gtk_text_view_new (); @@ -3673,7 +3676,7 @@ cb_file_list_drag_data_received (GtkWidget *widget, // uris and then use common loading code... if (uris == NULL) { uris = g_new0(gchar*, 2); - char *sdata = g_strdup((gchar*)selection_data->data); + char *sdata = g_strdup((gchar*)gtk_selection_data_get_data(selection_data)); char *nl_pos; if ((nl_pos = g_strstr_len(sdata, strlen(sdata), "\r"))) *nl_pos = 0; @@ -3770,8 +3773,8 @@ fit_marks_in_window(GivWin *self) } else { margin= 10; - int cnv_width = selfp->w_imgv->allocation.width; - int cnv_height = selfp->w_imgv->allocation.height; + int cnv_width = gtk_widget_get_allocated_width(selfp->w_imgv); + int cnv_height = gtk_widget_get_allocated_height(selfp->w_imgv); double aspect_ratio = 1.0*cnv_height/cnv_width; // The following is a hack around the problem of too thin @@ -4108,7 +4111,7 @@ draw_caliper(GivWin *self, } if (measure_type == MEASURE_TYPE_VERTICAL) { - int w = selfp->w_scrolled_win->allocation.width; + int w = gtk_widget_get_allocated_width(selfp->w_scrolled_win); if (lasso_context == DOVTK_LASSO_CONTEXT_PAINT) { cairo_matrix_init_translate(&matrix, 0, y0); @@ -4134,7 +4137,7 @@ draw_caliper(GivWin *self, cairo_fill(cr); } else if (measure_type == MEASURE_TYPE_HORIZONTAL) { - int h = selfp->w_scrolled_win->allocation.height; + int h = gtk_widget_get_allocated_width(selfp->w_scrolled_win); if (lasso_context == DOVTK_LASSO_CONTEXT_PAINT) { cairo_matrix_init_rotate(&matrix, MY_PI/2); @@ -4489,7 +4492,8 @@ static int cmd_giv_string(GLibJsonRpcServer *server, static gboolean cb_idle_set_cursor(gpointer user_data) { GivWin *self = (GivWin*)user_data; - gdk_window_set_cursor(selfp->w_imgv->window, selfp->current_cursor); + gdk_window_set_cursor(gtk_widget_get_window(selfp->w_imgv), + selfp->current_cursor); return false; } @@ -4535,7 +4539,7 @@ static void giv_win_json_pick_reply(GivWin *self, const gchar *error, double x, error_response); } - gdk_window_set_cursor(selfp->w_imgv->window, NULL); + gdk_window_set_cursor(gtk_widget_get_window(selfp->w_imgv), NULL); selfp->current_cursor = NULL; } diff --git a/src/gtkimageviewer/SConscript b/src/gtkimageviewer/SConscript index 71b7ed1..28a9eb6 100644 --- a/src/gtkimageviewer/SConscript +++ b/src/gtkimageviewer/SConscript @@ -3,9 +3,7 @@ Import('env') import re -# The following python subroutine and the subsequent scons command -# shows how to do general template filling. This system should perhaps -# be put in a separate directory, or even be made part of scons. +# Patch problems with the gob output. def patch_src(env, target, source): out = open(str(target[0]), "wb") inp = open(str(source[0]), "r") @@ -22,6 +20,15 @@ def patch_src(env, target, source): if re.search(r"object_signals\[SET_SCROLL_ADJUSTMENTS_SIGNAL\]",line): in_area=1 + line = re.sub('GtkScrollableInterfaceIface', + 'GtkScrollableInterface', + line) + line = re.sub('GTK_TYPE_SCROLLABLEINTERFACE', + 'GTK_TYPE_SCROLLABLE', + line) + line = re.sub('scroll_policy"', + 'scroll-policy"', + line) out.write(line.encode('utf8')) out.close() diff --git a/src/gtkimageviewer/gtk-image-viewer.gob b/src/gtkimageviewer/gtk-image-viewer.gob index 962c175..3575ba4 100644 --- a/src/gtkimageviewer/gtk-image-viewer.gob +++ b/src/gtkimageviewer/gtk-image-viewer.gob @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Dov Grobgeld + * Copyright (C) 2008-2018 Dov Grobgeld * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -40,6 +40,7 @@ requires 2.0.0 #include #include #include +#include %} %{ @@ -62,7 +63,7 @@ requires 2.0.0 * Boston, MA 02111-1307, USA. */ #define DBG(a) -#define DBG2(a) +#define DBG2(a) static gint view_changed(GtkImageViewer *image_widget, int do_force, @@ -96,6 +97,7 @@ static gboolean turn_off_insensitive(GtkWidget *widget); class Gtk:Image:Viewer from Gtk:Widget + (interface Gtk:ScrollableInterface) { private GdkPixbuf *image=NULL destroy @@ -123,7 +125,6 @@ class Gtk:Image:Viewer from Gtk:Widget private gboolean do_linear_zoom_steps; private gdouble min_zoom; private gdouble max_zoom; - private GdkGC *gc; private gdouble scroll_min_x = -1; private gdouble scroll_max_x = -1; private gdouble scroll_min_y = -1; @@ -132,13 +133,14 @@ class Gtk:Image:Viewer from Gtk:Widget private gdouble scroll_height = -1; private GtkAdjustment *hadjustment = NULL; private GtkAdjustment *vadjustment = NULL; + private GtkPolicyType hscroll_policy = 0; + private GtkPolicyType vscroll_policy = 0; private gint last_x; private gint last_y; private gboolean is_mouse_button2_pressed = FALSE; private gdouble last_pan_anchor_x; private gdouble last_pan_anchor_y; private gint button; - private GdkDrawable *cache_area = NULL; private gdouble cache_scale_x = -1; private gdouble cache_scale_y = -1; private gdouble cache_current_x0 = -1; @@ -151,7 +153,7 @@ class Gtk:Image:Viewer from Gtk:Widget init(self) { - GTK_WIDGET_SET_FLAGS (self, GTK_CAN_FOCUS); + gtk_widget_set_can_focus (GTK_WIDGET(self), TRUE); selfp->interp_type = GDK_INTERP_NEAREST; selfp->do_linear_zoom_steps = FALSE; selfp->do_use_transfer_map = FALSE; @@ -165,18 +167,18 @@ class Gtk:Image:Viewer from Gtk:Widget selfp->max_zoom = 128; selfp->scroll_width = -1; selfp->scroll_height = -1; - selfp->gc = NULL; selfp->hadjustment = 0; selfp->vadjustment = 0; selfp->frozen = FALSE; } - class_init(self) { - // The following statement does the magic of connecting the scrolled_window - // packing to the scrolling of the image viewer. - ((GtkWidgetClass*)self)->set_scroll_adjustments_signal = object_signals[SET_SCROLL_ADJUSTMENTS_SIGNAL]; - } - +// TBDov: What to do about this? +// class_init(self) { +// // The following statement does the magic of connecting the scrolled_window +// // packing to the scrolling of the image viewer. +// ((GtkWidgetClass*)self)->set_scroll_adjustments_signal = object_signals[SET_SCROLL_ADJUSTMENTS_SIGNAL]; +// } + /** * new: * @pixbuf: Can be NULL if no image is set. @@ -220,14 +222,15 @@ class Gtk:Image:Viewer from Gtk:Widget { GtkWidget *widget = GTK_WIDGET(self); GdkWindowAttr attributes; + GtkAllocation allocation; gint attributes_mask; - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation(widget, &allocation); + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | @@ -239,45 +242,82 @@ class Gtk:Image:Viewer from Gtk:Widget GDK_KEY_PRESS_MASK | GDK_FOCUS_CHANGE_MASK | GDK_LEAVE_NOTIFY_MASK | - GDK_ENTER_NOTIFY_MASK; + GDK_ENTER_NOTIFY_MASK | + GDK_SCROLL_MASK + ; attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); - widget->style = gtk_style_attach (widget->style, widget->window); + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + gtk_widget_set_window(widget, gdk_window_new ( + gtk_widget_get_window( + gtk_widget_get_parent(widget)), &attributes, attributes_mask)); - gdk_window_set_user_data (widget->window, widget); - - // Force background to be white. This is uggly and should be fixed! - { - GdkColor color; - gdk_color_parse("white", &color); - gtk_widget_modify_bg(self, GTK_STATE_NORMAL, &color); - gtk_widget_modify_bg(self, GTK_STATE_ACTIVE, &color); - } + // TBDOV: styles? See doc for GtkStyleContext + gdk_window_set_user_data (gtk_widget_get_window(widget), widget); + } + + override (Gtk:Widget) + void + map (Gtk:Widget *widget (check null type)) + { + PARENT_HANDLER(widget); + + GtkImageViewer *self = GTK_IMAGE_VIEWER(widget); - // gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE); + if (selfp->do_fill_on_resize) + gtk_image_viewer_zoom_fit(self); } override (Gtk:Widget) void - size_request (GtkWidget *widget, - GtkRequisition *requisition) + get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width) { GtkImageViewer *self = GTK_IMAGE_VIEWER (widget); if (selfp->image) - { - requisition->width = gdk_pixbuf_get_width(selfp->image); - requisition->height = gdk_pixbuf_get_height(selfp->image); - } + *natural_width = gdk_pixbuf_get_width(selfp->image); else - { - requisition->width = 256; - requisition->height = 256; - } + *natural_width = 256; + *minimal_width = 128; + } + + override (Gtk:Widget) + void + get_preferred_height (GtkWidget *widget, + gint *minimal_height, + gint *natural_height) + { + GtkImageViewer *self = GTK_IMAGE_VIEWER (widget); + + if (selfp->image) + *natural_height = gdk_pixbuf_get_height(selfp->image); + else + *natural_height = 256; + *minimal_height = 128; + } + + // From gtkdrawingarea + private void + send_configure (self) + { + GtkAllocation allocation; + GtkWidget *widget; + GdkEvent *event = gdk_event_new (GDK_CONFIGURE); + + widget = GTK_WIDGET (self); + gtk_widget_get_allocation (widget, &allocation); + + event->configure.window = g_object_ref (gtk_widget_get_window (widget)); + event->configure.send_event = TRUE; + event->configure.x = allocation.x; + event->configure.y = allocation.y; + event->configure.width = allocation.width; + event->configure.height = allocation.height; + + gtk_widget_event (widget, event); + gdk_event_free (event); } override (Gtk:Widget) @@ -288,25 +328,27 @@ class Gtk:Image:Viewer from Gtk:Widget GtkImageViewer *self; int old_cnv_w, old_cnv_h; - widget->allocation = *allocation; + gtk_widget_set_allocation(widget, allocation); self = GTK_IMAGE_VIEWER (widget); - if (GTK_WIDGET_REALIZED (widget)) { - gdk_window_move_resize (widget->window, - allocation->x, allocation->y, - allocation->width, allocation->height); + if (gtk_widget_get_realized (widget) + && gtk_widget_get_window(widget)) { + gdk_window_move_resize (gtk_widget_get_window(widget), + allocation->x, allocation->y, + allocation->width, allocation->height); + gtk_image_viewer_send_configure(GTK_IMAGE_VIEWER(widget)); } old_cnv_w = selfp->canvas_width; old_cnv_h = selfp->canvas_height; - selfp->canvas_width = widget->allocation.width; - selfp->canvas_height = widget->allocation.height; - if (GTK_IS_SCROLLED_WINDOW(GTK_WIDGET(self)->parent)) { - GtkPolicyType hscrollbar_policy, vscrollbar_policy; - gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(GTK_WIDGET(self)->parent), - &hscrollbar_policy, - &vscrollbar_policy); + selfp->canvas_width = allocation->width; + selfp->canvas_height = allocation->height; + if (GTK_IS_SCROLLED_WINDOW(gtk_widget_get_parent(GTK_WIDGET(self)))) + { + gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(gtk_widget_get_parent(GTK_WIDGET(self))), + &selfp->hscroll_policy, + &selfp->vscroll_policy); #if 0 printf("Replacing with parent size (%d,%d)->(%d,%d)...\n", selfp->canvas_width, @@ -315,11 +357,11 @@ class Gtk:Image:Viewer from Gtk:Widget GTK_WIDGET(self)->parent->allocation.height ); #endif - if (hscrollbar_policy != GTK_POLICY_ALWAYS) - selfp->canvas_width = GTK_WIDGET(self)->parent->allocation.width; - - if (vscrollbar_policy != GTK_POLICY_ALWAYS) - selfp->canvas_height = GTK_WIDGET(self)->parent->allocation.height; + if (selfp->hscroll_policy != GTK_POLICY_ALWAYS) + selfp->canvas_width = gtk_widget_get_allocated_width(gtk_widget_get_parent(GTK_WIDGET(self))); + + if (selfp->vscroll_policy != GTK_POLICY_ALWAYS) + selfp->canvas_height = gtk_widget_get_allocated_height(gtk_widget_get_parent(GTK_WIDGET(self))); } // If we were called because the scrollbar automatically appeared @@ -332,7 +374,8 @@ class Gtk:Image:Viewer from Gtk:Widget double scale_factor = 1.0; if (!selfp->one_shot_block_fill_on_resize - && selfp->do_fill_on_resize) { + && selfp->do_fill_on_resize) + { double sw = selfp->scroll_width; double sh = selfp->scroll_height; double cw = selfp->canvas_width; @@ -343,14 +386,6 @@ class Gtk:Image:Viewer from Gtk:Widget if (sh < 0) sh = ch; - // This should be made more sophisticated. -#if 0 - if (!selfp->image) { - cw-= 20; - ch-= 20; - } -#endif - if (old_cnv_w == 0) scale_factor = 1; else @@ -365,7 +400,7 @@ class Gtk:Image:Viewer from Gtk:Widget scale_factor_y = ch/sh/selfp->current_scale_y; if (scale_factor_y < scale_factor) scale_factor = scale_factor_y; - } + } selfp->one_shot_block_fill_on_resize = FALSE; selfp->current_scale_x *= scale_factor; @@ -377,47 +412,44 @@ class Gtk:Image:Viewer from Gtk:Widget * new size is wider than scale * image size. */ { - double scale_x = selfp->current_scale_x; - double scale_y = selfp->current_scale_y; - double img_w = selfp->scroll_width*scale_x; - double img_h = selfp->scroll_height*scale_y; - int cnv_w = selfp->canvas_width; - int cnv_h = selfp->canvas_height; + double scale_x = selfp->current_scale_x; + double scale_y = selfp->current_scale_y; + double img_w = selfp->scroll_width*scale_x; + double img_h = selfp->scroll_height*scale_y; + int cnv_w = selfp->canvas_width; + int cnv_h = selfp->canvas_height; - DBG(fprintf(stderr,"Resize: x0 y0 img_w img_h cnv_w cnv_h = %d %d %f %f %d %d\n", - selfp->current_x0,selfp->current_y0,img_w,img_h,cnv_w,cnv_h)); + DBG(fprintf(stderr,"Resize: x0 y0 img_w img_h cnv_w cnv_h = %.0f %.0f %f %f %d %d\n", + selfp->current_x0,selfp->current_y0,img_w,img_h,cnv_w,cnv_h)); - if (cnv_w > img_w) - selfp->current_x0 = -(cnv_w-img_w)/2+selfp->scroll_min_x*scale_x; - else if (old_cnv_w > img_w) - selfp->current_x0 = selfp->scroll_min_x*scale_x; - else if (img_w - selfp->current_x0 < cnv_w) - { - DBG(fprintf(stderr, "Resize case 3X\n")); - selfp->current_x0 = img_w-cnv_w+selfp->scroll_min_x*scale_x; - } - if (cnv_h > img_h) - selfp->current_y0 = -(cnv_h-img_h)/2+selfp->scroll_min_y*scale_y; - else if (old_cnv_h > img_h) - selfp->current_y0 = selfp->scroll_min_y*scale_y; - else if (img_h - selfp->current_y0 < cnv_h) - { - DBG(fprintf(stderr, "Resize case 3Y\n")); - selfp->current_y0 = img_h-cnv_h+selfp->scroll_min_y*scale_y; - } - } + if (cnv_w > img_w) + selfp->current_x0 = -(cnv_w-img_w)/2+selfp->scroll_min_x*scale_x; + else if (old_cnv_w > img_w) + selfp->current_x0 = selfp->scroll_min_x*scale_x; + else if (img_w - selfp->current_x0 < cnv_w) + { + DBG(fprintf(stderr, "Resize case 3X\n")); + selfp->current_x0 = img_w-cnv_w+selfp->scroll_min_x*scale_x; + } + if (cnv_h > img_h) + selfp->current_y0 = -(cnv_h-img_h)/2+selfp->scroll_min_y*scale_y; + else if (old_cnv_h > img_h) + selfp->current_y0 = selfp->scroll_min_y*scale_y; + else if (img_h - selfp->current_y0 < cnv_h) + { + DBG(fprintf(stderr, "Resize case 3Y\n")); + selfp->current_y0 = img_h-cnv_h+selfp->scroll_min_y*scale_y; + } + } } override (Gtk:Widget) - gint - expose_event (GtkWidget *widget, - GdkEventExpose *event) + gboolean draw(GtkWidget *widget, + cairo_t *cr) { gtk_image_viewer_expose_area(GTK_IMAGE_VIEWER(widget), - event->area.x, event->area.y, - event->area.width, event->area.height); - - return FALSE; + cr); + return TRUE; } override (Gtk:Widget) @@ -430,7 +462,7 @@ class Gtk:Image:Viewer from Gtk:Widget if (selfp->timeout_id) g_source_remove(selfp->timeout_id); selfp->timeout_id = g_timeout_add(200, (GSourceFunc) turn_off_insensitive, self); - if (!GTK_WIDGET_HAS_FOCUS (widget)) + if (!gtk_widget_has_focus (widget)) gtk_widget_grab_focus (widget); return TRUE; @@ -443,7 +475,7 @@ class Gtk:Image:Viewer from Gtk:Widget { GtkImageViewer *self = GTK_IMAGE_VIEWER(widget); // printf("Leave notify\n"); - if (!GTK_WIDGET_HAS_FOCUS (widget)) + if (!gtk_widget_has_focus (widget)) gtk_widget_grab_focus (widget); if (selfp->timeout_id) { g_source_remove(selfp->timeout_id); @@ -464,7 +496,6 @@ class Gtk:Image:Viewer from Gtk:Widget gint k; double big_scale = 2.0; double small_scale = 1.1; - double basescale = 2.0; double vscale = 1.0; k = event->keyval; @@ -472,49 +503,49 @@ class Gtk:Image:Viewer from Gtk:Widget switch (k) { case '=': case '+': - if (!selfp->do_vertical_lock) - vscale = small_scale; - gtk_image_viewer_zoom_in(self, -1, -1, small_scale, vscale); - break; + if (!selfp->do_vertical_lock) + vscale = small_scale; + gtk_image_viewer_zoom_in(self, -1, -1, small_scale, vscale); + break; case '>': - if (!selfp->do_vertical_lock) - vscale = big_scale; - gtk_image_viewer_zoom_in(self, -1, -1, big_scale, vscale); - break; + if (!selfp->do_vertical_lock) + vscale = big_scale; + gtk_image_viewer_zoom_in(self, -1, -1, big_scale, vscale); + break; case '<': - if (!selfp->do_vertical_lock) - vscale = big_scale; - gtk_image_viewer_zoom_out(self, selfp->canvas_width/2, selfp->canvas_height/2, big_scale, vscale); - break; + if (!selfp->do_vertical_lock) + vscale = big_scale; + gtk_image_viewer_zoom_out(self, selfp->canvas_width/2, selfp->canvas_height/2, big_scale, vscale); + break; case '-': - if (!selfp->do_vertical_lock) - vscale = big_scale; - gtk_image_viewer_zoom_out(self, selfp->canvas_width/2, selfp->canvas_height/2, big_scale, vscale); - break; + if (!selfp->do_vertical_lock) + vscale = big_scale; + gtk_image_viewer_zoom_out(self, selfp->canvas_width/2, selfp->canvas_height/2, big_scale, vscale); + break; case '1': case 'n': - zoom_reset(self); - break; + zoom_reset(self); + break; case 'f': - gtk_image_viewer_zoom_fit(self); - break; + gtk_image_viewer_zoom_fit(self); + break; case 'v': - gtk_image_viewer_set_flip(self, - selfp->do_flip_horizontal, - !selfp->do_flip_vertical); - break; + gtk_image_viewer_set_flip(self, + selfp->do_flip_horizontal, + !selfp->do_flip_vertical); + break; case 'V': - gtk_image_viewer_set_vertical_lock(self, - !selfp->do_vertical_lock); - break; + gtk_image_viewer_set_vertical_lock(self, + !selfp->do_vertical_lock); + break; case 'h': - gtk_image_viewer_set_flip(self, - !selfp->do_flip_horizontal, - selfp->do_flip_vertical); - break; + gtk_image_viewer_set_flip(self, + !selfp->do_flip_horizontal, + selfp->do_flip_vertical); + break; default: - ret = FALSE; - break; + ret = FALSE; + break; } return ret; } @@ -531,28 +562,28 @@ class Gtk:Image:Viewer from Gtk:Widget double vscale = 1.0; if (selfp->is_insensitive) - return TRUE; + return TRUE; if (button == 1) - { + { if (!selfp->do_vertical_lock) - vscale = 2; + vscale = 2; gtk_image_viewer_zoom_in(self, (int)x, (int)y, 2, vscale); - } + } else if (button == 2) - { + { gtk_grab_add (GTK_WIDGET(self)); selfp->is_mouse_button2_pressed = TRUE; selfp->last_pan_anchor_x = x; selfp->last_pan_anchor_y = y; - } + } else if (button == 3) - { + { if (!selfp->do_vertical_lock) - vscale = 2; + vscale = 2; gtk_image_viewer_zoom_out(self, (int)x, (int)y, 2, vscale); - } + } selfp->button = event->button; @@ -579,18 +610,11 @@ class Gtk:Image:Viewer from Gtk:Widget if (selfp->is_mouse_button2_pressed) { selfp->is_mouse_button2_pressed = FALSE; if (selfp->last_pan_anchor_x>0 && selfp->last_pan_anchor_y > 0) - zoom_translate(self, - (int)(selfp->last_pan_anchor_x-x), - (int)(selfp->last_pan_anchor_y-y)); + zoom_translate(self, + (int)(selfp->last_pan_anchor_x-x), + (int)(selfp->last_pan_anchor_y-y)); gtk_grab_remove (GTK_WIDGET(self)); - /* Emit an additional view changed signal at the end of the scrolling - in order to support redrawing only when the panning is done. - */ -#if 0 - gtk_signal_emit(GTK_OBJECT(image_viewer), gtk_image_viewer_signals[VIEW_CHANGED]); -#endif - } } @@ -619,12 +643,15 @@ class Gtk:Image:Viewer from Gtk:Widget self = GTK_IMAGE_VIEWER (widget); - if (event->is_hint) { - gdk_window_get_pointer(event->window, &x, &y, &state); - } else { - x = (int) event->x; - y = (int) event->y; - } + if (event->is_hint) + { + gdk_window_get_device_position (event->window, event->device, &x, &y, &state); + } + else + { + x = (int) event->x; + y = (int) event->y; + } selfp->last_x = x; selfp->last_y = y; @@ -667,18 +694,18 @@ class Gtk:Image:Viewer from Gtk:Widget double vscale = 1.0; if (event->state & GDK_SHIFT_MASK) - zoom_strength = 1.1; + zoom_strength = 1.1; if (event->state & GDK_CONTROL_MASK) - zoom_strength = 2.0; + zoom_strength = 2.0; if (!selfp->do_vertical_lock) - vscale = zoom_strength; + vscale = zoom_strength; if (event->direction) - //zoom_in(self, (int)x,(int)y); - gtk_image_viewer_zoom_out(self, (int)x,(int)y,zoom_strength,vscale); + //zoom_in(self, (int)x,(int)y); + gtk_image_viewer_zoom_out(self, (int)x,(int)y,zoom_strength,vscale); else - gtk_image_viewer_zoom_in(self, x,y,zoom_strength, vscale); + gtk_image_viewer_zoom_in(self, x,y,zoom_strength, vscale); return 1; } return 0; @@ -696,10 +723,20 @@ class Gtk:Image:Viewer from Gtk:Widget */ public void expose_area(self, - int exp_x0, int exp_y0, - int w, int h) + cairo_t *cr) { - GtkWidget *widget = GTK_WIDGET(self); /* In order to access window */ + double cr_exp_x0, cr_exp_y0, cr_exp_x1, cr_exp_y1; + int w, h; + cairo_clip_extents(cr, + &cr_exp_x0, &cr_exp_y0, + &cr_exp_x1, &cr_exp_y1); + int exp_x0, exp_y0; + exp_x0 = (int)floor(cr_exp_x0); + exp_y0 = (int)floor(cr_exp_y0); + w = (int)ceil(cr_exp_x1-exp_x0); + h = (int)ceil(cr_exp_y1-exp_y0); + + // GtkWidget *widget = GTK_WIDGET(self); /* In order to access window */ GdkPixbuf *img_scaled = NULL; double scale_x = selfp->current_scale_x; double scale_y = selfp->current_scale_y; @@ -723,37 +760,13 @@ class Gtk:Image:Viewer from Gtk:Widget // Check if we have a cached version of the exposed area and // that the settings of the cache match the current settings. - - // Currently turn off the caching mechanism as it works badly... - // Need to rethink the whole mechanism. - if (0 && selfp->cache_area) { - if (selfp->cache_scale_x == scale_x - && selfp->cache_scale_y == scale_y - && selfp->cache_current_x0 == selfp->current_x0 - && selfp->cache_current_y0 == selfp->current_y0 - && selfp->cache_width == selfp->canvas_width - && selfp->cache_height == selfp->canvas_height - ) { - -#if 0 - printf("Restoring cache!\n"); -#endif - /* Scroll visible region */ - gdk_draw_drawable (widget->window, - selfp->gc, - selfp->cache_area, - exp_x0, exp_y0, - exp_x0, exp_y0, - w,h); - return; - } - else { - // invalidate cache - gdk_drawable_unref(selfp->cache_area); - selfp->cache_area = NULL; - } - } - + + GdkRGBA background_color; + gdk_rgba_parse(&background_color,"white"); + cairo_set_source_rgb(cr, + background_color.red, + background_color.green, + background_color.blue); if (selfp->image) { /* Canvas size */ @@ -764,7 +777,7 @@ class Gtk:Image:Viewer from Gtk:Widget int img_y1 = cnv_h; img_w = gdk_pixbuf_get_width(selfp->image); img_h = gdk_pixbuf_get_height(selfp->image); - DBG(fprintf(stderr, "current_x0 exp_x0 offs_x = %d %d %d\n", + DBG(fprintf(stderr, "current_x0 exp_x0 offs_x = %.0f %d %.0f\n", selfp->current_x0, exp_x0, offs_x)); @@ -789,10 +802,9 @@ class Gtk:Image:Viewer from Gtk:Widget copy_w = 0; offs_x = 0; dst_x = img_x0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,w, h); + cairo_rectangle (cr, + exp_x0,exp_y0,w,h); + cairo_fill (cr); } else if (exp_x0 < img_x0 && exp_x1 > img_x1) { @@ -808,14 +820,11 @@ class Gtk:Image:Viewer from Gtk:Widget else trans_offs_x = offs_x = 0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,(img_x0-exp_x0), h); - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - img_x1,exp_y0,(exp_x1-img_x1), h); + cairo_rectangle(cr, + exp_x0,exp_y0,(img_x0-exp_x0), h); + cairo_rectangle(cr, + img_x1,exp_y0,(exp_x1-img_x1), h); + cairo_fill(cr); } else if (exp_x0 < img_x0) { @@ -831,19 +840,16 @@ class Gtk:Image:Viewer from Gtk:Widget else offs_x = trans_offs_x = 0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,(img_x0-exp_x0), h); + cairo_rectangle( cr, + exp_x0,exp_y0,(img_x0-exp_x0), h); + cairo_fill (cr); } else if (exp_x0 > img_x1) { DBG(fprintf(stderr, "Case 4X\n")); copy_w = 0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,w, h); + cairo_rectangle (cr, + exp_x0,exp_y0,w, h); } else if (exp_x1 > img_x1) @@ -860,10 +866,9 @@ class Gtk:Image:Viewer from Gtk:Widget else offs_x = trans_offs_x = -(exp_x0-img_x0); - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - img_x1,exp_y0,exp_x1-img_x1, h); + cairo_rectangle (cr, + img_x1,exp_y0,exp_x1-img_x1, h); + cairo_fill (cr); } else { @@ -887,10 +892,9 @@ class Gtk:Image:Viewer from Gtk:Widget copy_h = 0; offs_y = 0; dst_x = img_y0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,w, h); + cairo_rectangle(cr, + exp_x0,exp_y0,w, h); + cairo_fill (cr); } else if (exp_y0 < img_y0 && exp_y1 > img_y1) { @@ -906,14 +910,12 @@ class Gtk:Image:Viewer from Gtk:Widget else trans_offs_y = offs_y = 0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,w, img_y0-exp_y0); - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0, img_y1,w, exp_y1-img_y1); + cairo_rectangle(cr, + exp_x0,exp_y0,w, img_y0-exp_y0); + cairo_rectangle(cr, + exp_x0, img_y1,w, exp_y1-img_y1); + cairo_fill (cr); + } else if (exp_y0 < img_y0) { @@ -929,20 +931,17 @@ class Gtk:Image:Viewer from Gtk:Widget else offs_y = trans_offs_y = 0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,w,(img_y0-exp_y0)); + cairo_rectangle(cr, + exp_x0,exp_y0,w,(img_y0-exp_y0)); + cairo_fill (cr); } else if (exp_y0 > img_y1) { DBG(fprintf(stderr, "Case 4Y\n")); copy_h = 0; - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,exp_y0,w, h); - + cairo_rectangle(cr, + exp_x0,exp_y0,w, h); + cairo_fill(cr); } else if (exp_y1 > img_y1) { @@ -958,10 +957,9 @@ class Gtk:Image:Viewer from Gtk:Widget else offs_y = trans_offs_y = -(exp_y0-img_y0); - gdk_draw_rectangle(widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - exp_x0,img_y1,w,exp_y1-img_y1); + cairo_rectangle(cr, + exp_x0,img_y1,w,exp_y1-img_y1); + cairo_fill(cr); } else { @@ -979,7 +977,7 @@ class Gtk:Image:Viewer from Gtk:Widget } - DBG(fprintf(stderr, "dst_x dst_y copy_w copy_h offs_x offs_y = %d %d %d %d %d %d\n", + DBG(fprintf(stderr, "dst_x dst_y copy_w copy_h offs_x offs_y = %d %d %d %d %.0f %.0f\n", dst_x, dst_y, copy_w, copy_h, selfp->current_x0, selfp->current_y0)); /* Scale and copy the image */ @@ -1013,28 +1011,28 @@ class Gtk:Image:Viewer from Gtk:Widget #endif /* Check legality */ - DBG(fprintf(stderr, "offs_x copy_x scale_x w = %d %d %f %d\n", + DBG(fprintf(stderr, "offs_x copy_x scale_x w = %.0f %d %f %d\n", offs_x, copy_w, scale_x, img_w)); // Bug workaround for huge zooms if (scale_x >= 30) - fix_gdk_pixbuf_scale_nn(selfp->image, - img_scaled, - 0,0, - copy_w, - copy_h, - offs_x, - offs_y, - scale_x, scale_y); + fix_gdk_pixbuf_scale_nn(selfp->image, + img_scaled, + 0,0, + copy_w, + copy_h, + offs_x, + offs_y, + scale_x, scale_y); else - gdk_pixbuf_scale(selfp->image, - img_scaled, - 0,0, - copy_w, - copy_h, - offs_x, - offs_y, - scale_x, scale_y, - selfp->interp_type); + gdk_pixbuf_scale(selfp->image, + img_scaled, + 0,0, + copy_w, + copy_h, + offs_x, + offs_y, + scale_x, scale_y, + selfp->interp_type); if (selfp->do_use_transfer_map) { @@ -1135,7 +1133,7 @@ class Gtk:Image:Viewer from Gtk:Widget offs_x = selfp->current_x0+w-exp_x1+cnv_w; else offs_x = -selfp->current_x0-exp_x0; - DBG(printf("No image: current_x0=%d offs_x = %d\n", selfp->current_x0, offs_x)); + DBG(printf("No image: current_x0=%.0f offs_x = %.0f\n", selfp->current_x0, offs_x)); if (selfp->do_flip_vertical) offs_y = selfp->current_y0+h-exp_y1+cnv_h; else @@ -1178,7 +1176,8 @@ class Gtk:Image:Viewer from Gtk:Widget } // Add checkerboard below images that have alpha channel - if (gdk_pixbuf_get_has_alpha(img_scaled)) { + if (gdk_pixbuf_get_has_alpha(img_scaled)) + { GdkPixbuf *img_comp = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(img_scaled), TRUE, gdk_pixbuf_get_bits_per_sample(img_scaled), @@ -1200,50 +1199,15 @@ class Gtk:Image:Viewer from Gtk:Widget g_object_unref(img_scaled); img_scaled = img_comp; } - if (!selfp->frozen) - gdk_draw_pixbuf (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - img_scaled, - 0, 0, - dst_x, dst_y, - copy_w, copy_h, - GDK_RGB_DITHER_NORMAL, - selfp->current_x0, - selfp->current_y0); + if (!selfp->frozen) { + gdk_cairo_set_source_pixbuf(cr, + img_scaled, + dst_x,dst_y); + cairo_paint(cr); + } g_object_unref(img_scaled); - // If we have just drawn the whole buffer, then copy the result - // to the cache. - if (w == selfp->canvas_width - && h == selfp->canvas_height) { - selfp->cache_area = gdk_pixmap_new(widget->window, - w,h, - -1); - if (!selfp->gc) { - selfp->gc = gdk_gc_new(widget->window); - gdk_gc_copy(selfp->gc, widget->style->white_gc); - gdk_gc_set_exposures(selfp->gc, TRUE); - } - - gdk_draw_drawable(selfp->cache_area, - selfp->gc, - widget->window, - 0,0, - 0,0, - -1, -1); - selfp->cache_current_x0 = selfp->current_x0; - selfp->cache_current_y0 = selfp->current_y0; - selfp->cache_scale_x = selfp->current_scale_x; - selfp->cache_scale_y = selfp->current_scale_y; - selfp->cache_width = selfp->canvas_width; - selfp->cache_height = selfp->canvas_height; -#if 0 - printf("Storing cache! (x0,y0,sx,sy) = (%d %d %f %f)\n", - selfp->current_x0, selfp->current_y0, - selfp->current_scale_x, selfp->current_scale_y); -#endif - } #if 0 gtk_signal_emit(GTK_OBJECT(self), gtk_image_viewer_signals[VIEW_CHANGED]); @@ -1271,16 +1235,11 @@ class Gtk:Image:Viewer from Gtk:Widget redraw(self, gboolean clear_cache) { - if (clear_cache) { - if (selfp->cache_area) - gdk_drawable_unref(selfp->cache_area); - selfp->cache_area = NULL; - } - if (GTK_WIDGET(self)->window) - gtk_image_viewer_expose_area(self, - 0,0, - GTK_WIDGET(self)->allocation.width, - GTK_WIDGET(self)->allocation.height); + if (gtk_widget_get_window(GTK_WIDGET(self))) + gtk_widget_queue_draw_area (GTK_WIDGET(self), + 0,0, + gtk_widget_get_allocated_width(GTK_WIDGET(self)), + gtk_widget_get_allocated_height(GTK_WIDGET(self))); return FALSE; } @@ -1301,40 +1260,41 @@ class Gtk:Image:Viewer from Gtk:Widget double new_x, double new_y) { - double w = selfp->canvas_width; - double h = selfp->canvas_height; - double old_scale_x, old_scale_y, old_x0, old_y0, new_x0, new_y0; - DBG(printf("zoom_around_fixed_point: nsx nsy old_x old_y new_x new_y = %f %f %f %f %f %f\n", - new_scale_x, new_scale_y, - old_x, old_y, - new_x, new_y)); - - g_return_val_if_fail (self != NULL, FALSE); - g_return_val_if_fail (GTK_IS_IMAGE_VIEWER (self), FALSE); + double w = selfp->canvas_width; + double h = selfp->canvas_height; + double old_scale_x, old_scale_y, old_x0, old_y0, new_x0, new_y0; + DBG(printf("zoom_around_fixed_point: nsx nsy old_x old_y new_x new_y = %f %f %f %f %f %f\n", + new_scale_x, new_scale_y, + old_x, old_y, + new_x, new_y)); - /* Short cuts */ - old_x0 = selfp->current_x0; - old_y0 = selfp->current_y0; - old_scale_x = selfp->current_scale_x; - old_scale_y = selfp->current_scale_y; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (GTK_IS_IMAGE_VIEWER (self), FALSE); + /* Short cuts */ + old_x0 = selfp->current_x0; + old_y0 = selfp->current_y0; + old_scale_x = selfp->current_scale_x; + old_scale_y = selfp->current_scale_y; - if (selfp->do_flip_horizontal) { - old_x = w - old_x; - new_x = w - new_x; + if (selfp->do_flip_horizontal) + { + old_x = w - old_x; + new_x = w - new_x; } - if (selfp->do_flip_vertical) { - old_y = h - old_y; - new_y = h - new_y; + if (selfp->do_flip_vertical) + { + old_y = h - old_y; + new_y = h - new_y; } - new_x0 = new_scale_x/old_scale_x * (old_x + old_x0) - new_x; - new_y0 = new_scale_y/old_scale_y * (old_y + old_y0) - new_y; + new_x0 = new_scale_x/old_scale_x * (old_x + old_x0) - new_x; + new_y0 = new_scale_y/old_scale_y * (old_y + old_y0) - new_y; - DBG(printf("old_x0 new_x0 = %f %f\n", old_x0, new_x0)); - view_changed(self, FALSE, new_scale_x, new_scale_y, new_x0, new_y0); + DBG(printf("old_x0 new_x0 = %f %f\n", old_x0, new_x0)); + view_changed(self, FALSE, new_scale_x, new_scale_y, new_x0, new_y0); - return 0; + return 0; } public gint @@ -1436,45 +1396,45 @@ class Gtk:Image:Viewer from Gtk:Widget double pixel_margin, gboolean preserve_aspect) { - double w = selfp->canvas_width; - double h = selfp->canvas_height; - - if (w==0 || h==0) { - GtkRequisition requisition; - gtk_widget_size_request(GTK_WIDGET(self), - &requisition); - w = requisition.width; - h = requisition.height; - if (w>1 && h>1) { - selfp->canvas_width = w; - selfp->canvas_height = h; - } + double w = selfp->canvas_width; + double h = selfp->canvas_height; + + if (w==0 || h==0) + { + int w,min_w,h,min_h; + gtk_widget_get_preferred_width(GTK_WIDGET(self),&min_w,&w); + gtk_widget_get_preferred_height(GTK_WIDGET(self),&min_h,&h); + if (w>1 && h>1) { + selfp->canvas_width = w; + selfp->canvas_height = h; + } } - // Refuse to fit in an uninitiaded situation. - if (world_min_x >= world_max_x) - return 0; + // Refuse to fit in an uninitiaded situation. + if (world_min_x >= world_max_x) + return 0; #if 0 - printf("alloc_width=%f alloc_height=%f\n", - w,h); + printf("alloc_width=%f alloc_height=%f\n", + w,h); #endif - double new_scale_x = (w-2*pixel_margin)/(world_max_x-world_min_x); - double new_scale_y = (h-2*pixel_margin)/(world_max_y-world_min_y); + double new_scale_x = (w-2*pixel_margin)/(world_max_x-world_min_x); + double new_scale_y = (h-2*pixel_margin)/(world_max_y-world_min_y); - if (preserve_aspect) { - if (new_scale_x > new_scale_y) - new_scale_x = new_scale_y; - else - new_scale_y = new_scale_x; + if (preserve_aspect) + { + if (new_scale_x > new_scale_y) + new_scale_x = new_scale_y; + else + new_scale_y = new_scale_x; } - // This works for both flip and not flip! - double new_x0 = new_scale_x*0.5*(world_max_x+world_min_x)-w/2; - double new_y0 = new_scale_y*0.5*(world_max_y+world_min_y)-h/2; + // This works for both flip and not flip! + double new_x0 = new_scale_x*0.5*(world_max_x+world_min_x)-w/2; + double new_y0 = new_scale_y*0.5*(world_max_y+world_min_y)-h/2; - view_changed(self, FALSE, new_scale_x, new_scale_y, new_x0, new_y0); + view_changed(self, FALSE, new_scale_x, new_scale_y, new_x0, new_y0); - return 0; + return 0; } /** @@ -1489,33 +1449,34 @@ class Gtk:Image:Viewer from Gtk:Widget GtkAdjustment *adjustment) { g_return_if_fail (GTK_IS_IMAGE_VIEWER (self)); - if (adjustment) { - g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); - } + if (adjustment) + g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); if (selfp->hadjustment && selfp->hadjustment != adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (selfp->hadjustment), self); - gtk_object_unref (GTK_OBJECT (selfp->hadjustment)); + g_signal_handlers_disconnect_by_func (selfp->hadjustment, + hadjustment_value_changed, + self); + + g_object_unref (G_OBJECT (selfp->hadjustment)); selfp->hadjustment = NULL; } if (!adjustment) - adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, - 0.0, 0.0, 0.0)); + adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, + 0.0, 0.0, 0.0); if (selfp->hadjustment != adjustment) { - selfp->hadjustment = adjustment; - gtk_object_ref (GTK_OBJECT (selfp->hadjustment)); - gtk_object_sink (GTK_OBJECT (selfp->hadjustment)); + selfp->hadjustment = g_object_ref_sink (adjustment); - gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + g_signal_connect (G_OBJECT (adjustment), "value_changed", G_CALLBACK(hadjustment_value_changed), (gpointer) self); } - // g_object_notify (G_OBJECT (self), "hadjustment"); + g_object_notify (G_OBJECT (self), "hadjustment"); + update_adjustments(self); } /** @@ -1531,33 +1492,34 @@ class Gtk:Image:Viewer from Gtk:Widget GtkAdjustment *adjustment) { g_return_if_fail (GTK_IS_IMAGE_VIEWER (self)); - if (adjustment) { + if (adjustment) g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); - } if (selfp->vadjustment && selfp->vadjustment != adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (selfp->vadjustment), self); - gtk_object_unref (GTK_OBJECT (selfp->vadjustment)); + g_signal_handlers_disconnect_by_func (selfp->vadjustment, + vadjustment_value_changed, + self); + + g_object_unref (G_OBJECT (selfp->vadjustment)); selfp->vadjustment = NULL; - } + } if (!adjustment) - adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, - 0.0, 0.0, 0.0)); + adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, + 0.0, 0.0, 0.0); if (selfp->vadjustment != adjustment) { - selfp->vadjustment = adjustment; - gtk_object_ref (GTK_OBJECT (selfp->vadjustment)); - gtk_object_sink (GTK_OBJECT (selfp->vadjustment)); + selfp->vadjustment = g_object_ref_sink (adjustment); + g_object_ref (G_OBJECT (selfp->vadjustment)); - gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + g_signal_connect (G_OBJECT (adjustment), "value_changed", G_CALLBACK(vadjustment_value_changed), (gpointer) self); } - // g_object_notify (G_OBJECT (self), "vadjustment"); + g_object_notify (G_OBJECT (self), "vadjustment"); update_adjustments(self); } @@ -1599,7 +1561,7 @@ class Gtk:Image:Viewer from Gtk:Widget get_image(self) { if (selfp->image) - g_object_ref(selfp->image); + g_object_ref(selfp->image); return selfp->image; } @@ -1629,23 +1591,25 @@ class Gtk:Image:Viewer from Gtk:Widget // output double* imgx, double* imgy) { - if (selfp->do_flip_horizontal) { + if (selfp->do_flip_horizontal) + { int w = selfp->canvas_width; *imgx = (selfp->current_x0+w-cx)/selfp->current_scale_x; - } + } else *imgx=(selfp->current_x0+cx)/selfp->current_scale_x; - if (selfp->do_flip_vertical) { + if (selfp->do_flip_vertical) + { int h = selfp->canvas_height; *imgy = (selfp->current_y0+h-cy)/selfp->current_scale_y; - } + } else *imgy=(selfp->current_y0+cy)/selfp->current_scale_y; #if 0 if (selfp->do_flip_vertical) - *imgy = -(cy-selfp->current_y0-GTK_WIDGET(self)->allocation.height)/selfp->current_scale_y; + *imgy = -(cy-selfp->current_y0-gtk_widget_get_allocated_width(GTK_WIDGET(self));)/selfp->current_scale_y; else *imgy=(cy+selfp->current_y0)/selfp->current_scale_y; #endif @@ -1657,18 +1621,20 @@ class Gtk:Image:Viewer from Gtk:Widget // output double* canvx, double* canvy) { - if (selfp->do_flip_horizontal) { + if (selfp->do_flip_horizontal) + { int w = selfp->canvas_width; *canvx = (selfp->current_x0+w-imgx*selfp->current_scale_x); - } + } else *canvx = imgx*selfp->current_scale_x-selfp->current_x0; - if (selfp->do_flip_vertical) { + if (selfp->do_flip_vertical) + { int h = selfp->canvas_height; *canvy = (selfp->current_y0+h-imgy*selfp->current_scale_y); - } + } else *canvy = imgy*selfp->current_scale_y-selfp->current_y0; } @@ -1678,8 +1644,8 @@ class Gtk:Image:Viewer from Gtk:Widget double min_zoom, double max_zoom) { - selfp->min_zoom = min_zoom; - selfp->max_zoom = max_zoom; + selfp->min_zoom = min_zoom; + selfp->max_zoom = max_zoom; } public gboolean @@ -1699,18 +1665,20 @@ class Gtk:Image:Viewer from Gtk:Widget *scale_y = selfp->current_scale_y; *shift_x = selfp->current_x0; *shift_y = selfp->current_y0; - if (selfp->do_flip_horizontal) { + if (selfp->do_flip_horizontal) + { int cnv_w = selfp->canvas_width; *scale_x = -*scale_x; *shift_x += cnv_w; *shift_x = -*shift_x; - } - if (selfp->do_flip_vertical) { + } + if (selfp->do_flip_vertical) + { int cnv_h = selfp->canvas_height; *scale_y = -*scale_y; *shift_y += cnv_h; *shift_y = -*shift_y; - } + } } public void @@ -1720,27 +1688,30 @@ class Gtk:Image:Viewer from Gtk:Widget gint shift_x, gint shift_y) { - if (selfp->do_flip_horizontal) { + if (selfp->do_flip_horizontal) + { int cnv_w = selfp->canvas_width; scale_x = -scale_x; shift_x = cnv_w-shift_x; - } - if (selfp->do_flip_vertical) { + } + if (selfp->do_flip_vertical) + { int cnv_h = selfp->canvas_height; scale_y = -scale_y; shift_y = cnv_h-shift_y; - } + } if (selfp->current_scale_x != scale_x || selfp->current_scale_y != scale_y || selfp->current_x0 != shift_x - || selfp->current_y0 != shift_y) { + || selfp->current_y0 != shift_y) + { selfp->current_scale_x = scale_x; selfp->current_scale_y = scale_y; selfp->current_x0 = shift_x; selfp->current_y0 = shift_y; gtk_image_viewer_redraw(self, TRUE); - } + } } public void @@ -1755,26 +1726,26 @@ class Gtk:Image:Viewer from Gtk:Widget set_fill_on_resize(self, gboolean whether) { - selfp->do_fill_on_resize = whether; + selfp->do_fill_on_resize = whether; } public void set_fill_on_resize_margin(self, gboolean margin) { - selfp->fill_on_resize_margin = margin; + selfp->fill_on_resize_margin = margin; } public void one_shot_block_fill_on_resize(self) { - selfp->one_shot_block_fill_on_resize = TRUE; + selfp->one_shot_block_fill_on_resize = TRUE; } public gboolean get_fill_on_resize(self) { - return selfp->do_fill_on_resize; + return selfp->do_fill_on_resize; } public void @@ -1797,8 +1768,8 @@ class Gtk:Image:Viewer from Gtk:Widget gboolean *do_flip_horizontal, gboolean *do_flip_vertical) { - *do_flip_horizontal = selfp->do_flip_horizontal; - *do_flip_vertical = selfp->do_flip_vertical; + *do_flip_horizontal = selfp->do_flip_horizontal; + *do_flip_vertical = selfp->do_flip_vertical; } public void @@ -1819,15 +1790,15 @@ class Gtk:Image:Viewer from Gtk:Widget // Flip adjustments if (selfp->hadjustment && do_flip_horizontal != selfp->do_flip_horizontal) { - selfp->hadjustment->value = 1 - selfp->hadjustment->page_size - selfp->hadjustment->value; + gtk_adjustment_set_value(selfp->hadjustment, + 1 - gtk_adjustment_get_page_size(selfp->hadjustment) - gtk_adjustment_get_value(selfp->hadjustment)); selfp->do_flip_horizontal = do_flip_horizontal; - gtk_adjustment_value_changed(selfp->hadjustment); need_signal = TRUE; } if (selfp->vadjustment && do_flip_vertical != selfp->do_flip_vertical) { - selfp->vadjustment->value = 1 - selfp->vadjustment->page_size - selfp->vadjustment->value; + gtk_adjustment_set_value(selfp->vadjustment, + 1 - gtk_adjustment_get_page_size(selfp->vadjustment) - gtk_adjustment_get_value(selfp->vadjustment)); selfp->do_flip_vertical = do_flip_vertical; - gtk_adjustment_value_changed(selfp->vadjustment); need_signal =TRUE; } @@ -1843,19 +1814,20 @@ class Gtk:Image:Viewer from Gtk:Widget set_vertical_lock(self, gboolean do_vertical_lock) { - gboolean need_signal = selfp->do_vertical_lock != do_vertical_lock; - selfp->do_vertical_lock = do_vertical_lock; - if (need_signal) { - gtk_image_viewer_vertical_zoom_lock_changed(self, - selfp->do_vertical_lock); - gtk_image_viewer_redraw(self, TRUE); + gboolean need_signal = selfp->do_vertical_lock != do_vertical_lock; + selfp->do_vertical_lock = do_vertical_lock; + if (need_signal) + { + gtk_image_viewer_vertical_zoom_lock_changed(self, + selfp->do_vertical_lock); + gtk_image_viewer_redraw(self, TRUE); } } public void zoom_reset(self) { - zoom_reset(self); + zoom_reset(self); } public void @@ -1863,7 +1835,7 @@ class Gtk:Image:Viewer from Gtk:Widget { gdouble margin = 0; if (!selfp->image) - margin = selfp->fill_on_resize_margin; + margin = selfp->fill_on_resize_margin; gtk_image_viewer_zoom_to_box(self, selfp->scroll_min_x, selfp->scroll_min_y, @@ -1879,6 +1851,7 @@ class Gtk:Image:Viewer from Gtk:Widget Gtk:Adjustment *hadjustment, Gtk:Adjustment *vadjustment) { + printf("set_scroll_adjustments.\n"); if (selfp->hadjustment != hadjustment) gtk_image_viewer_set_hadjustment (self, hadjustment); if (selfp->vadjustment != vadjustment) @@ -1899,6 +1872,30 @@ class Gtk:Image:Viewer from Gtk:Widget signal last NONE (INT) void vertical_zoom_lock_changed(self, gboolean vertical_zoom_lock); + + property OBJECT vadjustment + (override) + set { gtk_image_viewer_set_vadjustment(self,GTK_ADJUSTMENT(g_value_dup_object (VAL))); } + get { g_value_set_object (VAL, selfp->vadjustment); } + ; + + property OBJECT hadjustment + (override) + set { gtk_image_viewer_set_hadjustment(self, GTK_ADJUSTMENT(g_value_dup_object (VAL))); } + get { g_value_set_object (VAL, selfp->hadjustment); } + ; + + property OBJECT vscroll_policy + (override) + set { selfp->vscroll_policy = g_value_get_enum (VAL); } + get { g_value_set_enum (VAL, selfp->vscroll_policy); } + ; + + property OBJECT hscroll_policy + (override) + set { selfp->hscroll_policy = g_value_get_enum (VAL); } + get { g_value_set_enum (VAL, selfp->hscroll_policy); } + ; } %{ @@ -1916,7 +1913,7 @@ view_changed(GtkImageViewer *self, int render_width, render_height; GdkRectangle expose_rect; //printf("view_changed\n"); - if (!widget || !widget->window) + if (!widget || !gtk_widget_get_window(widget)) return 0; g_return_val_if_fail (self != NULL, FALSE); @@ -1944,47 +1941,49 @@ view_changed(GtkImageViewer *self, /* Clip the request */ if (im || (selfp->scroll_width > 0 && selfp->scroll_height > 0) - ) { - int cwidth = selfp->canvas_width; - int cheight = selfp->canvas_height; - double height, width; + ) + { + int cwidth = selfp->canvas_width; + int cheight = selfp->canvas_height; + double height, width; - width = selfp->scroll_width; - height = selfp->scroll_height; + width = selfp->scroll_width; + height = selfp->scroll_height; - if (im && width*scale_x > cwidth) - render_width = cwidth; - else - render_width = (int)(width * scale_x); + if (im && width*scale_x > cwidth) + render_width = cwidth; + else + render_width = (int)(width * scale_x); - if (im && height*scale_y > cheight) - render_height = cheight; - else - render_height = (int)(height * scale_y); + if (im && height*scale_y > cheight) + render_height = cheight; + else + render_height = (int)(height * scale_y); - // Clip only for images - if (im) { - if (render_width < cwidth) - x0 = -(cwidth - render_width)/2; - else if (x0 + render_width > width*scale_x) - x0 = width*scale_x - render_width; - else if (x0<0) - x0 = 0; + // Clip only for images + if (im) + { + if (render_width < cwidth) + x0 = -(cwidth - render_width)/2; + else if (x0 + render_width > width*scale_x) + x0 = width*scale_x - render_width; + else if (x0<0) + x0 = 0; - if (im && render_height < cheight) - y0 = -(cheight - render_height)/2; - else if (y0 + render_height > height*scale_y) - y0 = height*scale_y - render_height; - else if (y0<0) - y0 = 0; + if (im && render_height < cheight) + y0 = -(cheight - render_height)/2; + else if (y0 + render_height > height*scale_y) + y0 = height*scale_y - render_height; + else if (y0<0) + y0 = 0; } - } + } /* If scale is the same, then the image has only been scrolled, and we only need to update the exposed areas. */ if (!do_force - && widget->window + && gtk_widget_get_window(widget) && scale_x == selfp->current_scale_x && scale_y == selfp->current_scale_y ) @@ -1997,18 +1996,6 @@ view_changed(GtkImageViewer *self, dx = -dx; if (selfp->do_flip_vertical) dy = -dy; - int src_x = (dx < 0) ? 0 : dx; - int src_y = (dy < 0) ? 0 : dy; - int dst_x = (dx < 0) ? -dx : 0; - int dst_y = (dy < 0) ? -dy : 0; - - /* Construct the gc the first time it is used */ - if (!selfp->gc) - { - selfp->gc = gdk_gc_new(widget->window); - gdk_gc_copy(selfp->gc, widget->style->white_gc); - gdk_gc_set_exposures(selfp->gc, TRUE); - } selfp->current_x0 = x0; #if 0 @@ -2019,48 +2006,36 @@ view_changed(GtkImageViewer *self, #endif selfp->current_y0 = y0; - /* Scroll visible region */ - gdk_draw_drawable (widget->window, - selfp->gc, - widget->window, - src_x, src_y, - dst_x, dst_y, - GTK_WIDGET(self)->allocation.width - abs (dx), - GTK_WIDGET(self)->allocation.height - abs (dy)); + gdk_window_scroll(gtk_widget_get_window(GTK_WIDGET(self)), + dx,dy); - DBG2(g_print("Filling in: dx dy = %d %d\n", dx, dy)); + DBG2(g_print("Filling in: dx dy = %.0f %.0f\n", dx, dy)); /* And fill in the new areas */ if (dx) { - expose_rect.x = (dx < 0) ? 0 : GTK_WIDGET(self)->allocation.width - dx; - expose_rect.y = 0; - expose_rect.width = abs(dx); - expose_rect.height = GTK_WIDGET(self)->allocation.height; - - gdk_window_invalidate_rect(widget->window, - &expose_rect, - FALSE); - gdk_window_process_updates(widget->window, - FALSE); - + expose_rect.x = (dx < 0) ? 0 : gtk_widget_get_allocated_width(GTK_WIDGET(self)) - dx; + expose_rect.y = 0; + expose_rect.width = abs(dx); + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self)); + + gdk_window_invalidate_rect(gtk_widget_get_window(widget), + &expose_rect, + FALSE); } if (dy) { - expose_rect.x = 0; - expose_rect.y = (dy < 0) ? 0 : GTK_WIDGET(self)->allocation.height - dy;; - expose_rect.width = GTK_WIDGET(self)->allocation.width; - expose_rect.height = abs(dy); - - gdk_window_invalidate_rect(widget->window, - &expose_rect, - FALSE); - gdk_window_process_updates(widget->window, - FALSE); - + expose_rect.x = 0; + expose_rect.y = (dy < 0) ? 0 : gtk_widget_get_allocated_height(GTK_WIDGET(self)) - dy; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); + expose_rect.height = abs(dy); + + gdk_window_invalidate_rect(gtk_widget_get_window(widget), + &expose_rect, + FALSE); } } - else if (widget->window && + else if (gtk_widget_get_window(widget) && (do_force || scale_x != selfp->current_scale_x || scale_y != selfp->current_scale_y @@ -2075,16 +2050,13 @@ view_changed(GtkImageViewer *self, expose_rect.x = 0; expose_rect.y = 0; - expose_rect.width = GTK_WIDGET(self)->allocation.width; - expose_rect.height = GTK_WIDGET(self)->allocation.height; + expose_rect.width = gtk_widget_get_allocated_width(GTK_WIDGET(self)); + expose_rect.height = gtk_widget_get_allocated_height(GTK_WIDGET(self)); /* gdk_window_ref (expose_event.window); */ - gdk_window_invalidate_rect(widget->window, + gdk_window_invalidate_rect(gtk_widget_get_window(widget), &expose_rect, TRUE); - gdk_window_process_updates(widget->window, - TRUE - ); } return 1; @@ -2096,8 +2068,8 @@ view_changed(GtkImageViewer *self, static gint zoom_reset(GtkImageViewer *self) { - view_changed(self, TRUE, 1, 1, 0, 0); - return 1; + view_changed(self, TRUE, 1, 1, 0, 0); + return 1; } static gint @@ -2131,17 +2103,15 @@ hadjustment_value_changed (GtkAdjustment *hadjustment, min = selfp->scroll_min_x; // if flip then flip back to calculate same x0 as before flip! - double v = hadjustment->value; + double v = gtk_adjustment_get_value(hadjustment); double s = selfp->current_scale_x; if (selfp->do_flip_horizontal) - v = 1.0 - hadjustment->page_size - v; - new_x0 = (v * (width-selfp->hadjustment->page_size) + min) * s; + v = 1.0 - gtk_adjustment_get_page_size(hadjustment) - v; + new_x0 = (v * (width-gtk_adjustment_get_page_size(selfp->hadjustment)) + min) * s; dx = new_x0 - selfp->current_x0; - if ((int)dx!=0) { + if ((int)dx!=0) zoom_translate(self, (int)dx, 0); - } - } static void @@ -2152,29 +2122,25 @@ vadjustment_value_changed (GtkAdjustment *vadjustment, double min = 0; double new_y0, dy; double height; - + g_return_if_fail (GTK_IS_ADJUSTMENT (vadjustment)); g_return_if_fail (GTK_IS_IMAGE_VIEWER (data)); - + self = GTK_IMAGE_VIEWER (data); - + height = selfp->scroll_height; min = selfp->scroll_min_y; - + // if flip then flip back to calculate same x0 as before flip! - double v = vadjustment->value; + double v = gtk_adjustment_get_value(vadjustment); double s = selfp->current_scale_y; if (selfp->do_flip_vertical) - v = 1.0 - vadjustment->page_size - v; - new_y0 = (v * (height-selfp->vadjustment->page_size) + min) * s; + v = 1.0 - gtk_adjustment_get_page_size(vadjustment) - v; + new_y0 = (v * (height-gtk_adjustment_get_page_size(selfp->vadjustment)) + min) * s; dy = new_y0 - selfp->current_y0; - - if ((int)dy!=0) { -#if 0 - printf("vadjustment: value dy = %f %d\n", vadjustment->value, (int)dy); -#endif + + if ((int)dy!=0) zoom_translate(self, 0, (int)dy); - } } // This function should update the adjustment so that they reflect @@ -2182,15 +2148,16 @@ vadjustment_value_changed (GtkAdjustment *vadjustment, static gboolean update_adjustments(GtkImageViewer *self) { double scroll_min_x = 0, scroll_min_y = 0, scroll_max_x=0, scroll_max_y=0; - double scroll_width=0, scroll_height=0; - double width, height; + // double scroll_width=0, scroll_height=0; if (!selfp->hadjustment || !selfp->vadjustment ) +#if 0 width = selfp->scroll_width; height = selfp->scroll_height; +#endif // Don't rely on scroll_min_x, etc for calculation of adjustments // as these may have been overridden because of aspect ratio @@ -2203,84 +2170,60 @@ static gboolean update_adjustments(GtkImageViewer *self) selfp->canvas_width+1,selfp->canvas_height+1, // output &scroll_max_x, &scroll_max_y); - scroll_width = scroll_max_x - scroll_min_x; - scroll_height = scroll_max_y - scroll_min_y; if (selfp->hadjustment) { - selfp->hadjustment->lower = 0; - selfp->hadjustment->upper = 1.0; - selfp->hadjustment->step_increment = 0.01; - selfp->hadjustment->page_size = selfp->canvas_width / (selfp->scroll_width * selfp->current_scale_x); + gtk_adjustment_set_lower(selfp->hadjustment, 0); + gtk_adjustment_set_upper(selfp->hadjustment, 1.0); + gtk_adjustment_set_step_increment(selfp->hadjustment, 0.01); + gtk_adjustment_set_page_size(selfp->hadjustment, selfp->canvas_width / (selfp->scroll_width * selfp->current_scale_x)); double v = (selfp->current_x0/selfp->current_scale_x - selfp->scroll_min_x) - /(selfp->scroll_width-selfp->hadjustment->page_size); + /(selfp->scroll_width-gtk_adjustment_get_page_size(selfp->hadjustment)); if (selfp->do_flip_horizontal) - v = 1.0 - selfp->hadjustment->page_size -v; + v = 1.0 - gtk_adjustment_get_page_size(selfp->hadjustment) -v; - DBG(printf("current_x0 scale ps val = %d %f %f %f\n", + DBG(printf("current_x0 scale ps val = %.0f %f %f %f\n", selfp->current_x0, selfp->current_scale_x, - selfp->hadjustment->page_size, - selfp->hadjustment->value)); + gtk_adjustment_get_page_size(selfp->hadjustment), + gtk_adjustment_get_value(selfp->hadjustment))); - if (v>=-1 && v<= 2) { - selfp->hadjustment->value = v; - gtk_adjustment_changed(selfp->hadjustment); - gtk_adjustment_value_changed(selfp->hadjustment); - } + if (v>=-1 && v<= 2) + gtk_adjustment_set_value(selfp->hadjustment, v); } if (selfp->vadjustment) { - selfp->vadjustment->lower = 0; - selfp->vadjustment->upper = 1.0; - selfp->vadjustment->step_increment = 0.01; + gtk_adjustment_set_lower(selfp->vadjustment, 0); + gtk_adjustment_set_upper(selfp->vadjustment, 1.0); + gtk_adjustment_set_step_increment(selfp->vadjustment, 0.01); DBG(printf("canvas_height sh sy scroll_height*current_scale_y = %d %f %f %f\n", selfp->canvas_height, selfp->scroll_height, selfp->current_scale_y, selfp->scroll_height * selfp->current_scale_y)); - selfp->vadjustment->page_size = selfp->canvas_height / (selfp->scroll_height * selfp->current_scale_y); + gtk_adjustment_set_page_size(selfp->vadjustment, selfp->canvas_height / (selfp->scroll_height * selfp->current_scale_y)); double v = (selfp->current_y0/selfp->current_scale_y - selfp->scroll_min_y) - /(selfp->scroll_height-selfp->vadjustment->page_size); + /(selfp->scroll_height-gtk_adjustment_get_page_size(selfp->vadjustment)); if (selfp->do_flip_vertical) - v = 1.0 - selfp->vadjustment->page_size -v; + v = 1.0 - gtk_adjustment_get_page_size(selfp->vadjustment) -v; - if (v>=-1 && v<= 2) { - selfp->vadjustment->value = v; - gtk_adjustment_changed(selfp->hadjustment); - gtk_adjustment_value_changed(selfp->hadjustment); - } + if (v>=-1 && v<= 2) + gtk_adjustment_set_value(selfp->vadjustment, v); - DBG(printf("vadjust: current_y0 scale ps val = %d %f %f %f\n", + DBG(printf("vadjust: current_y0 scale ps val = %.0f %f %f %f\n", selfp->current_y0, selfp->current_scale_y, - selfp->vadjustment->page_size, - selfp->vadjustment->value)); + gtk_adjustment_get_page_size(selfp->vadjustment), + gtk_adjustment_get_value(selfp->vadjustment))); - gtk_adjustment_changed(selfp->vadjustment); - gtk_adjustment_value_changed(selfp->vadjustment); } return 0; -} -#if 0 - property OBJECT vadjustment - (nick = "Vertical adjustment", - blurb = "Vertical adjustment") - set { selfp->vadjustment = GTK_ADJUSTMENT(g_value_dup_object (VAL)); } - get { g_value_set_object (VAL, selfp->vadjustment); } - ; - property OBJECT hadjustment - (nick = "Horizontal adjustment", - blurb = "Horizontal adjustment") - set { selfp->hadjustment = GTK_ADJUSTMENT(g_value_dup_object (VAL)); } - get { g_value_set_object (VAL, selfp->hadjustment); } - ; +} -#endif static void fix_gdk_pixbuf_scale_nn(const GdkPixbuf *src, @@ -2294,61 +2237,65 @@ fix_gdk_pixbuf_scale_nn(const GdkPixbuf *src, double scale_x, double scale_y) { - int nch_src = gdk_pixbuf_get_n_channels(src); - int nch_dest = gdk_pixbuf_get_n_channels(dest); - int nch = nch_src; // Minimum num channels - int row_idx, col_idx; - if (nch_dest < nch) - nch = nch_dest; - guchar *buf_dest = gdk_pixbuf_get_pixels(dest); - guchar *buf_src = gdk_pixbuf_get_pixels(src); - gint dest_row_stride = gdk_pixbuf_get_rowstride(dest); - gint src_row_stride = gdk_pixbuf_get_rowstride(src); - gint src_height = gdk_pixbuf_get_height(src); - gint src_width = gdk_pixbuf_get_width(src); - - // Create a cache of column addresses so we don't have to - // do floating point calculations for each pixel. - gint *dest_addr = (gint*)g_new0(gint, dest_width); - for (col_idx= 0; col_idx= 0 && col_src < src_width) - dest_addr[col_idx] = col_src; - else - col_src = -1; + int nch_src = gdk_pixbuf_get_n_channels(src); + int nch_dest = gdk_pixbuf_get_n_channels(dest); + int nch = nch_src; // Minimum num channels + int row_idx, col_idx; + if (nch_dest < nch) + nch = nch_dest; + guchar *buf_dest = gdk_pixbuf_get_pixels(dest); + guchar *buf_src = gdk_pixbuf_get_pixels(src); + gint dest_row_stride = gdk_pixbuf_get_rowstride(dest); + gint src_row_stride = gdk_pixbuf_get_rowstride(src); + gint src_height = gdk_pixbuf_get_height(src); + gint src_width = gdk_pixbuf_get_width(src); + + // Create a cache of column addresses so we don't have to + // do floating point calculations for each pixel. + gint *dest_addr = (gint*)g_new0(gint, dest_width); + for (col_idx= 0; col_idx= 0 && col_src < src_width) + dest_addr[col_idx] = col_src; + else + col_src = -1; } - // Todo: clip dest_height and dest_width so that we don't - // copy outside of image. - for (row_idx=0; row_idx= src_height) { - memset(p, 0, dest_row_stride); - continue; + // Todo: clip dest_height and dest_width so that we don't + // copy outside of image. + for (row_idx=0; row_idx= src_height) + { + memset(p, 0, dest_row_stride); + continue; } - for (col_idx= 0; col_idx= 0) { - guchar *psrc = psrc_row + col_src * nch_src; + for (col_idx= 0; col_idx= 0) { + guchar *psrc = psrc_row + col_src * nch_src; - rr = *psrc++; - gg = *psrc++; - bb = *psrc++; - if (nch_src==4) - alpha = *psrc++; - } - - *p++ = rr; - *p++ = gg; - *p++ = bb; - if (nch_dest == 4) - *p++ = alpha; + rr = *psrc++; + gg = *psrc++; + bb = *psrc++; + if (nch_src==4) + alpha = *psrc++; + } + + *p++ = rr; + *p++ = gg; + *p++ = bb; + if (nch_dest == 4) + *p++ = alpha; } } - g_free(dest_addr); + g_free(dest_addr); } static gboolean turn_off_insensitive(GtkWidget *data) diff --git a/src/makefile.mingw b/src/makefile.mingw deleted file mode 100755 index aca9487..0000000 --- a/src/makefile.mingw +++ /dev/null @@ -1,22 +0,0 @@ -PATH = /usr/local/bin:/usr/local/lib:/usr/bin:/usr/lib:/bin:/lib -COPT = -mms-bitfields -mno-cygwin -DEBUG = -g -Wall -INCLUDE = `pkg-config --cflags gtk+-2.0 gtkimageviewer` -CFLAGS = $(COPT) $(DEBUG) $(INCLUDE) -LDFLAGS = `pkg-config --libs gtk+-2.0 gtkimageviewer` -mwindows -SRC = giv.c giv_mark_tree.c colormaps.cc -OBJ = $(SRC:.c=.o) -NSI_TOP = /usr/local - -giv : $(OBJ) - $(LINK.c) -o giv $(OBJ) $(LDFLAGS) - -clean : - rm giv.exe $(OBJ) - -nsi : - perl -pe 's/\n/\r\n/' ../COPYING > COPYING.dos - /cygdrive/c/Program\ Files/NSIS/makensis giv.nsi - rm -rf COPYING.dos - - diff --git a/src/plugins/tiff.c b/src/plugins/tiff.c index bdd9c54..8b2651b 100644 --- a/src/plugins/tiff.c +++ b/src/plugins/tiff.c @@ -47,8 +47,6 @@ GivImage *giv_plugin_load_file(const char *filename, GError **error) { GivImage *img=NULL; - gchar *npy_string; - guint length; TIFF* tif = TIFFOpen(filename, "r"); @@ -56,7 +54,6 @@ GivImage *giv_plugin_load_file(const char *filename, if (tif) { uint32 w, h, config=9999, bps=1, spp=1, sample_format=9999; - size_t npixels; uint8* raster; gboolean has_colormap = FALSE; uint16 *rmap, *gmap, *bmap; @@ -95,8 +92,7 @@ GivImage *giv_plugin_load_file(const char *filename, printf("Unknown planar config==%d\n", config); if (raster != NULL) { - int row_idx, col_idx, clr_idx, config; - int clr[3]; + int row_idx, col_idx, clr_idx; int dst_spp = 1; // TBD - Support more types. @@ -137,7 +133,6 @@ GivImage *giv_plugin_load_file(const char *filename, giv_image_set_one_bit(img, one_bit); guchar *dst = img->buf.buf; - int dst_bpp = giv_image_type_get_size(image_type); int dst_row_stride = giv_image_get_row_stride(img); // Copy the tiff data to the img structure. This can