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 @@
<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>
</gresource>
</gresources>
......@@ -23,72 +23,6 @@ template $SwayNotificationCenterControlCenter: ApplicationWindow {
styles [
"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 @@
"notifications"
],
"widget-config": {
"notifications": {
"vexpand": true
},
"inhibitors": {
"text": "Inhibitors",
"button-text": "Clear All",
......
......@@ -27,12 +27,12 @@
},
"layer-shell": {
"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
},
"layer-shell-cover-screen": {
"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
},
"cssPriority": {
......@@ -332,6 +332,7 @@
},
"widgets": {
"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.",
"default": ["inhibitors", "title", "dnd", "notifications"],
"items": {
......@@ -346,6 +347,10 @@
"additionalProperties": false,
"$comment": "New widgets go here in \"patternProperties\" ↓",
"patternProperties": {
"notifications": {
"$comment": "References the widget structure from \"widgets\" below",
"$ref": "#/widgets/notifications"
},
"^title(#[a-zA-Z0-9_-]{1,}){0,1}?$": {
"$comment": "References the widget structure from \"widgets\" below",
"$ref": "#/widgets/title"
......@@ -383,6 +388,18 @@
},
"widgets": {
"$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": {
"type": "object",
"description": "Control Center Title Widget",
......@@ -395,7 +412,7 @@
},
"clear-all-button": {
"type": "boolean",
"description": "Wether to display a \"Clear All\" button",
"description": "Whether to display a \"Clear All\" button",
"default": true
},
"button-text": {
......@@ -496,7 +513,7 @@
},
"active": {
"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
}
}
......@@ -705,7 +722,7 @@
},
"clear-all-button": {
"type": "boolean",
"description": "Wether to display a \"Clear All\" button",
"description": "Whether to display a \"Clear All\" button",
"default": true
},
"button-text": {
......
namespace SwayNotificationCenter.Widgets {
public static BaseWidget ? get_widget_from_key (owned string key,
SwayncDaemon swaync_daemon,
NotiDaemon noti_daemon) {
NotiDaemon noti_daemon,
out bool is_notifications) {
is_notifications = false;
string[] key_seperated = key.split ("#");
string suffix = "";
if (key_seperated.length > 0) key = key_seperated[0];
if (key_seperated.length > 1) suffix = key_seperated[1];
BaseWidget widget;
switch (key) {
case "notifications":
is_notifications = true;
message ("Loading widget: widget-notifications");
return null;
case "title":
widget = new Title (suffix, swaync_daemon, noti_daemon);
break;
......
......@@ -27,6 +27,8 @@ widget_sources = [
'controlCenter/widgets/baseWidget.vala',
'controlCenter/widgets/factory.vala',
'controlCenter/widgets/shared/toggleButton.vala',
# Widget: Notifications
'controlCenter/widgets/notifications/notifications.vala',
# Widget: Title
'controlCenter/widgets/title/title.vala',
# 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