Skip to content

Commit

Permalink
Only show apps for which a DesktopAppInfo can be found + add a hidden…
Browse files Browse the repository at this point in the history
… setting to show all
  • Loading branch information
leolost2605 committed Sep 7, 2023
1 parent 099fa37 commit 7fb5259
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
10 changes: 10 additions & 0 deletions data/sound.gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="io.elementary.switchboard.sound" path="/io/elementary/switchboard/sound/">
<key name="show-unknown-apps" type="b">
<default>false</default>
<summary>Show apps for which no info could be found</summary>
<description>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.</description>
</key>
</schema>
</schemalist>
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ config_file = configure_file(
configuration: config_data
)

gnome.post_install (glib_compile_schemas: true)

subdir('data')
subdir('src')
subdir('po')
13 changes: 9 additions & 4 deletions src/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions src/AppRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/ApplicationsPanel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 7fb5259

Please sign in to comment.