diff --git a/src/App.vala b/src/App.vala index 537e5dae..ade76ede 100644 --- a/src/App.vala +++ b/src/App.vala @@ -6,16 +6,31 @@ */ public class Sound.App : Object { - public uint32 index { get; construct; } - public string name { get; construct; } - public PulseAudio.ChannelMap channel_map { get; set; } - public double volume { get; set; } - public bool muted { get; set; } + public uint32 index { get; construct; } + public string name { get; construct; } + public string display_name { get; construct; } + public Icon icon { get; construct; } - public App (uint32 index, string name) { - Object ( - index: index, - name: name - ); - } + public double volume { get; set; } + public bool muted { get; set; } + public PulseAudio.ChannelMap channel_map { get; set; } + + public App (uint32 index, string name) { + Object ( + index: index, + name: name + ); + } + + construct { + var app_info = new GLib.DesktopAppInfo (name + ".desktop"); + + if (app_info != null) { + display_name = app_info.get_name (); + icon = app_info.get_icon (); + } else { + display_name = name; + icon = new ThemedIcon ("application-default-icon"); + } + } } diff --git a/src/AppRow.vala b/src/AppRow.vala index 23f679b0..e5bf68c0 100644 --- a/src/AppRow.vala +++ b/src/AppRow.vala @@ -96,15 +96,8 @@ public class Sound.AppRow : Gtk.Grid { public void bind_app (App app) { this.app = app; - var appinfo = new GLib.DesktopAppInfo (app.name + ".desktop"); - - title_label.label = appinfo != null ? appinfo.get_name () : app.name; - - if (appinfo != null && appinfo.get_icon () != null) { - image.set_from_gicon (appinfo.get_icon (), Gtk.IconSize.DND); - } else { - image.set_from_icon_name ("application-default-icon", Gtk.IconSize.DND); - } + title_label.label = app.display_name; + image.set_from_gicon (app.icon, Gtk.IconSize.DND); app.notify["volume"].connect (update); app.notify["muted"].connect (update);