summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2010-08-05 11:02:51 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-08-05 12:49:32 -0400
commit214196373040efd160a051bf4cb02abe7ad2d953 (patch)
treefa4180c4d27ba0454f4f2004ed84ead632bf58ce
parente5c50ed0fe4255136d64851913c95ba72eea22b2 (diff)
Don't try to display images bigger than 32000 pixels
X and GTK+ can't deal with windows that are bigger than 65535 pixels.
-rw-r--r--window.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/window.c b/window.c
index 591c921..75e97a2 100644
--- a/window.c
+++ b/window.c
@@ -9,7 +9,7 @@
#include "sivviewport.h"
#define MIN_ZOOM -80
-#define MAX_ZOOM 65
+#define MAX_ZOOM 80
struct SivWindow
{
@@ -57,13 +57,15 @@ get_widget (SivWindow *window, const char *name)
static GtkAdjustment *
get_hadj (SivWindow *window)
{
- return gtk_scrolled_window_get_hadjustment (get_widget (window, "scrolled_window"));
+ return gtk_scrolled_window_get_hadjustment
+ (get_widget (window, "scrolled_window"));
}
static GtkAdjustment *
get_vadj (SivWindow *window)
{
- return gtk_scrolled_window_get_vadjustment (get_widget (window, "scrolled_window"));
+ return gtk_scrolled_window_get_vadjustment (
+ get_widget (window, "scrolled_window"));
}
static double
@@ -166,10 +168,15 @@ paint_rect (GtkWidget *drawing_area, GdkRectangle *area, SivWindow *window)
color2 = 0x00cccccc;
}
- if (gtk_check_menu_item_get_active (get_widget (window, "menu_smooth_image")))
+ if (gtk_check_menu_item_get_active (
+ get_widget (window, "menu_smooth_image")))
+ {
interp = GDK_INTERP_BILINEAR;
+ }
else
+ {
interp = GDK_INTERP_NEAREST;
+ }
gdk_pixbuf_composite_color (window->original, tmp,
0, 0, dest.width, dest.height,
@@ -182,7 +189,8 @@ paint_rect (GtkWidget *drawing_area, GdkRectangle *area, SivWindow *window)
pixmap = gdk_pixmap_new (drawing_area->window, dest.width, dest.height, -1);
gdk_draw_pixbuf (pixmap, NULL,
- tmp, 0, 0, 0, 0, dest.width, dest.height, GDK_RGB_DITHER_NONE,
+ tmp, 0, 0, 0, 0, dest.width, dest.height,
+ GDK_RGB_DITHER_NONE,
0, 0);
gc = gdk_gc_new (drawing_area->window);
@@ -255,11 +263,10 @@ set_sensitivity (SivWindow *window)
int i;
/* List of widgets that are sensitive if and only if a file is loaded */
- const char insensitive[][32] =
- {
- "menu_white", "menu_checkerboard", "menu_no", "menu_smooth_image",
- "menu_zoom_normal", "zoom_normal"
- };
+ const char insensitive[][32] = {
+ "menu_white", "menu_checkerboard", "menu_no", "menu_smooth_image",
+ "menu_zoom_normal", "zoom_normal"
+ };
for (i = 0; i < G_N_ELEMENTS (insensitive); ++i)
{
@@ -278,6 +285,12 @@ set_sensitivity (SivWindow *window)
compute_size (window, &w, &h);
can_zoom_in = window->zoom_level < MAX_ZOOM;
+ if (w > 32000 || h > 32000)
+ {
+ /* GTK+ doesn't support native windows larger than this.
+ */
+ can_zoom_in = FALSE;
+ }
can_zoom_out = window->zoom_level > MIN_ZOOM;
if (window->zoom_level <= 0 && (w < 16 || h < 16))