From 30438dca07919c5413a44091d288e8a6cf9928e1 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 12 Sep 2023 09:37:48 -0400 Subject: [PATCH] feat(ags): make closer work and change button class --- config/ags/js/bar/clock.js | 25 +++++++++---------------- config/ags/js/bar/notif-button.js | 24 +++++++++--------------- config/ags/js/misc/closer.js | 13 +++++++++---- config/ags/js/notifications/base.js | 1 + 4 files changed, 28 insertions(+), 35 deletions(-) diff --git a/config/ags/js/bar/clock.js b/config/ags/js/bar/clock.js index a14d061..1de4eb8 100644 --- a/config/ags/js/bar/clock.js +++ b/config/ags/js/bar/clock.js @@ -1,6 +1,5 @@ const { Box, Label } = ags.Widget; -const { execAsync } = ags.Utils; -const { openWindow, closeWindow } = ags.App; +const { toggleWindow } = ags.App; const { DateTime } = imports.gi.GLib; import { EventBox } from '../misc/cursorbox.js'; @@ -19,22 +18,16 @@ const ClockModule = ({ ], }); -var calendarState = false; - export const Clock = EventBox({ className: 'toggle-off', - onPrimaryClickRelease: () => { - if (calendarState) { - Clock.toggleClassName('toggle-on', false); - closeWindow('calendar'); - calendarState = false; - } - else { - Clock.toggleClassName('toggle-on', true); - openWindow('calendar'); - calendarState = true; - } - }, + onPrimaryClickRelease: () => toggleWindow('calendar'), + connections: [ + [ags.App, (box, windowName, visible) => { + if (windowName == 'calendar') { + Clock.toggleClassName('toggle-on', visible); + } + }], + ], child: Box({ child: ClockModule({}), }), diff --git a/config/ags/js/bar/notif-button.js b/config/ags/js/bar/notif-button.js index 25ab758..99aca96 100644 --- a/config/ags/js/bar/notif-button.js +++ b/config/ags/js/bar/notif-button.js @@ -1,26 +1,20 @@ const { Box, Label, Icon } = ags.Widget; -const { openWindow, closeWindow } = ags.App; +const { toggleWindow } = ags.App; const { Notifications } = ags.Service; import { Separator } from '../misc/separator.js'; import { EventBox } from '../misc/cursorbox.js'; -var notifButtonState = false; - export const NotifButton = EventBox({ className: 'toggle-off', - onPrimaryClickRelease: () => { - if (notifButtonState) { - NotifButton.toggleClassName('toggle-on', false); - closeWindow('notification-center'); - notifButtonState = false; - } - else { - NotifButton.toggleClassName('toggle-on', true); - openWindow('notification-center'); - notifButtonState = true; - } - }, + onPrimaryClickRelease: () => toggleWindow('notification-center'), + connections: [ + [ags.App, (box, windowName, visible) => { + if (windowName == 'notification-center') { + NotifButton.toggleClassName('toggle-on', visible); + } + }], + ], child: Box({ className: 'notif-panel', vertical: false, diff --git a/config/ags/js/misc/closer.js b/config/ags/js/misc/closer.js index a970805..12c232e 100644 --- a/config/ags/js/misc/closer.js +++ b/config/ags/js/misc/closer.js @@ -1,13 +1,18 @@ -export const Closer = ags.Widget.Window({ +const { Window, EventBox } = ags.Widget; +const { windows, closeWindow } = ags.App; + +export const Closer = Window({ name: 'closer', popup: true, layer: 'top', anchor: 'top bottom left right', - child: ags.Widget.EventBox({ + child: EventBox({ onPrimaryClickRelease: () => { - ags.App.closeWindow('powermenu'); - ags.App.closeWindow('closer'); + windows.forEach(w => { + if (w.name != 'bar') + closeWindow(w.name) + }); }, }), }); diff --git a/config/ags/js/notifications/base.js b/config/ags/js/notifications/base.js index 5abba85..e40f8e9 100644 --- a/config/ags/js/notifications/base.js +++ b/config/ags/js/notifications/base.js @@ -6,6 +6,7 @@ const { Box, Icon, Label, Button } = ags.Widget; import { Draggable } from '../misc/drag.js'; import { EventBox } from '../misc/cursorbox.js' +// TODO: launch app when click on icon const NotificationIcon = ({ appEntry, appIcon, image }) => { if (image) { return Box({