volume: auto-show per-app and device selector, remove config options

parent 113863fd
.widget-volume {
padding: 0px 10px;
padding: 0;
margin: 5px 15px;
border-radius: var(--window-radius);
......@@ -8,26 +8,22 @@
box-shadow: 0px 0px 10px var(--headerbar-shade-color);
border: 1px solid var(--border-color);
}
&>box {
padding: 0 10px;
margin: 0 0 0 3px;
}
}
.widget-volume .image-button {
background: transparent;
}
.widget-volume>box {
margin: 0 0 0 3px;
}
.widget-volume>box>button {}
.widget-volume revealer {
padding: 0;
margin: 0;
}
.per-app-volume {
background: transparent;
padding: 0;
padding: 0 10px;
margin: 0;
border-radius: var(--border-radius);
}
......@@ -35,3 +31,7 @@
.per-app-volume row {
background: transparent;
}
.sink-selector {
padding: 0;
}
......@@ -339,9 +339,6 @@
"^slider(#[a-zA-Z0-9_-]{1,}){0,1}?$": {
"$ref": "#/widgets/slider"
},
"^volume(#[a-zA-Z0-9_-]{1,}){0,1}?$": {
"$ref": "#/widgets/volume"
},
"^backlight(#[a-zA-Z0-9_-]{1,}){0,1}?$": {
"$ref": "#/widgets/backlight"
},
......@@ -484,59 +481,6 @@
}
}
},
"volume": {
"type": "object",
"description": "Slider to control pulse volume",
"additionalProperties": false,
"properties": {
"show-per-app": {
"type": "boolean",
"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"
},
"expand-per-app": {
"type": "boolean",
"default": false,
"description": "If the per app section should start expanded"
},
"empty-list-label": {
"type": "string",
"default": "No active sink input",
"description": "Text displayed when there are not active sink inputs"
},
"expand-button-label": {
"type": "string",
"default": "⇧",
"description": "Label displayed on button to show per app volume control"
},
"collapse-button-label": {
"type": "string",
"default": "⇩",
"description": "Label displayed on button to hide per app volume control"
},
"animation-type": {
"type": "string",
"default": "slide_down",
"description": "Animation type for menu",
"enum": ["slide_down", "slide_up", "none"]
},
"animation-duration": {
"type": "integer",
"default": 250,
"description": "Duration of animation in milliseconds"
}
}
},
"backlight": {
"type": "object",
"description": "Unified brightness control widget. Auto-detects display backlights (/sys/class/backlight), DDC/CI monitors, and keyboard backlights (/sys/class/leds/*kbd*).",
......
......@@ -2,21 +2,16 @@ namespace XimperShellNotificationCenter.Widgets {
public class SinkInputRow : Gtk.ListBoxRow {
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);
Gtk.Scale scale = new Gtk.Scale.with_range (
Gtk.Orientation.HORIZONTAL, 0, 100, 1);
public unowned PulseSinkInput sink_input;
private unowned PulseDaemon client;
private bool show_per_app_icon;
private bool show_per_app_label;
public SinkInputRow (PulseSinkInput sink_input, PulseDaemon client,
bool show_per_app_icon, bool show_per_app_label) {
public SinkInputRow (PulseSinkInput sink_input,
PulseDaemon client) {
this.client = client;
this.show_per_app_icon = show_per_app_icon;
this.show_per_app_label = show_per_app_label;
set_activatable (false);
......@@ -25,49 +20,41 @@ namespace XimperShellNotificationCenter.Widgets {
scale.draw_value = false;
scale.set_hexpand (true);
container = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
if (show_per_app_icon) {
container.append (icon);
}
if (show_per_app_label) {
container.append (label);
}
container = new Gtk.Box (
Gtk.Orientation.HORIZONTAL, 0);
container.append (icon);
container.append (scale);
set_child (container);
scale.value_changed.connect (() => {
client.set_sink_input_volume (sink_input, (float) scale.get_value ());
scale.tooltip_text = ((int) scale.get_value ()).to_string ();
client.set_sink_input_volume (
sink_input, (float) scale.get_value ());
scale.tooltip_text =
((int) scale.get_value ()).to_string ();
});
}
public void update (PulseSinkInput sink_input) {
this.sink_input = sink_input;
if (show_per_app_icon) {
string icon_name;
if (sink_input.application_icon_name != null) {
icon_name = sink_input.application_icon_name;
} else {
string icon_name = "application-x-executable";
if (sink_input.application_icon_name != null) {
icon_name = sink_input.application_icon_name;
} else if (sink_input.application_binary != null) {
var theme = Gtk.IconTheme.get_for_display (
Gdk.Display.get_default ());
if (theme.has_icon (
sink_input.application_binary)) {
icon_name = sink_input.application_binary;
}
var theme = Gtk.IconTheme.get_for_display (Gdk.Display.get_default ());
if (theme.has_icon (icon_name)) {
icon.set_from_icon_name (icon_name);
} else {
icon.set_from_icon_name ("application-x-executable");
}
}
if (show_per_app_label) {
label.set_text (this.sink_input.name);
}
icon.set_from_icon_name (icon_name);
icon.set_tooltip_text (sink_input.name);
scale.set_value (sink_input.volume);
scale.tooltip_text = ((int) scale.get_value ()).to_string ();
scale.tooltip_text =
((int) scale.get_value ()).to_string ();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment