[pulseaudio-commits] src/mainwindow.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 5 09:27:43 UTC 2019
src/mainwindow.cc | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
New commits:
commit e6caa8b87a9b463ea0db85deb77bac3d960ff1f1
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Sat Jul 27 13:53:48 2019 +0300
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
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 6fa3480..4b1cb8a 100644
--- a/src/mainwindow.cc
+++ b/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);
}
}
More information about the pulseaudio-commits
mailing list