refactor(ags): make a better popuWindow widget
This commit is contained in:
parent
cbcea307b4
commit
72df640608
8 changed files with 95 additions and 117 deletions
|
@ -1,8 +1,9 @@
|
||||||
import { App, Applications, Widget } from '../../imports.js';
|
import { App, Applications, Widget } from '../../imports.js';
|
||||||
const { Label, Box, Icon, Button, Scrollable, Entry, Window, EventBox } = Widget;
|
const { Label, Box, Icon, Button, Scrollable, Entry, EventBox } = Widget;
|
||||||
|
const { getWindow } = App
|
||||||
|
|
||||||
import { Separator } from '../misc/separator.js';
|
import { Separator } from '../misc/separator.js';
|
||||||
import { PopUp } from '../misc/popup.js';
|
import { PopupWindow } from '../misc/popup.js';
|
||||||
|
|
||||||
const icons = {
|
const icons = {
|
||||||
apps: {
|
apps: {
|
||||||
|
@ -114,21 +115,15 @@ const Applauncher = ({ windowName = 'applauncher' } = {}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: make it so I don't have to click to trigger onHoverLost
|
// FIXME: make it so I don't have to click to trigger onHoverLost
|
||||||
export default Window({
|
export default PopupWindow({
|
||||||
name: 'applauncher',
|
name: 'applauncher',
|
||||||
popup: true,
|
|
||||||
focusable: true,
|
|
||||||
layer: 'overlay',
|
|
||||||
child: EventBox({
|
child: EventBox({
|
||||||
onHover: box => {
|
onHover: () => {
|
||||||
box.get_parent().focusable = true
|
getWindow('applauncher').focusable = true;
|
||||||
},
|
},
|
||||||
onHoverLost: box => {
|
onHoverLost: () => {
|
||||||
box.get_parent().focusable = false
|
getWindow('applauncher').focusable = false;
|
||||||
},
|
},
|
||||||
child: PopUp({
|
|
||||||
name: 'applauncher',
|
|
||||||
child: Applauncher(),
|
child: Applauncher(),
|
||||||
}),
|
}),
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,6 @@ Revealer({
|
||||||
onPrimaryClickRelease: () => execAsync(`hyprctl dispatch workspace ${i}`).catch(print),
|
onPrimaryClickRelease: () => execAsync(`hyprctl dispatch workspace ${i}`).catch(print),
|
||||||
child: Box({
|
child: Box({
|
||||||
className: 'button',
|
className: 'button',
|
||||||
child: Label(`${i}`),
|
|
||||||
connections: [
|
connections: [
|
||||||
[Hyprland, btn => {
|
[Hyprland, btn => {
|
||||||
const occupied = Hyprland.getWorkspace(i)?.windows > 0;
|
const occupied = Hyprland.getWorkspace(i)?.windows > 0;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Widget } from '../imports.js';
|
import { Widget } from '../imports.js';
|
||||||
const { Box, Label, Window } = Widget;
|
const { Box, Label } = Widget;
|
||||||
|
|
||||||
import Gtk from 'gi://Gtk';
|
import Gtk from 'gi://Gtk';
|
||||||
import GLib from 'gi://GLib';
|
import GLib from 'gi://GLib';
|
||||||
const { DateTime } = GLib;
|
const { DateTime } = GLib;
|
||||||
|
|
||||||
import { PopUp } from './misc/popup.js';
|
import { PopupWindow } from './misc/popup.js';
|
||||||
|
|
||||||
|
|
||||||
const Divider = () => Box({
|
const Divider = () => Box({
|
||||||
|
@ -72,14 +72,9 @@ const CalendarWidget = () => Box({
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Calendar = Window({
|
export const Calendar = PopupWindow({
|
||||||
name: 'calendar',
|
|
||||||
layer: 'overlay',
|
|
||||||
popup: true,
|
|
||||||
anchor: [ 'top', 'right' ],
|
anchor: [ 'top', 'right' ],
|
||||||
margin: [ 8, 182, 0, 0],
|
margin: [ 8, 182, 0, 0],
|
||||||
|
|
||||||
child: PopUp({
|
|
||||||
name: 'calendar',
|
name: 'calendar',
|
||||||
child: Box({
|
child: Box({
|
||||||
className: 'date',
|
className: 'date',
|
||||||
|
@ -89,5 +84,4 @@ export const Calendar = Window({
|
||||||
CalendarWidget(),
|
CalendarWidget(),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
import { App, Widget } from '../../imports.js';
|
import { App, Widget } from '../../imports.js';
|
||||||
const { Revealer, Box } = Widget;
|
const { Revealer, Box, Window } = Widget;
|
||||||
const { openWindow } = App;
|
const { openWindow } = App;
|
||||||
|
|
||||||
|
|
||||||
export const PopUp = ({name, child, transition = 'slide_down', ...params}) => Box({
|
export const PopupWindow = ({
|
||||||
|
name,
|
||||||
|
child,
|
||||||
|
transition = 'slide_down',
|
||||||
|
...params
|
||||||
|
}) => Window({
|
||||||
|
name,
|
||||||
|
popup: true,
|
||||||
|
visible: false,
|
||||||
|
layer: 'overlay',
|
||||||
|
...params,
|
||||||
|
|
||||||
|
child: Box({
|
||||||
style: 'min-height:1px; min-width:1px',
|
style: 'min-height:1px; min-width:1px',
|
||||||
child: Revealer({
|
child: Revealer({
|
||||||
...params,
|
|
||||||
transition,
|
transition,
|
||||||
transitionDuration: 500,
|
transitionDuration: 500,
|
||||||
connections: [[App, (revealer, currentName, visible) => {
|
connections: [[App, (revealer, currentName, visible) => {
|
||||||
|
@ -19,4 +30,5 @@ export const PopUp = ({name, child, transition = 'slide_down', ...params}) => Bo
|
||||||
}]],
|
}]],
|
||||||
child: child,
|
child: child,
|
||||||
}),
|
}),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Notifications, App, Utils, Widget } from '../../imports.js';
|
import { Notifications, App, Utils, Widget } from '../../imports.js';
|
||||||
const { Button, Label, Box, Icon, Scrollable, Window, Revealer } = Widget;
|
const { Button, Label, Box, Icon, Scrollable, Revealer } = Widget;
|
||||||
const { timeout } = Utils;
|
const { timeout } = Utils;
|
||||||
const { getWindow } = App;
|
const { getWindow } = App;
|
||||||
|
|
||||||
import Notification from './base.js';
|
import Notification from './base.js';
|
||||||
import { EventBox } from '../misc/cursorbox.js';
|
import { EventBox } from '../misc/cursorbox.js';
|
||||||
import { PopUp } from '../misc/popup.js';
|
import { PopupWindow } from '../misc/popup.js';
|
||||||
|
|
||||||
|
|
||||||
const ClearButton = () => EventBox({
|
const ClearButton = () => EventBox({
|
||||||
|
@ -135,15 +135,9 @@ const NotificationCenterWidget = Box({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const NotificationCenter = Window({
|
export const NotificationCenter = PopupWindow({
|
||||||
name: 'notification-center',
|
name: 'notification-center',
|
||||||
layer: 'overlay',
|
|
||||||
anchor: [ 'top', 'right' ],
|
anchor: [ 'top', 'right' ],
|
||||||
popup: true,
|
|
||||||
margin: [ 8, 60, 0, 0 ],
|
margin: [ 8, 60, 0, 0 ],
|
||||||
|
|
||||||
child: PopUp({
|
|
||||||
name: 'notification-center',
|
|
||||||
child: NotificationCenterWidget,
|
child: NotificationCenterWidget,
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
import { Hyprland, Widget } from '../../imports.js';
|
import { Hyprland, Widget } from '../../imports.js';
|
||||||
const { Window, Box } = Widget;
|
const { Box } = Widget;
|
||||||
|
|
||||||
import { PopUp } from '../misc/popup.js';
|
import { PopupWindow } from '../misc/popup.js';
|
||||||
import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js';
|
import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js';
|
||||||
import { updateClients } from './clients.js';
|
import { updateClients } from './clients.js';
|
||||||
|
|
||||||
|
|
||||||
export default Window({
|
export default PopupWindow({
|
||||||
name: 'overview',
|
|
||||||
layer: 'overlay',
|
|
||||||
popup: true,
|
|
||||||
|
|
||||||
child: PopUp({
|
|
||||||
name: 'overview',
|
name: 'overview',
|
||||||
transition: 'crossfade',
|
transition: 'crossfade',
|
||||||
|
|
||||||
|
@ -48,5 +43,4 @@ export default Window({
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Widget } from '../imports.js';
|
import { Widget } from '../imports.js';
|
||||||
const { Window, CenterBox, Label } = Widget;
|
const { CenterBox, Label } = Widget;
|
||||||
|
|
||||||
import { PopUp } from './misc/popup.js';
|
import { PopupWindow } from './misc/popup.js';
|
||||||
import { Button } from './misc/cursorbox.js'
|
import { Button } from './misc/cursorbox.js'
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,13 +37,8 @@ const PowermenuWidget = CenterBox({
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Powermenu = Window({
|
export const Powermenu = PopupWindow({
|
||||||
name: 'powermenu',
|
|
||||||
popup: true,
|
|
||||||
layer: 'overlay',
|
|
||||||
child: PopUp({
|
|
||||||
name: 'powermenu',
|
name: 'powermenu',
|
||||||
transition: 'crossfade',
|
transition: 'crossfade',
|
||||||
child: PowermenuWidget,
|
child: PowermenuWidget,
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Mpris, Widget } from '../../imports.js';
|
import { Mpris, Widget } from '../../imports.js';
|
||||||
const { Window, Box, Label, Revealer, Icon } = Widget;
|
const { Box, Label, Revealer, Icon } = Widget;
|
||||||
|
|
||||||
import Gtk from 'gi://Gtk';
|
import Gtk from 'gi://Gtk';
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import { ButtonGrid } from './button-grid.js';
|
||||||
import { SliderBox } from './slider-box.js';
|
import { SliderBox } from './slider-box.js';
|
||||||
import Player from '../media-player/player.js';
|
import Player from '../media-player/player.js';
|
||||||
import { EventBox } from '../misc/cursorbox.js';
|
import { EventBox } from '../misc/cursorbox.js';
|
||||||
import { PopUp } from '../misc/popup.js';
|
import { PopupWindow } from '../misc/popup.js';
|
||||||
|
|
||||||
|
|
||||||
const QuickSettingsWidget = Box({
|
const QuickSettingsWidget = Box({
|
||||||
|
@ -69,14 +69,9 @@ const QuickSettingsWidget = Box({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const QuickSettings = Window({
|
export const QuickSettings = PopupWindow({
|
||||||
name: 'quick-settings',
|
name: 'quick-settings',
|
||||||
layer: 'overlay',
|
|
||||||
anchor: [ 'top', 'right' ],
|
anchor: [ 'top', 'right' ],
|
||||||
popup: true,
|
|
||||||
margin: [ 8, 5, 0, ],
|
margin: [ 8, 5, 0, ],
|
||||||
child: PopUp({
|
|
||||||
name: 'quick-settings',
|
|
||||||
child: QuickSettingsWidget,
|
child: QuickSettingsWidget,
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue