improve image display, particularly for large images, especially if taller than they...
[claws.git] / src / gtk / gtkutils.c
index 4b70c58b248aacafb22ca653f8acf9d8f5e965af..f09d5a84fd265456d37fa39b4102da88d29eaee2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2018 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -757,7 +757,7 @@ static gboolean move_bar_cb(gpointer data)
        if (!GTK_IS_PROGRESS_BAR(w)) {
                return FALSE;
        }
-
+       gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(w), 0.1);
        gtk_progress_bar_pulse(GTK_PROGRESS_BAR(w));
        GTK_EVENTS_FLUSH();
        return TRUE;
@@ -1224,10 +1224,8 @@ GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *
 {
        GtkWidget *btn;
        GtkWidget *btn_label;
-#if !GTK_CHECK_VERSION(3, 0, 0)
        GdkColormap *cmap;
        gboolean success[2];
-#endif
        GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
        gchar *local_url = NULL;
        if (!url)
@@ -1241,11 +1239,9 @@ GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *
        btn = gtk_button_new_with_label(label?label:url);
        gtk_button_set_relief(GTK_BUTTON(btn), GTK_RELIEF_NONE);
        btn_label = gtk_bin_get_child(GTK_BIN((btn)));
-#if !GTK_CHECK_VERSION(3, 0, 0)
        cmap = gdk_drawable_get_colormap(gtk_widget_get_window(window));
        gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
        if (success[0] == TRUE && success[1] == TRUE) {
-#endif
                GtkStyle *style;
                gtk_widget_ensure_style(btn_label);
                style = gtk_style_copy
@@ -1255,10 +1251,8 @@ GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *
                style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
                gtk_widget_set_style(btn_label, style);
                g_object_unref(style);
-#if !GTK_CHECK_VERSION(3, 0, 0)
        } else
                g_warning("color allocation failed");
-#endif
 
        g_signal_connect(G_OBJECT(btn), "enter",
                         G_CALLBACK(link_btn_enter), window);
@@ -1756,32 +1750,6 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width,
                }
        }
 
-       w = gdk_pixbuf_get_width(pixbuf);
-       h = gdk_pixbuf_get_height(pixbuf);
-
-       if (angle == 90 || angle == 270) {
-               avail_height = box_width;
-               avail_width = box_height;
-       } else {
-               avail_width = box_width;
-               avail_height = box_height;
-       }
-
-       /* Scale first */
-       if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) {
-               if (w > avail_width) {
-                       h = (avail_width * h) / w;
-                       w = avail_width;
-               }
-               if (h > avail_height) {
-                       w = (avail_height * w) / h;
-                       h = avail_height;
-               }
-               t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, 
-                       w, h, GDK_INTERP_BILINEAR);
-               g_object_unref(pixbuf);
-               pixbuf = t_pixbuf;
-       }
 
        /* Rotate if needed */
        if (angle != 0) {
@@ -1804,6 +1772,23 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width,
                pixbuf = t_pixbuf;
        }
 
+       w = gdk_pixbuf_get_width(pixbuf);
+       h = gdk_pixbuf_get_height(pixbuf);
+
+       avail_width = box_width;
+       avail_height = box_height;
+               
+       if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) {
+               if (w > avail_width || h > avail_height) {
+                       h = (avail_width * h) / w;
+                       w = avail_width;
+               }
+               t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, 
+                       w, h, GDK_INTERP_BILINEAR);
+               g_object_unref(pixbuf);
+               pixbuf = t_pixbuf;
+       }
+
        return pixbuf;
 }