From 58c57de6f15f73fc3feaaf98629fd56e78fd40de Mon Sep 17 00:00:00 2001 From: Leonhard Date: Sat, 26 Aug 2023 15:26:13 +0200 Subject: [PATCH] Add media label --- src/AppRow.vala | 30 ++++++++++++++++++++---------- src/PulseAudioManager.vala | 5 ++--- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/AppRow.vala b/src/AppRow.vala index e5bf68c0..c5f45aa1 100644 --- a/src/AppRow.vala +++ b/src/AppRow.vala @@ -7,7 +7,8 @@ public class Sound.AppRow : Gtk.Grid { private App? app; - private Gtk.Label title_label; + private Gtk.Label app_name_label; + private Gtk.Label media_name_label; private Gtk.Image image; private Gtk.Button icon_button; private Gtk.Scale volume_scale; @@ -18,12 +19,19 @@ public class Sound.AppRow : Gtk.Grid { pixel_size = 32 }; - title_label = new Gtk.Label ("") { - ellipsize = Pango.EllipsizeMode.END, - valign = Gtk.Align.END, + app_name_label = new Gtk.Label ("") { + ellipsize = END, + valign = END, xalign = 0 }; - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL); + app_name_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL); + + media_name_label = new Gtk.Label ("") { + ellipsize = END, + valign = END, + xalign = 0 + }; + media_name_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); icon_button = new Gtk.Button.from_icon_name ("audio-volume-muted") { can_focus = false @@ -47,10 +55,11 @@ public class Sound.AppRow : Gtk.Grid { margin_bottom = 6; margin_start = 6; - attach (image, 0, 0, 1, 2); - attach (title_label, 1, 0, 2); - attach (icon_button, 1, 1); - attach (volume_scale, 2, 1); + attach (image, 0, 0, 1, 3); + attach (app_name_label, 1, 0, 2); + attach (media_name_label, 1, 1, 2); + attach (icon_button, 1, 2); + attach (volume_scale, 2, 2); attach (mute_switch, 3, 0, 1, 2); volume_scale.change_value.connect ((type, new_value) => { @@ -78,6 +87,7 @@ public class Sound.AppRow : Gtk.Grid { } private void update () { + media_name_label.label = app.media_name; volume_scale.set_value (app.volume); mute_switch.state = !app.muted; volume_scale.sensitive = !app.muted; @@ -96,7 +106,7 @@ public class Sound.AppRow : Gtk.Grid { public void bind_app (App app) { this.app = app; - title_label.label = app.display_name; + app_name_label.label = app.display_name; image.set_from_gicon (app.icon, Gtk.IconSize.DND); app.notify["volume"].connect (update); diff --git a/src/PulseAudioManager.vala b/src/PulseAudioManager.vala index db2bf006..3e946c2b 100644 --- a/src/PulseAudioManager.vala +++ b/src/PulseAudioManager.vala @@ -617,9 +617,8 @@ public class Sound.PulseAudioManager : GLib.Object { apps.append (app); } - if (!app.channel_map.equal (sink_input.channel_map)) { - app.channel_map = sink_input.channel_map; - } + app.media_name = sink_input.name; + app.channel_map = sink_input.channel_map; if ((sink_input.mute != 0) != app.muted) { app.muted = sink_input.mute != 0;