summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorten Welinder <terra@gnome.org>2004-03-02 17:03:04 +0000
committerMorten Welinder <mortenw@src.gnome.org>2004-03-02 17:03:04 +0000
commite4cec76b6d34a99522a8c9e3573a0b7c94feee2d (patch)
treeb12a0316a0c16d840df895253b14c422849d1b94
parentc0b55fe0d8e4893b2799ea1c15ea72fe73451164 (diff)
downloadgtk+-e4cec76b6d34a99522a8c9e3573a0b7c94feee2d.tar.gz
Don't scale images that are small enough to fit. Avoid using incompatibly
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.
-rw-r--r--ChangeLog4
-rw-r--r--ChangeLog.pre-2-104
-rw-r--r--ChangeLog.pre-2-44
-rw-r--r--ChangeLog.pre-2-64
-rw-r--r--ChangeLog.pre-2-84
-rw-r--r--tests/testfilechooser.c36
6 files changed, 36 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index adaeafdcde..be4cdd762e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
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.
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index adaeafdcde..be4cdd762e 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,5 +1,9 @@
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.
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index adaeafdcde..be4cdd762e 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,5 +1,9 @@
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.
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index adaeafdcde..be4cdd762e 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,5 +1,9 @@
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.
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index adaeafdcde..be4cdd762e 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,5 +1,9 @@
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.
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c
index 8b96c3fad4..9fbb270783 100644
--- a/tests/testfilechooser.c
+++ b/tests/testfilechooser.c
@@ -82,7 +82,7 @@ response_cb (GtkDialog *dialog,
}
else
g_print ("Dialog was closed\n");
-
+
gtk_main_quit ();
}
@@ -138,20 +138,19 @@ static void
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);
@@ -165,10 +164,7 @@ my_new_from_file_at_size (const char *filename,
{
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
- struct {
- int width;
- int height;
- } info;
+ int info[2];
struct stat st;
guchar buffer [4096];
@@ -204,9 +200,9 @@ my_new_from_file_at_size (const char *filename,
#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)) {