Unverified Commit c4f957a4 authored by Erik Reider's avatar Erik Reider Committed by GitHub

Moved control center notifications into its own widget + vexpand config option (#597)

* Moved control center notifications into its own widget + vexpand config option * Fixed cc max size not being respected
parent 7e34c752
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
<file preprocess="xml-stripblanks">ui/notification.ui</file> <file preprocess="xml-stripblanks">ui/notification.ui</file>
<file preprocess="xml-stripblanks">ui/control_center.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/mpris_player.ui</file>
<file preprocess="xml-stripblanks">ui/notifications_widget.ui</file>
</gresource> </gresource>
</gresources> </gresources>
...@@ -23,72 +23,6 @@ template $SwayNotificationCenterControlCenter: ApplicationWindow { ...@@ -23,72 +23,6 @@ template $SwayNotificationCenterControlCenter: ApplicationWindow {
styles [ styles [
"widgets", "widgets",
] ]
Box notifications_box {
orientation: vertical;
overflow: hidden;
styles [
"widget",
"widget-notifications",
]
Stack stack {
hhomogeneous: true;
vhomogeneous: true;
transition-type: crossfade;
transition-duration: 200;
vexpand: true;
StackPage {
name: "notifications-list";
child: ScrolledWindow scrolled_window {
hscrollbar-policy: never;
has-frame: false;
child: Viewport viewport {
vexpand: true;
child: ListBox list_box {
valign: fill;
styles [
"control-center-list",
]
};
};
};
}
StackPage {
name: "notifications-placeholder";
child: Box {
halign: center;
valign: center;
hexpand: true;
vexpand: true;
orientation: vertical;
spacing: 12;
styles [
"control-center-list-placeholder",
]
Image {
pixel-size: 96;
icon-name: "preferences-system-notifications-symbolic";
use-fallback: true;
}
Label text_empty_label {
label: "No Notifications";
}
};
}
}
}
}; };
}; };
} }
......
using Gtk 4.0;
template $SwayNotificationCenterWidgetsNotifications: $SwayNotificationCenterWidgetsBaseWidget {
orientation: vertical;
overflow: hidden;
Stack stack {
hhomogeneous: true;
vhomogeneous: true;
transition-type: crossfade;
transition-duration: 200;
vexpand: true;
StackPage {
name: "notifications-list";
child: ScrolledWindow scrolled_window {
hscrollbar-policy: never;
has-frame: false;
child: Viewport viewport {
vexpand: true;
child: ListBox list_box {
valign: fill;
styles [
"control-center-list",
]
};
};
};
}
StackPage {
name: "notifications-placeholder";
child: Box {
halign: center;
valign: center;
hexpand: true;
vexpand: true;
orientation: vertical;
spacing: 12;
styles [
"control-center-list-placeholder",
]
Image {
pixel-size: 96;
icon-name: "preferences-system-notifications-symbolic";
use-fallback: true;
}
Label text_empty_label {
label: "No Notifications";
}
};
}
}
}
...@@ -57,6 +57,9 @@ ...@@ -57,6 +57,9 @@
"notifications" "notifications"
], ],
"widget-config": { "widget-config": {
"notifications": {
"vexpand": true
},
"inhibitors": { "inhibitors": {
"text": "Inhibitors", "text": "Inhibitors",
"button-text": "Clear All", "button-text": "Clear All",
......
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
}, },
"layer-shell": { "layer-shell": {
"type": "boolean", "type": "boolean",
"description": "Wether or not the windows should be opened as layer-shell surfaces. Note: Requires swaync restart to apply", "description": "Whether or not the windows should be opened as layer-shell surfaces. Note: Requires swaync restart to apply",
"default": true "default": true
}, },
"layer-shell-cover-screen": { "layer-shell-cover-screen": {
"type": "boolean", "type": "boolean",
"description": "Wether or not the windows should cover the whole screen when layer-shell is used. May exceed the height of the monitor if the value is too large. Fixes animations in compositors like Hyprland.", "description": "Whether or not the windows should cover the whole screen when layer-shell is used. May exceed the height of the monitor if the value is too large. Fixes animations in compositors like Hyprland.",
"default": true "default": true
}, },
"cssPriority": { "cssPriority": {
...@@ -332,6 +332,7 @@ ...@@ -332,6 +332,7 @@
}, },
"widgets": { "widgets": {
"type": "array", "type": "array",
"uniqueItems": true,
"description": "Which order and which widgets to display. If the \"notifications\" widget isn't specified, it will be placed at the bottom.", "description": "Which order and which widgets to display. If the \"notifications\" widget isn't specified, it will be placed at the bottom.",
"default": ["inhibitors", "title", "dnd", "notifications"], "default": ["inhibitors", "title", "dnd", "notifications"],
"items": { "items": {
...@@ -346,6 +347,10 @@ ...@@ -346,6 +347,10 @@
"additionalProperties": false, "additionalProperties": false,
"$comment": "New widgets go here in \"patternProperties\" ↓", "$comment": "New widgets go here in \"patternProperties\" ↓",
"patternProperties": { "patternProperties": {
"notifications": {
"$comment": "References the widget structure from \"widgets\" below",
"$ref": "#/widgets/notifications"
},
"^title(#[a-zA-Z0-9_-]{1,}){0,1}?$": { "^title(#[a-zA-Z0-9_-]{1,}){0,1}?$": {
"$comment": "References the widget structure from \"widgets\" below", "$comment": "References the widget structure from \"widgets\" below",
"$ref": "#/widgets/title" "$ref": "#/widgets/title"
...@@ -383,6 +388,18 @@ ...@@ -383,6 +388,18 @@
}, },
"widgets": { "widgets": {
"$comment": "New widgets go here", "$comment": "New widgets go here",
"notifications": {
"type": "object",
"description": "Control Center Title Widget",
"additionalProperties": false,
"properties": {
"vexpand": {
"type": "boolean",
"description": "Whether or not the notifications widget should vertically expand or not",
"default": true
}
}
},
"title": { "title": {
"type": "object", "type": "object",
"description": "Control Center Title Widget", "description": "Control Center Title Widget",
...@@ -395,7 +412,7 @@ ...@@ -395,7 +412,7 @@
}, },
"clear-all-button": { "clear-all-button": {
"type": "boolean", "type": "boolean",
"description": "Wether to display a \"Clear All\" button", "description": "Whether to display a \"Clear All\" button",
"default": true "default": true
}, },
"button-text": { "button-text": {
...@@ -496,7 +513,7 @@ ...@@ -496,7 +513,7 @@
}, },
"active": { "active": {
"type": "boolean", "type": "boolean",
"description": "Wether the toggle button is active as default or not", "description": "Whether the toggle button is active as default or not",
"default": false "default": false
} }
} }
...@@ -705,7 +722,7 @@ ...@@ -705,7 +722,7 @@
}, },
"clear-all-button": { "clear-all-button": {
"type": "boolean", "type": "boolean",
"description": "Wether to display a \"Clear All\" button", "description": "Whether to display a \"Clear All\" button",
"default": true "default": true
}, },
"button-text": { "button-text": {
......
namespace SwayNotificationCenter.Widgets { namespace SwayNotificationCenter.Widgets {
public static BaseWidget ? get_widget_from_key (owned string key, public static BaseWidget ? get_widget_from_key (owned string key,
SwayncDaemon swaync_daemon, SwayncDaemon swaync_daemon,
NotiDaemon noti_daemon) { NotiDaemon noti_daemon,
out bool is_notifications) {
is_notifications = false;
string[] key_seperated = key.split ("#"); string[] key_seperated = key.split ("#");
string suffix = ""; string suffix = "";
if (key_seperated.length > 0) key = key_seperated[0]; if (key_seperated.length > 0) key = key_seperated[0];
if (key_seperated.length > 1) suffix = key_seperated[1]; if (key_seperated.length > 1) suffix = key_seperated[1];
BaseWidget widget; BaseWidget widget;
switch (key) { switch (key) {
case "notifications":
is_notifications = true;
message ("Loading widget: widget-notifications");
return null;
case "title": case "title":
widget = new Title (suffix, swaync_daemon, noti_daemon); widget = new Title (suffix, swaync_daemon, noti_daemon);
break; break;
......
...@@ -27,6 +27,8 @@ widget_sources = [ ...@@ -27,6 +27,8 @@ widget_sources = [
'controlCenter/widgets/baseWidget.vala', 'controlCenter/widgets/baseWidget.vala',
'controlCenter/widgets/factory.vala', 'controlCenter/widgets/factory.vala',
'controlCenter/widgets/shared/toggleButton.vala', 'controlCenter/widgets/shared/toggleButton.vala',
# Widget: Notifications
'controlCenter/widgets/notifications/notifications.vala',
# Widget: Title # Widget: Title
'controlCenter/widgets/title/title.vala', 'controlCenter/widgets/title/title.vala',
# Widget: Dnd # Widget: Dnd
......
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