ags: some migration

i cry
This commit is contained in:
end-4
2023-12-29 18:17:08 +07:00
parent 0f91b010a6
commit 10bc1c4ef8
16 changed files with 551 additions and 569 deletions
+30 -50
View File
@@ -161,18 +161,24 @@ export default ({
children: [
Overlay({
child: NotificationIcon(notifObject),
overlays: [
AnimatedCircProg({
className: `notif-circprog-${notifObject.urgency}`,
valign: Gtk.Align.CENTER,
initFrom: (isPopup ? 100 : 0),
initTo: 0,
initAnimTime: popupTimeout,
})
]
overlays: isPopup ? [AnimatedCircProg({
className: `notif-circprog-${notifObject.urgency}`,
valign: Gtk.Align.CENTER,
initFrom: (isPopup ? 100 : 0),
initTo: 0,
initAnimTime: popupTimeout,
})] : [],
}),
]
});
let notifTime = '';
const messageTime = GLib.DateTime.new_from_unix_local(notifObject.time);
if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year())
notifTime = messageTime.format('%H:%M');
else if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year() - 1)
notifTime = 'Yesterday';
else
notifTime = messageTime.format('%d/%m');
const notifText = Box({
valign: Gtk.Align.CENTER,
vertical: true,
@@ -188,27 +194,14 @@ export default ({
maxWidthChars: 24,
truncate: 'end',
ellipsize: 3,
// wrap: true,
useMarkup: notifObject.summary.startsWith('<'),
label: notifObject.summary,
}),
Label({
valign: Gtk.Align.CENTER,
vpack: 'center',
justification: 'right',
className: 'txt-smaller txt-semibold',
justify: Gtk.Justification.RIGHT,
setup: (label) => {
// Let's ignore how it won't work for Jan1 cuz I'm lazy
const messageTime = GLib.DateTime.new_from_unix_local(notifObject.time);
if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year()) {
label.label = messageTime.format('%H:%M');
}
else if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year() - 1) {
label.label = messageTime.format('Yesterday');
}
else {
label.label = messageTime.format('%d/%m');
}
}
label: notifTime,
}),
]
}),
@@ -243,17 +236,6 @@ export default ({
notifIcon,
notifText,
notifExpandButton,
// what is this? i think it should be at the bottom not on the right
// Box({
// className: 'actions',
// children: actions.map(action => Button({
// className: 'action-button',
// onClicked: () => Notifications.invoke(id, action.id),
// hexpand: true,
// child: Label(action.label),
// })),
// }),
]
})
@@ -284,16 +266,16 @@ export default ({
opacity: 0;`;
const notificationBox = Box({
properties: [
['leftAnim1', leftAnim1],
['rightAnim1', rightAnim1],
['middleClickClose', middleClickClose],
['ready', false],
],
attribute: {
'leftAnim1': leftAnim1,
'rightAnim1': rightAnim1,
'middleClickClose': middleClickClose,
'ready': false,
},
homogeneous: true,
children: [notificationContent],
connections: [
[gesture, self => {
setup: (self) => self
.hook(gesture, self => {
var offset = gesture.get_offset()[1];
if (initialDir == 0 && offset != 0)
initialDir = (offset > 0 ? 1 : -1)
@@ -323,9 +305,8 @@ export default ({
if (widget.window)
widget.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grabbing'));
}, 'drag-update'],
[gesture, self => {
}, 'drag-update')
.hook(gesture, self => {
if (!self._ready) {
wholeThing.revealChild = true;
self._ready = true;
@@ -362,9 +343,8 @@ export default ({
wholeThing._dragging = false;
}
initialDir = 0;
}, 'drag-end'],
],
}, 'drag-end')
,
})
widget.add(notificationBox);
wholeThing.child.children = [widget];
+7 -5
View File
@@ -17,11 +17,13 @@ export default ({
child: Box({
className: `${showClassName} ${hideClassName}`,
connections: [[App, (self, currentName, visible) => {
if (currentName === name) {
self.toggleClassName(hideClassName, !visible);
}
}]],
setup: (self) => self
.hook(App, (self, currentName, visible) => {
if (currentName === name) {
self.toggleClassName(hideClassName, !visible);
}
})
,
child: child,
}),
});
+40 -38
View File
@@ -27,18 +27,18 @@ export const NotificationIndicator = (notifCenterName = 'sideright') => {
transition: 150,
transition: 'slide_left',
revealChild: false,
connections: [
[Notifications, (self, id) => {
setup: (self) => self
.hook(Notifications, (self, id) => {
if (!id || Notifications.dnd) return;
if (!Notifications.getNotification(id)) return;
self.revealChild = true;
}, 'notified'],
[App, (self, currentName, visible) => {
}, 'notified')
.hook(App, (self, currentName, visible) => {
if (visible && currentName === notifCenterName) {
self.revealChild = false;
}
}],
],
})
,
child: Widget.Box({
children: [
MaterialIcon('notifications', 'norm'),
@@ -50,20 +50,20 @@ export const NotificationIndicator = (notifCenterName = 'sideright') => {
['update', (self) => self.label = `${self._unreadCount}`],
['unreadCount', 0],
],
connections: [
[Notifications, (self, id) => {
setup: (self) => self
.hook(Notifications, (self, id) => {
if (!id || Notifications.dnd) return;
if (!Notifications.getNotification(id)) return;
self._increment(self);
self._update(self);
}, 'notified'],
[App, (self, currentName, visible) => {
}, 'notified')
.hook(App, (self, currentName, visible) => {
if (visible && currentName === notifCenterName) {
self._markread(self);
self._update(self);
}
}],
]
})
,
})
]
})
@@ -77,7 +77,11 @@ export const BluetoothIndicator = () => Widget.Stack({
['true', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' })],
['false', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' })],
],
connections: [[Bluetooth, stack => { stack.shown = String(Bluetooth.enabled); }]],
setup: (self) => self
.hook(Bluetooth, stack => {
stack.shown = String(Bluetooth.enabled);
})
,
});
@@ -90,7 +94,7 @@ const NetworkWiredIndicator = () => Widget.Stack({
['connected', Widget.Label({ className: 'txt-norm icon-material', label: 'lan' })],
['connecting', Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' })],
],
connections: [[Network, stack => {
setup: (self) => self.hook(Network, stack => {
if (!Network.wired)
return;
@@ -101,15 +105,15 @@ const NetworkWiredIndicator = () => Widget.Stack({
stack.shown = 'disconnected';
else
stack.shown = 'fallback';
}]],
}),
});
const SimpleNetworkIndicator = () => Widget.Icon({
connections: [[Network, self => {
setup: (self) => self.hook(Network, self => {
const icon = Network[Network.primary || 'wifi']?.iconName;
self.icon = icon || '';
self.visible = icon;
}]],
}),
});
const NetworkWifiIndicator = () => Widget.Stack({
@@ -124,7 +128,7 @@ const NetworkWifiIndicator = () => Widget.Stack({
['3', Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_3_bar' })],
['4', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_4_bar' })],
],
connections: [[Network, (stack) => {
setup: (self) => self.hook(Network, (stack) => {
if (!Network.wifi) {
return;
}
@@ -134,7 +138,7 @@ const NetworkWifiIndicator = () => Widget.Stack({
else if (Network.wifi.internet == 'disconnected' || Network.wifi.internet == 'connecting') {
stack.shown = Network.wifi.internet;
}
}]],
}),
});
export const NetworkIndicator = () => Widget.Stack({
@@ -144,8 +148,8 @@ export const NetworkIndicator = () => Widget.Stack({
['wifi', NetworkWifiIndicator()],
['wired', NetworkWiredIndicator()],
],
connections: [[Network, stack => {
if(!Network.primary) {
setup: (self) => self.hook(Network, stack => {
if (!Network.primary) {
stack.shown = 'wifi';
return;
}
@@ -154,7 +158,7 @@ export const NetworkIndicator = () => Widget.Stack({
stack.shown = primary;
else
stack.shown = 'fallback';
}]],
}),
});
const KeyboardLayout = ({ useFlag } = {}) => {
@@ -192,22 +196,20 @@ const KeyboardLayout = ({ useFlag } = {}) => {
...languageStackArray,
['undef', Widget.Label({ label: '?' })]
],
connections: [
[Hyprland, (stack, kbName, layoutName) => {
if (!kbName) {
return;
}
var lang = languages.find(lang => layoutName.includes(lang.name));
if (lang) {
widgetContent.shown = lang.layout;
}
else { // Attempt to support langs not listed
lang = languageStackArray.find(lang => isLanguageMatch(lang[0], layoutName));
if (!lang) stack.shown = 'undef';
else stack.shown = lang[0];
}
}, 'keyboard-layout']
],
setup: (self) => self.hook(Hyprland, (stack, kbName, layoutName) => {
if (!kbName) {
return;
}
var lang = languages.find(lang => layoutName.includes(lang.name));
if (lang) {
widgetContent.shown = lang.layout;
}
else { // Attempt to support langs not listed
lang = languageStackArray.find(lang => isLanguageMatch(lang[0], layoutName));
if (!lang) stack.shown = 'undef';
else stack.shown = lang[0];
}
}, 'keyboard-layout'),
});
widgetRevealer.child = widgetContent;
return widgetRevealer;