💥 fix(ags/apps-window): strange gap between app widgets, tooltip markup issue
This commit is contained in:
+21
-16
@@ -1,6 +1,6 @@
|
|||||||
import { GObject, Variable } from "astal";
|
import { GObject, Variable } from "astal";
|
||||||
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
|
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
|
||||||
import { cleanExec, getAppIcon, getAstalApps } from "../scripts/apps";
|
import { cleanExec, getAppIcon, getApps, getAstalApps } from "../scripts/apps";
|
||||||
import AstalApps from "gi://AstalApps";
|
import AstalApps from "gi://AstalApps";
|
||||||
|
|
||||||
const { TOP, LEFT, RIGHT, BOTTOM } = Astal.WindowAnchor;
|
const { TOP, LEFT, RIGHT, BOTTOM } = Astal.WindowAnchor;
|
||||||
@@ -12,12 +12,12 @@ export const AppsWindow = (mon: number): (Widget.Window) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let results: Array<AstalApps.Application> = [];
|
let results: Array<AstalApps.Application> = [];
|
||||||
let flowboxConnection: number;
|
const flowboxConnections: Array<number> = [];
|
||||||
|
|
||||||
const flowbox = new Gtk.FlowBox({
|
const flowbox = new Gtk.FlowBox({
|
||||||
rowSpacing: 6,
|
rowSpacing: 6,
|
||||||
columnSpacing: 6,
|
columnSpacing: 6,
|
||||||
homogeneous: false,
|
homogeneous: true,
|
||||||
visible: true,
|
visible: true,
|
||||||
minChildrenPerLine: 1,
|
minChildrenPerLine: 1,
|
||||||
activateOnSingleClick: true
|
activateOnSingleClick: true
|
||||||
@@ -31,8 +31,8 @@ export const AppsWindow = (mon: number): (Widget.Window) => {
|
|||||||
onActivate: () => flowbox.get_selected_children()?.[0]?.get_child()?.activate()
|
onActivate: () => flowbox.get_selected_children()?.[0]?.get_child()?.activate()
|
||||||
} as Widget.EntryProps);
|
} as Widget.EntryProps);
|
||||||
|
|
||||||
async function updateResults(str: string) {
|
async function updateResults(str?: string) {
|
||||||
if(!str) results = getAstalApps().fuzzy_query(str).sort((a, b) =>
|
if(!str) results = getApps().sort((a, b) =>
|
||||||
a.name > b.name ? 1 : -1);
|
a.name > b.name ? 1 : -1);
|
||||||
else results = getAstalApps().fuzzy_query(str);
|
else results = getAstalApps().fuzzy_query(str);
|
||||||
|
|
||||||
@@ -61,16 +61,16 @@ export const AppsWindow = (mon: number): (Widget.Window) => {
|
|||||||
widthRequest: 180,
|
widthRequest: 180,
|
||||||
heightRequest: 140,
|
heightRequest: 140,
|
||||||
expand: false,
|
expand: false,
|
||||||
tooltipMarkup: app.name + (app.description ?
|
tooltipMarkup: `${app.name}${app.description ?
|
||||||
`\n<span foreground="#7f7f7f">${app.description}</span>`
|
`\n<span foreground="#7f7f7f">${app.description}</span>`
|
||||||
: ""),
|
: ""}`.replace(/\&/g, "&"),
|
||||||
child: new Widget.Box({
|
child: new Widget.Box({
|
||||||
orientation: Gtk.Orientation.VERTICAL,
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
children: [
|
children: [
|
||||||
new Widget.Icon({
|
new Widget.Icon({
|
||||||
className: "icon",
|
className: "icon",
|
||||||
expand: true,
|
expand: true,
|
||||||
icon: getAppIcon(app) ?? "application-x-executable"
|
icon: getAppIcon(app) || "application-x-executable"
|
||||||
} as Widget.IconProps),
|
} as Widget.IconProps),
|
||||||
new Widget.Label({
|
new Widget.Label({
|
||||||
className: "name",
|
className: "name",
|
||||||
@@ -115,9 +115,8 @@ export const AppsWindow = (mon: number): (Widget.Window) => {
|
|||||||
onDestroy: () => {
|
onDestroy: () => {
|
||||||
searchString.set("");
|
searchString.set("");
|
||||||
entry.text = "";
|
entry.text = "";
|
||||||
searchSubscription();
|
searchSubscription?.();
|
||||||
GObject.signal_handler_is_connected(flowbox, flowboxConnection) &&
|
flowboxConnections.map(id => flowbox.disconnect(id));
|
||||||
flowbox.disconnect(flowboxConnection);
|
|
||||||
},
|
},
|
||||||
onKeyPressEvent: (_, event: Gdk.Event) => {
|
onKeyPressEvent: (_, event: Gdk.Event) => {
|
||||||
if(event.get_keyval()[1] === Gdk.KEY_Escape) {
|
if(event.get_keyval()[1] === Gdk.KEY_Escape) {
|
||||||
@@ -132,7 +131,7 @@ export const AppsWindow = (mon: number): (Widget.Window) => {
|
|||||||
event.get_keyval()[1] !== Gdk.KEY_Return &&
|
event.get_keyval()[1] !== Gdk.KEY_Return &&
|
||||||
event.get_keyval()[1] !== Gdk.KEY_space &&
|
event.get_keyval()[1] !== Gdk.KEY_space &&
|
||||||
event.get_keyval()[1] !== Gdk.KEY_Escape) {
|
event.get_keyval()[1] !== Gdk.KEY_Escape) {
|
||||||
!entry.is_focus && entry.grab_focus();
|
!entry.isFocus && entry.grab_focus_without_selecting();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: new Widget.EventBox({
|
child: new Widget.EventBox({
|
||||||
@@ -163,13 +162,19 @@ export const AppsWindow = (mon: number): (Widget.Window) => {
|
|||||||
]
|
]
|
||||||
} as Widget.BoxProps)
|
} as Widget.BoxProps)
|
||||||
} as Widget.EventBoxProps),
|
} as Widget.EventBoxProps),
|
||||||
setup: () => updateResults("")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
flowboxConnection = flowbox.connect("child-activated", (_, item) => {
|
const connId = window.connect("focus-in-event", (_) => {
|
||||||
if(!item || !item.get_child()) return;
|
updateResults();
|
||||||
item.get_child()!.activate();
|
window.disconnect(connId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
flowboxConnections.push(
|
||||||
|
flowbox.connect("child-activated", (_, item) => {
|
||||||
|
if(!item || !item.get_child()) return;
|
||||||
|
item.get_child()!.activate();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user