mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-09-11 15:56:04 +03:00
Add show-per-app-label for volume (#301)
This commit is contained in:
parent
e3cc05d67c
commit
176e3b7291
@ -434,6 +434,16 @@ config file to be able to detect config errors
|
||||
optional: true ++
|
||||
default: false ++
|
||||
description: Show per app volume control ++
|
||||
show-per-app-icon: ++
|
||||
type: bool ++
|
||||
optional: true ++
|
||||
default: false ++
|
||||
description: Show application icon in per app control ++
|
||||
show-per-app-label: ++
|
||||
type: bool ++
|
||||
optional: true ++
|
||||
default: false ++
|
||||
description: Show application name in per app control ++
|
||||
empty-list-label: ++
|
||||
type: string ++
|
||||
optional: true ++
|
||||
|
@ -498,6 +498,16 @@
|
||||
"default": false,
|
||||
"description": "Show per app volume control"
|
||||
},
|
||||
"show-per-app-icon": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Show application icon in per app control"
|
||||
},
|
||||
"show-per-app-label": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Show application name in per app control"
|
||||
},
|
||||
"empty-list-label": {
|
||||
"type": "string",
|
||||
"default": "No active sink input",
|
||||
|
@ -3,14 +3,21 @@ namespace SwayNotificationCenter.Widgets {
|
||||
|
||||
Gtk.Box container;
|
||||
Gtk.Image icon = new Gtk.Image ();
|
||||
Gtk.Label label = new Gtk.Label (null);
|
||||
Gtk.Scale scale = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 100, 1);
|
||||
|
||||
public unowned PulseSinkInput sink_input;
|
||||
|
||||
private unowned PulseDaemon client;
|
||||
|
||||
public SinkInputRow (PulseSinkInput sink_input, PulseDaemon client, int icon_size) {
|
||||
private bool show_per_app_icon;
|
||||
private bool show_per_app_label;
|
||||
|
||||
public SinkInputRow (PulseSinkInput sink_input, PulseDaemon client,
|
||||
int icon_size, bool show_per_app_icon, bool show_per_app_label) {
|
||||
this.client = client;
|
||||
this.show_per_app_icon = show_per_app_icon;
|
||||
this.show_per_app_label = show_per_app_label;
|
||||
|
||||
update (sink_input);
|
||||
|
||||
@ -20,7 +27,12 @@ namespace SwayNotificationCenter.Widgets {
|
||||
|
||||
container = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
|
||||
|
||||
container.add (icon);
|
||||
if (show_per_app_icon) {
|
||||
container.add (icon);
|
||||
}
|
||||
if (show_per_app_label) {
|
||||
container.add (label);
|
||||
}
|
||||
|
||||
container.pack_start (scale);
|
||||
|
||||
@ -35,10 +47,16 @@ namespace SwayNotificationCenter.Widgets {
|
||||
public void update (PulseSinkInput sink_input) {
|
||||
this.sink_input = sink_input;
|
||||
|
||||
icon.set_from_icon_name (
|
||||
sink_input.application_icon_name ?? "application-x-executable",
|
||||
Gtk.IconSize.DIALOG
|
||||
);
|
||||
if (show_per_app_icon) {
|
||||
icon.set_from_icon_name (
|
||||
sink_input.application_icon_name ?? "application-x-executable",
|
||||
Gtk.IconSize.DIALOG
|
||||
);
|
||||
}
|
||||
|
||||
if (show_per_app_label) {
|
||||
label.set_text (this.sink_input.name);
|
||||
}
|
||||
|
||||
scale.set_value (sink_input.volume);
|
||||
scale.tooltip_text = ((int) scale.get_value ()).to_string ();
|
||||
|
@ -28,6 +28,8 @@ namespace SwayNotificationCenter.Widgets {
|
||||
private PulseDaemon client = new PulseDaemon ();
|
||||
|
||||
private bool show_per_app;
|
||||
private bool show_per_app_icon = true;
|
||||
private bool show_per_app_label = false;
|
||||
|
||||
construct {
|
||||
this.client.change_default_device.connect (default_device_changed);
|
||||
@ -50,7 +52,17 @@ namespace SwayNotificationCenter.Widgets {
|
||||
string ? label = get_prop<string> (config, "label");
|
||||
label_widget.set_label (label ?? "Volume");
|
||||
|
||||
show_per_app = get_prop<bool> (config, "show-per-app") ? true : false;
|
||||
bool show_per_app_found;
|
||||
bool ? show_per_app = get_prop<bool> (config, "show-per-app", out show_per_app_found);
|
||||
if (show_per_app_found) this.show_per_app = show_per_app;
|
||||
|
||||
bool show_per_app_icon_found;
|
||||
bool ? show_per_app_icon = get_prop<bool> (config, "show-per-app-icon", out show_per_app_icon_found);
|
||||
if (show_per_app_icon_found) this.show_per_app_icon = show_per_app_icon;
|
||||
|
||||
bool show_per_app_label_found;
|
||||
bool ? show_per_app_label = get_prop<bool> (config, "show-per-app-label", out show_per_app_label_found);
|
||||
if (show_per_app_label_found) this.show_per_app_label = show_per_app_label;
|
||||
|
||||
string ? el = get_prop<string> (config, "empty-list-label");
|
||||
if (el != null) empty_label = el;
|
||||
@ -106,7 +118,8 @@ namespace SwayNotificationCenter.Widgets {
|
||||
}
|
||||
|
||||
foreach (var item in this.client.active_sinks.values) {
|
||||
levels_listbox.add (new SinkInputRow (item, client, icon_size));
|
||||
levels_listbox.add (new SinkInputRow (item, client,
|
||||
icon_size, show_per_app_icon, show_per_app_label));
|
||||
}
|
||||
|
||||
this.client.change_active_sink.connect (active_sink_change);
|
||||
@ -163,7 +176,7 @@ namespace SwayNotificationCenter.Widgets {
|
||||
var label = levels_listbox.get_children ().first ().data;
|
||||
levels_listbox.remove ((Gtk.Widget) label);
|
||||
}
|
||||
levels_listbox.add (new SinkInputRow (sink, client, icon_size));
|
||||
levels_listbox.add (new SinkInputRow (sink, client, icon_size, show_per_app_icon, show_per_app_label));
|
||||
show_all ();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user