refactor(agsV2): apply feedback from the man himself
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
653961ada1
commit
ab6b00c259
4 changed files with 35 additions and 48 deletions
|
@ -1,6 +1,4 @@
|
|||
import { App, Gdk, Widget } from 'astal/gtk3';
|
||||
|
||||
import AstalApps from 'gi://AstalApps';
|
||||
import { Gdk } from 'astal/gtk3';
|
||||
|
||||
import AstalHyprland from 'gi://AstalHyprland';
|
||||
const Hyprland = AstalHyprland.get_default();
|
||||
|
@ -111,16 +109,3 @@ export const centerCursor = async(): Promise<void> => {
|
|||
|
||||
await hyprMessage(`dispatch movecursor ${x} ${y}`);
|
||||
};
|
||||
|
||||
export const get_app_icon = (app: AstalApps.Application): string => {
|
||||
if (app.get_icon_name() && Widget.Icon.lookup_icon(app.get_icon_name())) {
|
||||
return app.get_icon_name();
|
||||
}
|
||||
else {
|
||||
const iconString = app.get_key('Icon');
|
||||
|
||||
App.add_icons(iconString);
|
||||
|
||||
return iconString;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Gtk, Widget } from 'astal/gtk3';
|
||||
import { register } from 'astal/gobject';
|
||||
|
||||
import { get_app_icon } from '../../lib';
|
||||
|
||||
/* Types */
|
||||
import AstalApps from 'gi://AstalApps';
|
||||
type AppItemProps = Widget.BoxProps & {
|
||||
|
@ -29,7 +27,7 @@ export class AppItem extends Widget.Box {
|
|||
|
||||
const icon = (
|
||||
<icon
|
||||
icon={get_app_icon(this.app)}
|
||||
icon={this.app.iconName}
|
||||
css="font-size: 42px; margin-right: 25px;"
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -162,7 +162,26 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
|||
setup_notif = () => { /**/ },
|
||||
...rest
|
||||
}: NotifGestureWrapperProps) {
|
||||
super();
|
||||
super({
|
||||
on_button_press_event: () => {
|
||||
this.setCursor('grabbing');
|
||||
},
|
||||
|
||||
// OnRelease
|
||||
on_button_release_event: () => {
|
||||
this.setCursor('grab');
|
||||
},
|
||||
|
||||
// OnHover
|
||||
on_enter_notify_event: () => {
|
||||
this.setCursor('grab');
|
||||
},
|
||||
|
||||
// OnHoverLost
|
||||
on_leave_notify_event: () => {
|
||||
this.setCursor('grab');
|
||||
},
|
||||
});
|
||||
|
||||
this.id = id;
|
||||
this.slide_in_from = slide_in_from;
|
||||
|
@ -171,29 +190,10 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
|||
this.popup_timer = popup_timer;
|
||||
this.is_popup = this.popup_timer !== 0;
|
||||
|
||||
// OnClick
|
||||
this.connect('button-press-event', () => {
|
||||
this.setCursor('grabbing');
|
||||
});
|
||||
|
||||
// OnRelease
|
||||
this.connect('button-release-event', () => {
|
||||
this.setCursor('grab');
|
||||
});
|
||||
|
||||
// OnHover
|
||||
this.connect('enter-notify-event', () => {
|
||||
this.setCursor('grab');
|
||||
});
|
||||
|
||||
// OnHoverLost
|
||||
this.connect('leave-notify-event', () => {
|
||||
this.setCursor('grab');
|
||||
});
|
||||
|
||||
// Handle timeout before sliding away if it is a popup
|
||||
if (this.popup_timer !== 0) {
|
||||
this.timer_object = interval(1000, async() => {
|
||||
try {
|
||||
if (!(await this.get_hovered())) {
|
||||
if (this.popup_timer === 0) {
|
||||
this.slideAway('Left');
|
||||
|
@ -202,6 +202,10 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
|||
--this.popup_timer;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (_) {
|
||||
this.timer_object?.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const Hyprland = AstalHyprland.get_default();
|
|||
import PopupWindow from '../misc/popup-window';
|
||||
import Separator from '../misc/separator';
|
||||
|
||||
import { get_app_icon, hyprMessage } from '../../lib';
|
||||
import { hyprMessage } from '../../lib';
|
||||
|
||||
|
||||
const ICON_SEP = 6;
|
||||
|
@ -46,7 +46,7 @@ export default () => {
|
|||
}}
|
||||
>
|
||||
<box halign={Gtk.Align.CENTER}>
|
||||
<icon icon={get_app_icon(Applications.fuzzy_query(client.class)[0])} />
|
||||
<icon icon={Applications.fuzzy_query(client.class)[0].iconName} />
|
||||
|
||||
<Separator size={ICON_SEP} />
|
||||
|
||||
|
|
Loading…
Reference in a new issue