2004-03-02 Morten Welinder <terra@gnome.org>
+ * tests/testfilechooser.c (size_prepared_cb): Don't scale images
+ that are small enough to fit. Avoid using incompatibly typed data
+ pointer.
+
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_get_resizable_hints): Test the
resize_horizontally pointer, not the deferenced pointer.
2004-03-02 Morten Welinder <terra@gnome.org>
+ * tests/testfilechooser.c (size_prepared_cb): Don't scale images
+ that are small enough to fit. Avoid using incompatibly typed data
+ pointer.
+
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_get_resizable_hints): Test the
resize_horizontally pointer, not the deferenced pointer.
2004-03-02 Morten Welinder <terra@gnome.org>
+ * tests/testfilechooser.c (size_prepared_cb): Don't scale images
+ that are small enough to fit. Avoid using incompatibly typed data
+ pointer.
+
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_get_resizable_hints): Test the
resize_horizontally pointer, not the deferenced pointer.
2004-03-02 Morten Welinder <terra@gnome.org>
+ * tests/testfilechooser.c (size_prepared_cb): Don't scale images
+ that are small enough to fit. Avoid using incompatibly typed data
+ pointer.
+
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_get_resizable_hints): Test the
resize_horizontally pointer, not the deferenced pointer.
2004-03-02 Morten Welinder <terra@gnome.org>
+ * tests/testfilechooser.c (size_prepared_cb): Don't scale images
+ that are small enough to fit. Avoid using incompatibly typed data
+ pointer.
+
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_get_resizable_hints): Test the
resize_horizontally pointer, not the deferenced pointer.
}
else
g_print ("Dialog was closed\n");
-
+
gtk_main_quit ();
}
size_prepared_cb (GdkPixbufLoader *loader,
int width,
int height,
- gpointer data)
+ int *data)
{
- struct {
- int width;
- int height;
- } *info = data;
-
- if ((double)height * (double)info->width >
- (double)width * (double)info->height) {
- width = 0.5 + (double)width * (double)info->height / (double)height;
- height = info->height;
+ int des_width = data[0];
+ int des_height = data[1];
+
+ if (des_height >= height && des_width >= width) {
+ /* Nothing */
+ } else if ((double)height * des_width > (double)width * des_height) {
+ width = 0.5 + (double)width * des_height / (double)height;
+ height = des_height;
} else {
- height = 0.5 + (double)height * (double)info->width / (double)width;
- width = info->width;
+ height = 0.5 + (double)height * des_width / (double)width;
+ width = des_width;
}
gdk_pixbuf_loader_set_size (loader, width, height);
{
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
- struct {
- int width;
- int height;
- } info;
+ int info[2];
struct stat st;
guchar buffer [4096];
#ifdef DONT_PRESERVE_ASPECT
gdk_pixbuf_loader_set_size (loader, width, height);
#else
- info.width = width;
- info.height = height;
- g_signal_connect (loader, "size-prepared", G_CALLBACK (&size_prepared_cb), &info);
+ info[0] = width;
+ info[1] = height;
+ g_signal_connect (loader, "size-prepared", G_CALLBACK (size_prepared_cb), info);
#endif
while (!feof (f)) {