widgets: use symbolic icons for volume and backlight, add icon to clear button

parent ae8344b7
......@@ -396,11 +396,6 @@ config file to be able to detect config errors
optional: true ++
default: true ++
description: Whether to display a "Clear All" button ++
button-text: ++
type: string ++
optional: true ++
default: "Clear All" ++
description: "Clear All" button text ++
description: The notification visibility state. ++
*dnd*++
type: object ++
......@@ -659,11 +654,6 @@ config file to be able to detect config errors
widget-volume ++
per-app-volume ++
properties: ++
label: ++
type: string ++
optional: true ++
default: "Volume" ++
description: Text displayed in front of the volume slider ++
show-per-app: ++
type: bool ++
optional: true ++
......@@ -716,11 +706,6 @@ config file to be able to detect config errors
type: object ++
css class: widget-backlight ++
properties: ++
label: ++
type: string ++
optional: true ++
default: "Brightness" ++
description: Text displayed in front of the backlight slider ++
device: ++
type: string ++
optional: true ++
......@@ -752,11 +737,6 @@ config file to be able to detect config errors
optional: true ++
default: true ++
description: Whether to display a "Clear All" button ++
button-text: ++
type: string ++
optional: true ++
default: "Clear All" ++
description: "Clear All" button text ++
description: Displayed if notifications are inhibited.
example:
......@@ -765,8 +745,7 @@ config file to be able to detect config errors
"widget-config": {
"title": {
"text": "Notifications",
"clear-all-button": true,
"button-text": "Clear All"
"clear-all-button": true
},
"dnd": {
"text": "Do Not Disturb"
......
src/main.vala
src/notification/notification.vala
src/configModel/configModel.vala
src/controlCenter/widgets/title/title.vala
src/controlCenter/widgets/dnd/dnd.vala
src/controlCenter/widgets/inhibitors/inhibitors.vala
src/controlCenter/widgets/volume/volume.vala
src/controlCenter/widgets/backlight/backlight.vala
src/controlCenter/widgets/slider/slider.vala
src/controlCenter/widgets/menubar/menubar.vala
src/controlCenter/widgets/powerProfiles/powerProfiles.vala
......
......@@ -79,14 +79,6 @@ msgstr "Блокировки"
msgid "No active sink input"
msgstr "Нет активного источника"
#: src/controlCenter/widgets/volume/volume.vala:58
msgid "Volume"
msgstr "Громкость"
#: src/controlCenter/widgets/backlight/backlight.vala:26
msgid "Brightness"
msgstr "Яркость"
#: src/controlCenter/widgets/slider/slider.vala:28
msgid "Slider"
msgstr "Ползунок"
......
......@@ -77,14 +77,6 @@ msgstr ""
msgid "No active sink input"
msgstr ""
#: src/controlCenter/widgets/volume/volume.vala:58
msgid "Volume"
msgstr ""
#: src/controlCenter/widgets/backlight/backlight.vala:26
msgid "Brightness"
msgstr ""
#: src/controlCenter/widgets/slider/slider.vala:28
msgid "Slider"
msgstr ""
......
......@@ -50,13 +50,11 @@
},
"inhibitors": {
"text": "Inhibitors",
"button-text": "Clear All",
"clear-all-button": true
},
"title": {
"text": "Notifications",
"clear-all-button": true,
"button-text": "Clear All"
"clear-all-button": true
},
"dnd": {
"text": "Do Not Disturb"
......
......@@ -389,11 +389,6 @@
"type": "boolean",
"description": "Whether to display a \"Clear All\" button",
"default": true
},
"button-text": {
"type": "string",
"description": "\"Clear All\" button text",
"default": "Clear All"
}
}
},
......@@ -652,11 +647,6 @@
"description": "Slider to control pulse volume",
"additionalProperties": false,
"properties": {
"label": {
"type": "string",
"description": "Text displayed in front of the volume slider",
"default": "Volume"
},
"show-per-app": {
"type": "boolean",
"default": false,
......@@ -716,11 +706,6 @@
"description": "Slider to control monitor brightness",
"additionalProperties": false,
"properties": {
"label": {
"type": "string",
"description": "Text displayed in front of the backlight slider",
"default": "Brightness"
},
"device": {
"type": "string",
"description": "Name of monitor (find possible devices using `ls /sys/class/backlight` or `ls /sys/class/leds`)",
......@@ -758,11 +743,6 @@
"type": "boolean",
"description": "Whether to display a \"Clear All\" button",
"default": true
},
"button-text": {
"type": "string",
"description": "\"Clear All\" button text",
"default": "Clear All"
}
}
}
......
......@@ -14,7 +14,8 @@ namespace XimperShellNotificationCenter.Widgets {
bool use_ddc = false;
#endif
Gtk.Label label_widget = new Gtk.Label (null);
Gtk.Image icon_widget = new Gtk.Image.from_icon_name (
"display-brightness-symbolic");
Gtk.Scale slider = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 100, 1);
public Backlight (string suffix) {
......@@ -22,8 +23,6 @@ namespace XimperShellNotificationCenter.Widgets {
Json.Object ?config = get_config (this);
if (config != null) {
string ?label = get_prop<string> (config, "label");
label_widget.set_label (label ?? _("Brightness"));
string device = (get_prop<string> (config, "device") ?? "intel_backlight");
string subsystem = (get_prop<string> (config, "subsystem") ?? "backlight");
int min = int.max (0, get_prop<int> (config, "min"));
......@@ -76,11 +75,9 @@ namespace XimperShellNotificationCenter.Widgets {
#if HAVE_DDC
if (use_ddc) {
if (ddc_clients.length == 1) {
// Single DDC display — use the existing label + slider
if (label_widget.get_label () == "Brightness") {
label_widget.set_label ("󰍹");
label_widget.set_tooltip_text (ddc_clients[0].get_display_name ());
}
// Single DDC display — use the existing icon + slider
icon_widget.set_tooltip_text (
ddc_clients[0].get_display_name ());
ddc_clients[0].brightness_change.connect ((percent) => {
if (percent < 0) {
hide ();
......@@ -95,15 +92,19 @@ namespace XimperShellNotificationCenter.Widgets {
ddc_clients[0].set_brightness.begin ((float) slider.get_value ());
slider.tooltip_text = ((int) slider.get_value ()).to_string ();
});
append (label_widget);
append (icon_widget);
append (slider);
} else {
// Multiple DDC displays — create a row per display
set_orientation (Gtk.Orientation.VERTICAL);
for (int i = 0; i < ddc_clients.length; i++) {
var row = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
var lbl = new Gtk.Label ("󰍹 %d".printf (i + 1));
lbl.set_tooltip_text (ddc_clients[i].get_display_name ());
var icon = new Gtk.Image.from_icon_name (
"display-brightness-symbolic");
var num_label = new Gtk.Label (
(i + 1).to_string ());
icon.set_tooltip_text (
ddc_clients[i].get_display_name ());
var scl = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 100, 1);
scl.set_draw_value (false);
scl.set_round_digits (0);
......@@ -122,7 +123,8 @@ namespace XimperShellNotificationCenter.Widgets {
scl.tooltip_text = ((int) scl.get_value ()).to_string ();
});
row.append (lbl);
row.append (icon);
row.append (num_label);
row.append (scl);
append (row);
}
......@@ -147,7 +149,7 @@ namespace XimperShellNotificationCenter.Widgets {
slider.tooltip_text = ((int) slider.get_value ()).to_string ();
});
append (label_widget);
append (icon_widget);
append (slider);
}
......
......@@ -12,12 +12,10 @@ namespace XimperShellNotificationCenter.Widgets {
// Default config values
string title;
bool has_clear_all_button = true;
string button_text;
public Inhibitors (string suffix) {
base (suffix);
title = _("Inhibitors");
button_text = _("Clear All");
ximper_shell_notification_center_daemon.inhibited_changed.connect ((length) => {
if (!ximper_shell_notification_center_daemon.inhibited) {
......@@ -42,11 +40,6 @@ namespace XimperShellNotificationCenter.Widgets {
if (found_clear_all) {
this.has_clear_all_button = has_clear_all_button;
}
// Get button text
string ?button_text = get_prop<string> (config, "button-text");
if (button_text != null) {
this.button_text = button_text;
}
}
title_widget = new Gtk.Label (title);
......@@ -56,7 +49,12 @@ namespace XimperShellNotificationCenter.Widgets {
append (title_widget);
if (has_clear_all_button) {
clear_all_button = new Gtk.Button.with_label (button_text);
clear_all_button = new Gtk.Button ();
var btn_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
btn_box.append (new Gtk.Image.from_icon_name (
"edit-clear-all-symbolic"));
btn_box.append (new Gtk.Label (_("Clear All")));
clear_all_button.set_child (btn_box);
clear_all_button.clicked.connect (() => {
try {
ximper_shell_notification_center_daemon.clear_inhibitors ();
......
......@@ -12,12 +12,10 @@ namespace XimperShellNotificationCenter.Widgets {
// Default config values
string title;
bool has_clear_all_button = true;
string button_text;
public Title (string suffix) {
base (suffix);
title = _("Notifications");
button_text = _("Clear All");
Json.Object ?config = get_config (this);
if (config != null) {
......@@ -33,11 +31,6 @@ namespace XimperShellNotificationCenter.Widgets {
if (found_clear_all) {
this.has_clear_all_button = has_clear_all_button;
}
// Get button text
string ?button_text = get_prop<string> (config, "button-text");
if (button_text != null) {
this.button_text = button_text;
}
}
title_widget = new Gtk.Label (title);
......@@ -46,7 +39,12 @@ namespace XimperShellNotificationCenter.Widgets {
append (title_widget);
if (has_clear_all_button) {
clear_all_button = new Gtk.Button.with_label (button_text);
clear_all_button = new Gtk.Button ();
var btn_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
btn_box.append (new Gtk.Image.from_icon_name (
"edit-clear-all-symbolic"));
btn_box.append (new Gtk.Label (_("Clear All")));
clear_all_button.set_child (btn_box);
clear_all_button.clicked.connect (() => {
noti_daemon.request_dismiss_all_notifications (ClosedReasons.DISMISSED);
});
......
......@@ -7,7 +7,7 @@ namespace XimperShellNotificationCenter.Widgets {
}
Gtk.Box main_volume_slider_container = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
Gtk.Label label_widget = new Gtk.Label (null);
Gtk.Image icon_widget = new Gtk.Image ();
Gtk.Scale slider = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 100, 1);
// Per app volume control
......@@ -38,6 +38,8 @@ namespace XimperShellNotificationCenter.Widgets {
construct {
this.client.change_default_device.connect (default_device_changed);
icon_widget.set_from_icon_name ("audio-volume-high-symbolic");
slider.value_changed.connect (() => {
if (default_sink != null) {
this.client.set_device_volume (
......@@ -45,6 +47,7 @@ namespace XimperShellNotificationCenter.Widgets {
(float) slider.get_value ());
slider.tooltip_text = ((int) slider.get_value ()).to_string ();
}
update_volume_icon ((int) slider.get_value ());
});
}
......@@ -54,9 +57,6 @@ namespace XimperShellNotificationCenter.Widgets {
Json.Object ?config = get_config (this);
if (config != null) {
string ?label = get_prop<string> (config, "label");
label_widget.set_label (label ?? _("Volume"));
bool show_per_app_found;
bool ?show_per_app = get_prop<bool> (config, "show-per-app",
out show_per_app_found);
......@@ -131,7 +131,7 @@ namespace XimperShellNotificationCenter.Widgets {
slider.draw_value = false;
slider.set_hexpand (true);
main_volume_slider_container.append (label_widget);
main_volume_slider_container.append (icon_widget);
main_volume_slider_container.append (slider);
append (main_volume_slider_container);
......@@ -177,6 +177,20 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
private void update_volume_icon (int volume) {
string icon_name;
if (volume <= 0) {
icon_name = "audio-volume-muted-symbolic";
} else if (volume <= 33) {
icon_name = "audio-volume-low-symbolic";
} else if (volume <= 66) {
icon_name = "audio-volume-medium-symbolic";
} else {
icon_name = "audio-volume-high-symbolic";
}
icon_widget.set_from_icon_name (icon_name);
}
private void set_button_icon () {
if (!reveal_button.active) {
if (expand_label == null) {
......
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