From: Klaus Ethgen Date: Sat, 8 May 2010 22:52:09 +0000 (+0100) Subject: Fix the windowsize X-Git-Tag: v1.2~11^2~7^2~1 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=6e695dd61e5fc1ed8d0688d4b72bd87c10f6e0f5 Fix the windowsize Opening a new window from a collection should not set the default size. Unfortunately the size of the image is not available in the early state. --- diff --git a/src/gq-marshal.c b/src/gq-marshal.c index 0bfd5671..c62959e3 100644 --- a/src/gq-marshal.c +++ b/src/gq-marshal.c @@ -91,6 +91,41 @@ gq_marshal_VOID__INT_INT_INT_INT(GClosure *closure, data2); } +void gq_marshal_VOID__INT_INT(GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1, + gint arg_1, + gint arg_2, + gpointer data2); + register GMarshalFunc_VOID__INT_INT callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail(n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA(closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer(param_values + 0); + } + else + { + data1 = g_value_peek_pointer(param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback); + + callback(data1, + g_marshal_value_peek_int(param_values + 1), + g_marshal_value_peek_int(param_values + 2), + data2); +} + /* VOID:DOUBLE (gq-marshal.list:3) */ /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/gq-marshal.h b/src/gq-marshal.h index c4b21d0c..e602f7c5 100644 --- a/src/gq-marshal.h +++ b/src/gq-marshal.h @@ -17,6 +17,13 @@ extern void gq_marshal_VOID__INT_INT_INT_INT (GClosure *closure, gpointer invocation_hint, gpointer marshal_data); +extern void gq_marshal_VOID__INT_INT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + /* VOID:DOUBLE (gq-marshal.list:3) */ #define gq_marshal_VOID__DOUBLE g_cclosure_marshal_VOID__DOUBLE diff --git a/src/image-load.c b/src/image-load.c index f4167b40..b6615790 100644 --- a/src/image-load.c +++ b/src/image-load.c @@ -35,6 +35,7 @@ enum { SIGNAL_ERROR, SIGNAL_DONE, SIGNAL_PERCENT, + SIGNAL_SIZE, SIGNAL_COUNT }; @@ -150,6 +151,17 @@ static void image_loader_class_init(ImageLoaderClass *class) G_TYPE_NONE, 1, G_TYPE_DOUBLE); + signals[SIGNAL_SIZE] = + g_signal_new("size_prepared", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(ImageLoaderClass, area_ready), + NULL, NULL, + gq_marshal_VOID__INT_INT, + G_TYPE_NONE, 2, + G_TYPE_INT, + G_TYPE_INT); + } static void image_loader_finalize(GObject *object) @@ -424,6 +436,7 @@ static void image_loader_size_cb(GdkPixbufLoader *loader, if (il->requested_width < 1 || il->requested_height < 1) { g_mutex_unlock(il->data_mutex); + g_signal_emit(il, signals[SIGNAL_SIZE], 0, width, height); return; } g_mutex_unlock(il->data_mutex); @@ -440,13 +453,17 @@ static void image_loader_size_cb(GdkPixbufLoader *loader, } g_strfreev(mime_types); - if (!scale) return; + if (!scale) + { + g_signal_emit(il, signals[SIGNAL_SIZE], 0, width, height); + return; + } g_mutex_lock(il->data_mutex); + gint nw, nh; if (width > il->requested_width || height > il->requested_height) { - gint nw, nh; if (((gdouble)il->requested_width / width) < ((gdouble)il->requested_height / height)) { @@ -466,6 +483,7 @@ static void image_loader_size_cb(GdkPixbufLoader *loader, } g_mutex_unlock(il->data_mutex); + g_signal_emit(il, signals[SIGNAL_SIZE], 0, nw, nh); } static void image_loader_stop_loader(ImageLoader *il) diff --git a/src/image.c b/src/image.c index ca871895..579e7cd2 100644 --- a/src/image.c +++ b/src/image.c @@ -652,6 +652,14 @@ static void image_load_done_cb(ImageLoader *il, gpointer data) image_read_ahead_start(imd); } +static void image_load_size_cb(ImageLoader *il, guint width, guint height, gpointer data) +{ + ImageWindow *imd = data; + + DEBUG_1("image_load_size_cb: %dx%d", width, height); + pixbuf_renderer_set_size_early((PixbufRenderer *)imd->pr, width, height); +} + static void image_load_error_cb(ImageLoader *il, gpointer data) { DEBUG_1("%s image error", get_exec_time()); @@ -674,6 +682,7 @@ static void image_load_set_signals(ImageWindow *imd, gboolean override_old_signa g_signal_connect(G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd); g_signal_connect(G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd); g_signal_connect(G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd); + g_signal_connect(G_OBJECT(imd->il), "size_prepared", (GCallback)image_load_size_cb, imd); } /* this read ahead is located here merely for the callbacks, above */ diff --git a/src/img-view.c b/src/img-view.c index ff9e422f..d1becc52 100644 --- a/src/img-view.c +++ b/src/img-view.c @@ -885,6 +885,13 @@ static ViewWindow *real_view_window_new(FileData *fd, GList *list, CollectionDat image_change_fd(vw->imd, fd, image_zoom_get_default(NULL)); } + /* Wait until image is loaded otherwise size is not defined */ + for (int count = 10; count && !w && !h; count++) + { + image_get_image_size(vw->imd, &w, &h); + usleep(100000); + } + if (image_zoom_get(vw->imd) == 0.0) { image_get_image_size(vw->imd, &w, &h); diff --git a/src/main.h b/src/main.h index 50041b8f..74a81376 100644 --- a/src/main.h +++ b/src/main.h @@ -97,7 +97,7 @@ #define DEFAULT_THUMB_WIDTH 96 #define DEFAULT_THUMB_HEIGHT 72 -#define DEFAULT_MINIMAL_WINDOW_SIZE 32 +#define DEFAULT_MINIMAL_WINDOW_SIZE 100 #define IMAGE_MIN_WIDTH 100 #define SIDEBAR_DEFAULT_WIDTH 250 diff --git a/src/pixbuf-renderer.c b/src/pixbuf-renderer.c index c553f597..f1bbf600 100644 --- a/src/pixbuf-renderer.c +++ b/src/pixbuf-renderer.c @@ -3193,7 +3193,7 @@ static void pr_update_signal(PixbufRenderer *pr) #if 0 log_printf("FIXME: send updated signal\n"); #endif - DEBUG_1("%s pixbuf renderer updated - started drawing %p", get_exec_time(), pr); + DEBUG_1("%s pixbuf renderer updated - started drawing %p, img: %dx%d", get_exec_time(), pr, pr->image_width, pr->image_height); pr->debug_updated = TRUE; } @@ -4357,7 +4357,7 @@ gboolean pixbuf_renderer_get_image_size(PixbufRenderer *pr, gint *width, gint *h g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), FALSE); g_return_val_if_fail(width != NULL && height != NULL, FALSE); - if (!pr->pixbuf && !pr->source_tiles_enabled) + if (!pr->pixbuf && !pr->source_tiles_enabled && (!pr->image_width || !pr->image_height)) { *width = 0; *height = 0; @@ -4374,7 +4374,7 @@ gboolean pixbuf_renderer_get_scaled_size(PixbufRenderer *pr, gint *width, gint * g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), FALSE); g_return_val_if_fail(width != NULL && height != NULL, FALSE); - if (!pr->pixbuf && !pr->source_tiles_enabled) + if (!pr->pixbuf && !pr->source_tiles_enabled && (!pr->image_width || !pr->image_height)) { *width = 0; *height = 0; @@ -4428,4 +4428,23 @@ gboolean pixbuf_renderer_get_virtual_rect(PixbufRenderer *pr, GdkRectangle *rect rect->height = pr->vis_height; return TRUE; } + +void pixbuf_renderer_set_size_early(PixbufRenderer *pr, guint width, guint height) +{ + gdouble zoom; + gint w, h; + + zoom = pixbuf_renderer_zoom_get(pr); + pr->image_width = width; + pr->image_height = height; + + pr_zoom_clamp(pr, zoom, PR_ZOOM_FORCE, NULL); + + //w = width; + //h = height; + + //pr->width = width; + //pr->height = height; +} + /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/pixbuf-renderer.h b/src/pixbuf-renderer.h index 8ddb0986..ef3d976b 100644 --- a/src/pixbuf-renderer.h +++ b/src/pixbuf-renderer.h @@ -267,5 +267,7 @@ gboolean pixbuf_renderer_get_mouse_position(PixbufRenderer *pr, gint *x_pixel, g gboolean pixbuf_renderer_get_pixel_colors(PixbufRenderer *pr, gint x_pixel, gint y_pixel, gint *r_mouse, gint *g_mouse, gint *b_mouse); +void pixbuf_renderer_set_size_early(PixbufRenderer *pr, guint width, guint height); + #endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */