changeset 2203:9ab7570f8126

Merge branch 'ke' into ke-lua * ke: Fix compiling issue Fix the windowsize
author Klaus Ethgen <Klaus@Ethgen.de>
date Thu, 23 Dec 2010 18:19:36 +0100
parents 76c4d6774ab8 (current diff) c9be40d3499f (diff)
children de06305391a1
files
diffstat 8 files changed, 104 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gq-marshal.c	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/gq-marshal.c	Thu Dec 23 18:19:36 2010 +0100
@@ -91,6 +91,41 @@
            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: */
--- a/src/gq-marshal.h	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/gq-marshal.h	Thu Dec 23 18:19:36 2010 +0100
@@ -17,6 +17,13 @@
                                               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
 
--- a/src/image-load.c	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/image-load.c	Thu Dec 23 18:19:36 2010 +0100
@@ -35,6 +35,7 @@
 	SIGNAL_ERROR,
 	SIGNAL_DONE,
 	SIGNAL_PERCENT,
+	SIGNAL_SIZE,
 	SIGNAL_COUNT
 };
 
@@ -150,6 +151,17 @@
 			     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 @@
 	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 @@
 		}
 	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 @@
 		}
 	g_mutex_unlock(il->data_mutex);
 
+	g_signal_emit(il, signals[SIGNAL_SIZE], 0, nw, nh);
 }
 
 static void image_loader_stop_loader(ImageLoader *il)
--- a/src/image.c	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/image.c	Thu Dec 23 18:19:36 2010 +0100
@@ -652,6 +652,14 @@
 	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 @@
 	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 */
--- a/src/img-view.c	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/img-view.c	Thu Dec 23 18:19:36 2010 +0100
@@ -885,6 +885,14 @@
 		image_change_fd(vw->imd, fd, image_zoom_get_default(NULL));
 		}
 
+	/* Wait until image is loaded otherwise size is not defined */
+	int count;
+	for (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);
--- a/src/main.h	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/main.h	Thu Dec 23 18:19:36 2010 +0100
@@ -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
--- a/src/pixbuf-renderer.c	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/pixbuf-renderer.c	Thu Dec 23 18:19:36 2010 +0100
@@ -3193,7 +3193,7 @@
 #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 @@
 	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 @@
 	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 @@
 	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: */
--- a/src/pixbuf-renderer.h	Mon Mar 08 22:01:44 2010 +0100
+++ b/src/pixbuf-renderer.h	Thu Dec 23 18:19:36 2010 +0100
@@ -267,5 +267,7 @@
 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: */