Skip to content

Commit

Permalink
Move name and icon detection to app class
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Aug 26, 2023
1 parent 1a317de commit acee840
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
37 changes: 26 additions & 11 deletions src/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
11 changes: 2 additions & 9 deletions src/AppRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit acee840

Please sign in to comment.