From 58d26dcf60cfbb12e879447e091e6374f64566cf Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:15:31 +1100 Subject: bar: use menubutton for tray items Inverts the click actions, but eh (primary for menu, secondary for activate) --- src/modules/bar.tsx | 59 +++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx index 55a0102..e7d9138 100644 --- a/src/modules/bar.tsx +++ b/src/modules/bar.tsx @@ -7,9 +7,9 @@ import { bindCurrentTime, osIcon } from "@/utils/system"; import type { AstalWidget } from "@/utils/types"; import { setupCustomTooltip } from "@/utils/widgets"; import type PopupWindow from "@/widgets/popupwindow"; -import { execAsync, register, Variable } from "astal"; +import { execAsync, Variable } from "astal"; import { bind, kebabify } from "astal/binding"; -import { App, Astal, astalify, Gdk, Gtk, type ConstructProps } from "astal/gtk3"; +import { App, Astal, Gtk } from "astal/gtk3"; import { bar as config } from "config"; import AstalBattery from "gi://AstalBattery"; import AstalBluetooth from "gi://AstalBluetooth"; @@ -210,49 +210,18 @@ const Workspaces = () => ( ); -@register() -class TrayItemMenu extends astalify(Gtk.Menu) { - readonly item: AstalTray.TrayItem; - - constructor(props: ConstructProps & { item: AstalTray.TrayItem }) { - const { item, ...sProps } = props; - super(sProps as any); - - this.item = item; - - this.hook(item, "notify::menu-model", () => this.bind_model(item.menuModel, null, true)); - this.hook(item, "notify::action-group", () => this.insert_action_group("dbusmenu", item.actionGroup)); - this.bind_model(item.menuModel, null, true); - this.insert_action_group("dbusmenu", item.actionGroup); - } - - popup_at_widget_bottom(widget: Gtk.Widget) { - this.item.about_to_show(); - this.popup_at_widget(widget, Gdk.Gravity.SOUTH, Gdk.Gravity.NORTH, null); - } -} - -const TrayItem = (item: AstalTray.TrayItem) => { - const menu = () as TrayItemMenu; - return ( - - ); -}; +const TrayItem = (item: AstalTray.TrayItem) => ( + event.get_button()[1] === Astal.MouseButton.SECONDARY && item.activate(0, 0)} + usePopover={false} + direction={config.vertical ? Gtk.ArrowType.RIGHT : Gtk.ArrowType.DOWN} + menuModel={bind(item, "menuModel")} + actionGroup={bind(item, "actionGroup").as(a => ["dbusmenu", a])} + setup={self => setupCustomTooltip(self, bind(item, "tooltipMarkup"))} + > + + +); const Tray = () => (