[pulseaudio-commits] [Git][pulseaudio/pavucontrol][master] mainwindow: scale icons to sane size

Arun Raghavan gitlab at gitlab.freedesktop.org
Mon Aug 5 09:27:43 UTC 2019



Arun Raghavan pushed to branch master at PulseAudio / pavucontrol


Commits:
e6caa8b8 by Tanu Kaskinen at 2019-07-27T10:53:48Z
mainwindow: scale icons to sane size

If load_icon() fails, we treat the icon name as a file path and try to
load an image from the path. In case that works, we need to ensure that
the has correct size. Previously that wasn't done, which led to too
large icons.

scale_simple() doesn't do anything if the image is already the correct
size, so we can call it unconditionally.

The exception handling was a bit weird in that the exception types
didn't match the documentation of IconTheme::load_icon() and
Image::set(). I updated the exception types (Image::set() doesn't need
exception handling any more, because now it's called with a Pixbuf
rather than a file name).

Fixes: https://gitlab.freedesktop.org/pulseaudio/pavucontrol/issues/60

- - - - -


1 changed file:

- src/mainwindow.cc


Changes:

=====================================
src/mainwindow.cc
=====================================
@@ -283,17 +283,23 @@ static void set_icon_name_fallback(Gtk::Image *i, const char *name, Gtk::IconSiz
 
     try {
         pixbuf = theme->load_icon(name, width, Gtk::ICON_LOOKUP_GENERIC_FALLBACK | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    } catch (Glib::Error &e) {
+        /* Ignore errors. */
+    }
+
+    if (!pixbuf) {
+        try {
+            pixbuf = Gdk::Pixbuf::create_from_file(name);
+        } catch (Glib::FileError &e) {
+            /* Ignore errors. */
+        } catch (Gdk::PixbufError &e) {
+            /* Ignore errors. */
+        }
+    }
 
-        if (pixbuf)
-            i->set(pixbuf);
-        else
-            i->set(name);
-    } catch (Gtk::IconThemeError &e) {
-        i->set(name);
-    } catch (Gio::Error &e) {
-        i->set(name);
-    } catch (Gdk::PixbufError &e) {
-        i->set(name);
+    if (pixbuf) {
+        pixbuf = pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
+        i->set(pixbuf);
     }
 }
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pavucontrol/commit/e6caa8b87a9b463ea0db85deb77bac3d960ff1f1

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pavucontrol/commit/e6caa8b87a9b463ea0db85deb77bac3d960ff1f1
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20190805/f31c0e15/attachment-0001.html>


More information about the pulseaudio-commits mailing list