From 7fb52594a94113a3d258c430ec7e50b03dcca016 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Thu, 7 Sep 2023 10:48:52 +0200 Subject: [PATCH] Only show apps for which a DesktopAppInfo can be found + add a hidden setting to show all --- data/meson.build | 5 +++++ data/sound.gschema.xml | 10 ++++++++++ meson.build | 2 ++ src/App.vala | 13 +++++++++---- src/AppRow.vala | 11 +++++++++++ src/ApplicationsPanel.vala | 1 - 6 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 data/sound.gschema.xml diff --git a/data/meson.build b/data/meson.build index 77ac57ee..efeabf1c 100644 --- a/data/meson.build +++ b/data/meson.build @@ -6,3 +6,8 @@ i18n.merge_file( install: true, install_dir: datadir / 'metainfo', ) + +install_data( + 'sound.gschema.xml', + install_dir: datadir / 'glib-2.0' / 'schemas' +) diff --git a/data/sound.gschema.xml b/data/sound.gschema.xml new file mode 100644 index 00000000..77e9db55 --- /dev/null +++ b/data/sound.gschema.xml @@ -0,0 +1,10 @@ + + + + + false + Show apps for which no info could be found + Show apps that are found by pulseaudio but misbehave so that no app info could be found. This setting may cause apps to appear that have wrong names or icons or none at all. Requires a restart. + + + diff --git a/meson.build b/meson.build index 617bd0ff..704a2fa7 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,8 @@ config_file = configure_file( configuration: config_data ) +gnome.post_install (glib_compile_schemas: true) + subdir('data') subdir('src') subdir('po') diff --git a/src/App.vala b/src/App.vala index 8319065c..645917ef 100644 --- a/src/App.vala +++ b/src/App.vala @@ -18,6 +18,14 @@ public class Sound.App : Object { public bool muted { get; set; } public PulseAudio.ChannelMap channel_map { get; set; } + public bool hidden { get; set; default = false; } + + private static Settings settings; + + static construct { + settings = new Settings ("io.elementary.switchboard.sound"); + } + public App.from_sink_input_info (PulseAudio.SinkInputInfo sink_input) { index = sink_input.index; name = sink_input.proplist.gets (PulseAudio.Proplist.PROP_APPLICATION_NAME); @@ -32,10 +40,7 @@ public class Sound.App : Object { var app_info = new DesktopAppInfo (app_id + ".desktop"); if (app_info == null) { - var results = DesktopAppInfo.search (app_id); - if (results[0] != null && results[0][0] != null) { - app_info = new DesktopAppInfo (results[0][0]); - } + settings.bind ("show-unknown-apps", this, "hidden", GET | INVERT_BOOLEAN); } if (app_info != null) { diff --git a/src/AppRow.vala b/src/AppRow.vala index 85779229..78b2b408 100644 --- a/src/AppRow.vala +++ b/src/AppRow.vala @@ -110,6 +110,17 @@ public class Sound.AppRow : Gtk.Grid { image.set_from_gicon (app.icon, Gtk.IconSize.DND); app.changed.connect (update); + app.notify["hidden"].connect (() => { + if (app.hidden) { + hide (); + } else { + show_all (); + } + }); + + if (!app.hidden) { + show_all (); + } volume_scale.set_value (app.volume); } diff --git a/src/ApplicationsPanel.vala b/src/ApplicationsPanel.vala index 9680bbe2..5dbacdc2 100644 --- a/src/ApplicationsPanel.vala +++ b/src/ApplicationsPanel.vala @@ -52,7 +52,6 @@ public class Sound.ApplicationsPanel : Gtk.Box { var app = (App) item; var app_row = new AppRow (); app_row.bind_app (app); - app_row.show_all (); return app_row; } }