widgets: migrate UI to Blueprint templates

parent dd0798ae
using Gtk 4.0;
using Adw 1;
template $XimperShellNotificationCenterNotificationCloseButton: Adw.Bin {
valign: start;
halign: end;
Revealer revealer {
transition-type: crossfade;
reveal-child: false;
notify::child-revealed => $on_child_revealed();
child: Button button {
icon-name: "ximper-shell-notification-center-close-symbolic";
has-frame: false;
halign: center;
valign: center;
clicked => $on_clicked();
styles ["close-button", "circular"]
};
}
}
using Gtk 4.0;
template $XimperShellNotificationCenterWidgetsBacklight:
$XimperShellNotificationCenterWidgetsBaseWidget {
orientation: vertical;
Box topbar {
orientation: horizontal;
spacing: 6;
margin-start: 10;
margin-end: 10;
Image topbar_icon {
icon-name: "display-brightness-symbolic";
}
Label topbar_label {
label: _("Brightness");
hexpand: true;
halign: start;
}
ToggleButton reveal_btn {
icon-name: "ximper-shell-notification-center-up-small-symbolic";
toggled => $on_reveal_toggled();
}
}
Revealer revealer {
transition-type: slide_down;
transition-duration: 200;
child: Box content {
orientation: vertical;
Box displays_box {
orientation: vertical;
margin-start: 10;
margin-end: 10;
}
Separator separator {
margin-top: 8;
margin-bottom: 8;
}
Box kbd_box {
orientation: vertical;
margin-start: 10;
margin-end: 10;
}
};
}
Box single_source_box {
orientation: vertical;
visible: false;
margin-start: 10;
margin-end: 10;
}
}
using Gtk 4.0;
template $XimperShellNotificationCenterWidgetsInhibitors:
$XimperShellNotificationCenterWidgetsBaseWidget {
Label title_widget {
hexpand: true;
halign: start;
}
Button clear_all_button {
can-focus: false;
valign: center;
clicked => $on_clear_inhibitors_clicked();
Box {
orientation: horizontal;
spacing: 10;
Image {
icon-name: "edit-clear-all-symbolic";
}
Label {
label: _("Clear All");
}
}
}
}
using Gtk 4.0;
template $XimperShellNotificationCenterWidgetsLabel:
$XimperShellNotificationCenterWidgetsBaseWidget {
Label label_widget {
ellipsize: end;
wrap: true;
max-width-chars: 0;
wrap-mode: word_char;
justify: left;
xalign: 0;
yalign: 0;
halign: fill;
hexpand: true;
}
}
using Gtk 4.0;
template $XimperShellNotificationCenterWidgetsTitle:
$XimperShellNotificationCenterWidgetsBaseWidget {
Label title_widget {
hexpand: true;
halign: start;
}
Button clear_all_button {
can-focus: false;
valign: center;
clicked => $on_clear_all_clicked();
styles ["control-center-clear-all"]
Box {
orientation: horizontal;
spacing: 10;
Image {
icon-name: "edit-clear-all-symbolic";
}
Label {
label: _("Clear All");
}
}
}
}
using Gtk 4.0;
template $XimperShellNotificationCenterWidgetsVolume:
$XimperShellNotificationCenterWidgetsBaseWidget {
orientation: vertical;
Box main_volume_slider_container {
orientation: horizontal;
Image icon_widget {
icon-name: "audio-volume-high-symbolic";
}
Scale slider {
orientation: horizontal;
hexpand: true;
draw-value: false;
adjustment: Adjustment {
lower: 0;
upper: 100;
step-increment: 1;
};
value-changed => $on_slider_changed();
}
ToggleButton reveal_button {
icon-name: "ximper-shell-notification-center-up-small-symbolic";
toggled => $on_reveal_toggled();
}
}
Revealer revealer {
transition-type: slide_down;
transition-duration: 200;
child: Box revealer_content {
orientation: vertical;
ListBox levels_listbox {
activate-on-single-click: true;
selection-mode: none;
styles ["per-app-volume"]
}
Separator sink_separator {
visible: false;
margin-top: 8;
margin-bottom: 8;
}
Box sink_list_box {
orientation: vertical;
visible: false;
margin-start: 4;
margin-end: 4;
margin-top: 4;
margin-bottom: 4;
styles ["sink-selector"]
}
};
}
}
......@@ -12,7 +12,13 @@
<file preprocess="xml-stripblanks">ui/notification_window.ui</file>
<file preprocess="xml-stripblanks">ui/notification.ui</file>
<file preprocess="xml-stripblanks">ui/control_center.ui</file>
<file preprocess="xml-stripblanks">ui/mpris_player.ui</file>
<file preprocess="xml-stripblanks">ui/notifications_widget.ui</file>
<file preprocess="xml-stripblanks">ui/notification_close_button.ui</file>
<file preprocess="xml-stripblanks">ui/widgets/mpris_player.ui</file>
<file preprocess="xml-stripblanks">ui/widgets/notifications.ui</file>
<file preprocess="xml-stripblanks">ui/widgets/label.ui</file>
<file preprocess="xml-stripblanks">ui/widgets/title.ui</file>
<file preprocess="xml-stripblanks">ui/widgets/inhibitors.ui</file>
<file preprocess="xml-stripblanks">ui/widgets/volume.ui</file>
<file preprocess="xml-stripblanks">ui/widgets/backlight.ui</file>
</gresource>
</gresources>
......@@ -13,4 +13,7 @@ src/controlCenter/widgets/quickSettings/tiles/caffeineTile.vala
src/controlCenter/widgets/quickSettings/tiles/nightLightTile.vala
src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala
data/ui/notifications_widget.blp
data/ui/widgets/notifications.blp
data/ui/widgets/title.blp
data/ui/widgets/inhibitors.blp
data/ui/widgets/backlight.blp
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ximper-shell-notification-center 0.1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-24 00:00+0300\n"
"POT-Creation-Date: 2026-03-26 18:49+0300\n"
"PO-Revision-Date: 2026-03-24 00:00+0300\n"
"Last-Translator: \n"
"Language-Team: Russian\n"
......@@ -15,7 +15,8 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
#: src/notification/notification.vala:539
msgid "Enter Text"
......@@ -58,31 +59,14 @@ msgstr[0] "%d д. назад"
msgstr[1] "%d д. назад"
msgstr[2] "%d д. назад"
#: src/controlCenter/widgets/title/title.vala:19
#: src/controlCenter/widgets/title/title.vala:21
msgid "Notifications"
msgstr "Уведомления"
#: src/controlCenter/widgets/title/title.vala:20
#: src/controlCenter/widgets/inhibitors/inhibitors.vala:20
msgid "Clear All"
msgstr "Очистить"
#: src/controlCenter/widgets/inhibitors/inhibitors.vala:19
#: src/controlCenter/widgets/inhibitors/inhibitors.vala:21
msgid "Inhibitors"
msgstr "Блокировки"
#: src/controlCenter/widgets/volume/volume.vala:53
msgid "No active sink input"
msgstr "Нет активного источника"
#: src/controlCenter/widgets/backlight/backlight.vala
msgid "Brightness"
msgstr "Яркость"
#: src/controlCenter/widgets/notifications/notifications.vala:56
msgid "No Notifications"
msgstr "Нет уведомлений"
#: src/controlCenter/widgets/quickSettings/tiles/dndTile.vala:5
msgid "Do Not Disturb"
msgstr "Не беспокоить"
......@@ -91,18 +75,6 @@ msgstr "Не беспокоить"
msgid "Dark Style"
msgstr "Тёмный стиль"
#: src/controlCenter/widgets/quickSettings/tiles/caffeineTile.vala:15
msgid "Caffeine"
msgstr "Кофеин"
#: src/controlCenter/widgets/quickSettings/tiles/caffeineTile.vala:49
msgid "Caffeine mode"
msgstr "Режим кофеина"
#: src/controlCenter/widgets/quickSettings/tiles/nightLightTile.vala:8
msgid "Night Light"
msgstr "Ночной свет"
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:18
msgid "Power Mode"
msgstr "Режим питания"
......@@ -119,42 +91,69 @@ msgstr "Баланс"
msgid "Power Saver"
msgstr "Энергосбережение"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/caffeineTile.vala:15
msgid "Caffeine"
msgstr "Кофеин"
#: src/controlCenter/widgets/quickSettings/tiles/caffeineTile.vala:49
msgid "Caffeine mode"
msgstr "Режим кофеина"
#: src/controlCenter/widgets/quickSettings/tiles/nightLightTile.vala:8
msgid "Night Light"
msgstr "Ночной свет"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:27
msgid "Wi-Fi"
msgstr "Wi-Fi"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:94
msgid "Disabled"
msgstr "Отключён"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:135
msgid "Not Connected"
msgstr "Не подключён"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
msgid "Connecting…"
msgstr "Подключение…"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:405
msgid "Password"
msgstr "Пароль"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:409
msgid "Connect"
msgstr "Подключить"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:469
msgid "Connecting…"
msgstr "Подключение…"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:485
msgid "Network Settings"
msgstr "Настройки сети"
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala:20
msgid "VPN"
msgstr "VPN"
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala:88
msgid "Disconnected"
msgstr "Отключён"
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala:344
msgid "VPN Settings"
msgstr "Настройки VPN"
#: data/ui/widgets/notifications.blp:57
msgid "No Notifications"
msgstr "Нет уведомлений"
#: data/ui/widgets/title.blp:27 data/ui/widgets/inhibitors.blp:25
msgid "Clear All"
msgstr "Очистить"
#: data/ui/widgets/backlight.blp:18
msgid "Brightness"
msgstr "Яркость"
#~ msgid "No active sink input"
#~ msgstr "Нет активного источника"
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# This file is distributed under the same license as the ximper-shell-notification-center package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Project-Id-Version: ximper-shell-notification-center\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-24 00:00+0300\n"
"POT-Creation-Date: 2026-03-26 18:49+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
......@@ -56,37 +56,36 @@ msgid_plural "%d days ago"
msgstr[0] ""
msgstr[1] ""
#: src/controlCenter/widgets/title/title.vala:19
#: src/controlCenter/widgets/title/title.vala:21
msgid "Notifications"
msgstr ""
#: src/controlCenter/widgets/title/title.vala:20
#: src/controlCenter/widgets/inhibitors/inhibitors.vala:20
msgid "Clear All"
#: src/controlCenter/widgets/inhibitors/inhibitors.vala:21
msgid "Inhibitors"
msgstr ""
#: src/controlCenter/widgets/inhibitors/inhibitors.vala:19
msgid "Inhibitors"
#: src/controlCenter/widgets/quickSettings/tiles/dndTile.vala:5
msgid "Do Not Disturb"
msgstr ""
#: src/controlCenter/widgets/volume/volume.vala:53
msgid "No active sink input"
#: src/controlCenter/widgets/quickSettings/tiles/darkModeTile.vala:7
msgid "Dark Style"
msgstr ""
#: src/controlCenter/widgets/backlight/backlight.vala
msgid "Brightness"
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:18
msgid "Power Mode"
msgstr ""
#: src/controlCenter/widgets/notifications/notifications.vala:56
msgid "No Notifications"
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:95
msgid "Performance"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/dndTile.vala:5
msgid "Do Not Disturb"
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:97
msgid "Balanced"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/darkModeTile.vala:7
msgid "Dark Style"
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:99
msgid "Power Saver"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/caffeineTile.vala:15
......@@ -101,18 +100,54 @@ msgstr ""
msgid "Night Light"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:18
msgid "Power Mode"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:27
msgid "Wi-Fi"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:95
msgid "Performance"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:94
msgid "Disabled"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:97
msgid "Balanced"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:135
msgid "Not Connected"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/powerProfilesTile.vala:99
msgid "Power Saver"
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:405
msgid "Password"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:409
msgid "Connect"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:469
msgid "Connecting…"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/wifiTile.vala:485
msgid "Network Settings"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala:20
msgid "VPN"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala:88
msgid "Disconnected"
msgstr ""
#: src/controlCenter/widgets/quickSettings/tiles/vpnTile.vala:344
msgid "VPN Settings"
msgstr ""
#: data/ui/widgets/notifications.blp:57
msgid "No Notifications"
msgstr ""
#: data/ui/widgets/title.blp:27 data/ui/widgets/inhibitors.blp:25
msgid "Clear All"
msgstr ""
#: data/ui/widgets/backlight.blp:18
msgid "Brightness"
msgstr ""
using GLib;
namespace XimperShellNotificationCenter.Widgets {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/widgets/backlight.ui")]
public class Backlight : BaseWidget {
public override string widget_name {
get {
......@@ -22,17 +23,25 @@ namespace XimperShellNotificationCenter.Widgets {
BrightnessSource[] display_sources = {};
BrightnessSource[] kbd_sources = {};
Gtk.Box ?displays_box = null;
Gtk.Box ?kbd_box = null;
Gtk.Separator ?separator = null;
Gtk.Revealer ?revealer = null;
Gtk.ToggleButton ?reveal_btn = null;
[GtkChild]
unowned Gtk.Box topbar;
[GtkChild]
unowned Gtk.ToggleButton reveal_btn;
[GtkChild]
unowned Gtk.Revealer revealer;
[GtkChild]
unowned Gtk.Box displays_box;
[GtkChild]
unowned Gtk.Separator separator;
[GtkChild]
unowned Gtk.Box kbd_box;
[GtkChild]
unowned Gtk.Box single_source_box;
int min_brightness = 0;
public Backlight (string suffix) {
base (suffix);
set_orientation (Gtk.Orientation.VERTICAL);
Json.Object ?config = get_config (this);
if (config != null) {
......@@ -108,9 +117,6 @@ namespace XimperShellNotificationCenter.Widgets {
}
private static string prettify_source_name (string name) {
// DDC names are already nice (e.g. "DELL U2723QE")
// Sysfs backlight: "amdgpu_bl1" → "AMDGPU BL1"
// Kbd: "asus::kbd_backlight" → "Asus Keyboard"
string result = name;
// Keyboard backlight cleanup
......@@ -222,70 +228,42 @@ namespace XimperShellNotificationCenter.Widgets {
return outer;
}
[GtkCallback]
private void on_reveal_toggled () {
revealer.set_reveal_child (reveal_btn.active);
if (reveal_btn.active) {
reveal_btn.set_icon_name (
"ximper-shell-notification-center-down-small-symbolic");
add_css_class ("expanded");
} else {
reveal_btn.set_icon_name (
"ximper-shell-notification-center-up-small-symbolic");
remove_css_class ("expanded");
}
}
private void build_ui () {
bool need_collapse = display_sources.length > 1
|| kbd_sources.length > 0;
if (!need_collapse && display_sources.length == 1) {
// Single display — simple row
// Single display — simple row, hide multi-source UI
topbar.set_visible (false);
revealer.set_visible (false);
single_source_box.set_visible (true);
var row = create_slider_row (
ref display_sources[0], null, false);
row.set_margin_start (10);
row.set_margin_end (10);
append (row);
single_source_box.append (row);
return;
}
// Multiple sources — collapsible layout
if (need_collapse) {
single_source_box.set_visible (false);
add_css_class ("has-collapse");
var topbar = new Gtk.Box (
Gtk.Orientation.HORIZONTAL, 6);
topbar.set_margin_start (10);
topbar.set_margin_end (10);
var topbar_icon = new Gtk.Image.from_icon_name (
"display-brightness-symbolic");
var topbar_label = new Gtk.Label (
_("Brightness"));
topbar_label.set_hexpand (true);
topbar_label.set_halign (Gtk.Align.START);
reveal_btn = new Gtk.ToggleButton ();
reveal_btn.set_icon_name (
"ximper-shell-notification-center-up-small-symbolic");
topbar.append (topbar_icon);
topbar.append (topbar_label);
topbar.append (reveal_btn);
append (topbar);
revealer = new Gtk.Revealer ();
revealer.set_transition_type (
Gtk.RevealerTransitionType.SLIDE_DOWN);
revealer.set_transition_duration (200);
var content = new Gtk.Box (
Gtk.Orientation.VERTICAL, 0);
revealer.set_child (content);
append (revealer);
reveal_btn.toggled.connect (() => {
revealer.set_reveal_child (reveal_btn.active);
if (reveal_btn.active) {
reveal_btn.set_icon_name (
"ximper-shell-notification-center-down-small-symbolic");
add_css_class ("expanded");
} else {
reveal_btn.set_icon_name (
"ximper-shell-notification-center-up-small-symbolic");
remove_css_class ("expanded");
}
});
// Display sources
if (display_sources.length > 0) {
displays_box = new Gtk.Box (
Gtk.Orientation.VERTICAL, 0);
displays_box.set_margin_start (10);
displays_box.set_margin_end (10);
var sg = new Gtk.SizeGroup (
Gtk.SizeGroupMode.HORIZONTAL);
for (int i = 0; i < display_sources.length; i++) {
......@@ -293,25 +271,17 @@ namespace XimperShellNotificationCenter.Widgets {
ref display_sources[i], sg, true);
displays_box.append (row);
}
content.append (displays_box);
} else {
displays_box.set_visible (false);
}
// Separator
if (display_sources.length > 0
&& kbd_sources.length > 0) {
separator = new Gtk.Separator (
Gtk.Orientation.HORIZONTAL);
separator.set_margin_top (8);
separator.set_margin_bottom (8);
content.append (separator);
}
separator.set_visible (
display_sources.length > 0
&& kbd_sources.length > 0);
// Keyboard sources
if (kbd_sources.length > 0) {
kbd_box = new Gtk.Box (
Gtk.Orientation.VERTICAL, 0);
kbd_box.set_margin_start (10);
kbd_box.set_margin_end (10);
var sg = new Gtk.SizeGroup (
Gtk.SizeGroupMode.HORIZONTAL);
for (int i = 0; i < kbd_sources.length; i++) {
......@@ -319,7 +289,8 @@ namespace XimperShellNotificationCenter.Widgets {
ref kbd_sources[i], sg, true);
kbd_box.append (row);
}
content.append (kbd_box);
} else {
kbd_box.set_visible (false);
}
}
}
......@@ -353,7 +324,7 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
if (val && reveal_btn != null) {
if (val) {
reveal_btn.set_active (false);
}
}
......
namespace XimperShellNotificationCenter.Widgets {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/widgets/inhibitors.ui")]
public class Inhibitors : BaseWidget {
public override string widget_name {
get {
......@@ -6,8 +7,10 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
Gtk.Label title_widget;
Gtk.Button clear_all_button;
[GtkChild]
unowned Gtk.Label title_widget;
[GtkChild]
unowned Gtk.Button clear_all_button;
// Default config values
string title;
......@@ -42,33 +45,19 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
title_widget = new Gtk.Label (title);
title_widget.set_halign (Gtk.Align.START);
title_widget.set_hexpand (true);
title_widget.set_visible (true);
append (title_widget);
if (has_clear_all_button) {
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 ();
} catch (Error e) {
critical ("Error: %s\n", e.message);
}
});
clear_all_button.set_can_focus (false);
clear_all_button.valign = Gtk.Align.CENTER;
clear_all_button.set_visible (true);
append (clear_all_button);
}
title_widget.set_text (title);
clear_all_button.set_visible (has_clear_all_button);
hide ();
}
[GtkCallback]
private void on_clear_inhibitors_clicked () {
try {
ximper_shell_notification_center_daemon.clear_inhibitors ();
} catch (Error e) {
critical ("Error: %s\n", e.message);
}
}
}
}
namespace XimperShellNotificationCenter.Widgets {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/widgets/label.ui")]
public class Label : BaseWidget {
public override string widget_name {
get {
......@@ -6,7 +7,8 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
Gtk.Label label_widget;
[GtkChild]
unowned Gtk.Label label_widget;
// Default config values
string text = "Label Text";
......@@ -29,23 +31,8 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
label_widget = new Gtk.Label (null);
label_widget.set_text (text);
label_widget.set_ellipsize (Pango.EllipsizeMode.END);
label_widget.set_wrap (true);
label_widget.set_lines (max_lines);
// Without this and pack_start fill, the label would expand to
// the monitors full width... GTK bug!...
label_widget.set_max_width_chars (0);
label_widget.set_wrap_mode (Pango.WrapMode.WORD_CHAR);
label_widget.set_justify (Gtk.Justification.LEFT);
label_widget.set_xalign (0.0f);
label_widget.set_yalign (0.0f);
label_widget.set_halign (Gtk.Align.FILL);
label_widget.set_hexpand (true);
append (label_widget);
}
}
}
namespace XimperShellNotificationCenter.Widgets.Mpris {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/mpris_player.ui")]
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/widgets/mpris_player.ui")]
public class MprisPlayer : Underlay {
[GtkChild]
public unowned Gtk.Label title;
......
namespace XimperShellNotificationCenter.Widgets {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/notifications_widget.ui")]
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/widgets/notifications.ui")]
public class Notifications : BaseWidget {
public override string widget_name {
get {
......
namespace XimperShellNotificationCenter.Widgets {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/widgets/title.ui")]
public class Title : BaseWidget {
public override string widget_name {
get {
......@@ -6,8 +7,10 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
Gtk.Label title_widget;
Gtk.Button clear_all_button;
[GtkChild]
unowned Gtk.Label title_widget;
[GtkChild]
unowned Gtk.Button clear_all_button;
// Default config values
string title;
......@@ -33,32 +36,18 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
title_widget = new Gtk.Label (title);
title_widget.set_hexpand (true);
title_widget.set_halign (Gtk.Align.START);
append (title_widget);
title_widget.set_text (title);
clear_all_button.set_visible (has_clear_all_button);
clear_all_button.set_sensitive (!notifications_widget.is_empty ());
if (has_clear_all_button) {
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);
});
clear_all_button.set_sensitive (!notifications_widget.is_empty ());
ximper_shell_notification_center_daemon.subscribe_v2.connect ((count) => {
clear_all_button.set_sensitive (count > 0);
});
}
ximper_shell_notification_center_daemon.subscribe_v2.connect ((count) => {
clear_all_button.set_sensitive (count > 0);
});
clear_all_button.set_can_focus (false);
clear_all_button.valign = Gtk.Align.CENTER;
// Backwards compatible towards older CSS stylesheets
clear_all_button.add_css_class ("control-center-clear-all");
append (clear_all_button);
}
[GtkCallback]
private void on_clear_all_clicked () {
noti_daemon.request_dismiss_all_notifications (ClosedReasons.DISMISSED);
}
}
}
namespace XimperShellNotificationCenter.Widgets {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/widgets/volume.ui")]
public class Volume : BaseWidget {
public override string widget_name {
get {
......@@ -6,24 +7,22 @@ namespace XimperShellNotificationCenter.Widgets {
}
}
Gtk.Box main_volume_slider_container = new Gtk.Box (
Gtk.Orientation.HORIZONTAL, 0);
Gtk.Image icon_widget = new Gtk.Image ();
Gtk.Scale slider = new Gtk.Scale.with_range (
Gtk.Orientation.HORIZONTAL, 0, 100, 1);
[GtkChild]
unowned Gtk.Image icon_widget;
[GtkChild]
unowned Gtk.Scale slider;
[GtkChild]
unowned Gtk.ToggleButton reveal_button;
[GtkChild]
unowned Gtk.Revealer revealer;
[GtkChild]
unowned Gtk.ListBox levels_listbox;
[GtkChild]
unowned Gtk.Separator sink_separator;
[GtkChild]
unowned Gtk.Box sink_list_box;
// Expandable section
Gtk.ToggleButton reveal_button;
Gtk.Revealer revealer;
Gtk.Box revealer_content;
// Per app volume
Gtk.ListBox levels_listbox;
IterListBoxController list_box_controller;
// Sink selector
Gtk.Separator sink_separator;
Gtk.Box sink_list_box;
uint sink_rebuild_timeout = 0;
private PulseDevice ?default_sink = null;
......@@ -32,64 +31,11 @@ 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 (
default_sink,
(float) slider.get_value ());
slider.tooltip_text =
((int) slider.get_value ()).to_string ();
}
update_volume_icon ((int) slider.get_value ());
});
}
public Volume (string suffix) {
base (suffix);
this.orientation = Gtk.Orientation.VERTICAL;
// Main slider
slider.draw_value = false;
slider.set_hexpand (true);
main_volume_slider_container.append (icon_widget);
main_volume_slider_container.append (slider);
// Reveal button
reveal_button = new Gtk.ToggleButton ();
set_button_icon ();
reveal_button.toggled.connect (() => {
set_button_icon ();
revealer.set_reveal_child (reveal_button.active);
if (reveal_button.active) {
add_css_class ("expanded");
} else {
remove_css_class ("expanded");
}
});
main_volume_slider_container.append (reveal_button);
append (main_volume_slider_container);
// Revealer with per-app + sink selector
revealer = new Gtk.Revealer ();
revealer.transition_type =
Gtk.RevealerTransitionType.SLIDE_DOWN;
revealer.transition_duration = 200;
revealer_content = new Gtk.Box (
Gtk.Orientation.VERTICAL, 0);
revealer.set_child (revealer_content);
// Per-app volume list
levels_listbox = new Gtk.ListBox ();
levels_listbox.add_css_class ("per-app-volume");
levels_listbox.set_activate_on_single_click (true);
levels_listbox.set_selection_mode (
Gtk.SelectionMode.NONE);
list_box_controller = new IterListBoxController (
levels_listbox);
......@@ -106,29 +52,6 @@ namespace XimperShellNotificationCenter.Widgets {
this.client.remove_active_sink.connect (
active_sink_removed);
revealer_content.append (levels_listbox);
// Separator between per-app and sinks
sink_separator = new Gtk.Separator (
Gtk.Orientation.HORIZONTAL);
sink_separator.set_margin_top (8);
sink_separator.set_margin_bottom (8);
sink_separator.set_visible (false);
revealer_content.append (sink_separator);
// Sink selector
sink_list_box = new Gtk.Box (
Gtk.Orientation.VERTICAL, 0);
sink_list_box.add_css_class ("sink-selector");
sink_list_box.set_margin_start (4);
sink_list_box.set_margin_end (4);
sink_list_box.set_margin_top (4);
sink_list_box.set_margin_bottom (4);
sink_list_box.set_visible (false);
revealer_content.append (sink_list_box);
append (revealer);
// Device signals
this.client.new_device.connect (on_device_changed);
this.client.change_device.connect (
......@@ -139,6 +62,29 @@ namespace XimperShellNotificationCenter.Widgets {
update_reveal_visibility ();
}
[GtkCallback]
private void on_slider_changed () {
if (default_sink != null) {
this.client.set_device_volume (
default_sink,
(float) slider.get_value ());
slider.tooltip_text =
((int) slider.get_value ()).to_string ();
}
update_volume_icon ((int) slider.get_value ());
}
[GtkCallback]
private void on_reveal_toggled () {
set_button_icon ();
revealer.set_reveal_child (reveal_button.active);
if (reveal_button.active) {
add_css_class ("expanded");
} else {
remove_css_class ("expanded");
}
}
private void update_volume_icon (int volume) {
string icon_name;
if (volume <= 0) {
......
namespace XimperShellNotificationCenter {
[GtkTemplate (ui = "/ru/ximperlinux/shell/NotificationCenter/ui/notification_close_button.ui")]
public class NotificationCloseButton : Adw.Bin {
Gtk.Revealer revealer;
Gtk.Button button;
construct {
valign = Gtk.Align.START;
// TODO: Configurable
halign = Gtk.Align.END;
revealer = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.CROSSFADE,
reveal_child = false,
};
revealer.notify["child-revealed"].connect (() => {
set_visible (revealer.reveal_child);
});
set_child (revealer);
[GtkChild]
unowned Gtk.Revealer revealer;
public signal void clicked ();
button = new Gtk.Button.from_icon_name ("ximper-shell-notification-center-close-symbolic") {
has_frame = false,
halign = Gtk.Align.CENTER,
valign = Gtk.Align.CENTER,
};
button.add_css_class ("close-button");
button.add_css_class ("circular");
button.clicked.connect (click_cb);
revealer.set_child (button);
[GtkCallback]
private void on_child_revealed () {
set_visible (revealer.reveal_child);
}
private void click_cb () {
[GtkCallback]
private void on_clicked () {
clicked ();
}
public signal void clicked ();
public void set_reveal (bool state) {
if (state == revealer.reveal_child) {
set_visible (state);
......
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