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.
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: */
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
SIGNAL_ERROR,
SIGNAL_DONE,
SIGNAL_PERCENT,
+ SIGNAL_SIZE,
SIGNAL_COUNT
};
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)
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);
}
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))
{
}
g_mutex_unlock(il->data_mutex);
+ g_signal_emit(il, signals[SIGNAL_SIZE], 0, nw, nh);
}
static void image_loader_stop_loader(ImageLoader *il)
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());
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 */
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);
#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
#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;
}
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;
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;
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: */
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: */