✨ ags(runner): make runner work by keyboard keys, focus entry on type + style improvements
This commit is contained in:
@@ -14,9 +14,8 @@ type ResultWidgetProps = {
|
||||
};
|
||||
|
||||
@register({ GTypeName: "ResultWidget" })
|
||||
class ResultWidget extends Widget.EventBox {
|
||||
private readonly connections: Array<number>;
|
||||
public readonly onClick: ((() => void)|undefined);
|
||||
class ResultWidget extends Widget.Box {
|
||||
public readonly onClick: (() => void);
|
||||
public readonly icon: (string|undefined);
|
||||
public readonly setup: ((() => void)|undefined);
|
||||
public readonly closeOnClick: boolean = true;
|
||||
@@ -26,50 +25,41 @@ class ResultWidget extends Widget.EventBox {
|
||||
super();
|
||||
if(props.icon)
|
||||
this.icon = props.icon;
|
||||
if(props.onClick)
|
||||
this.onClick = props.onClick;
|
||||
if(props.setup)
|
||||
this.setup = props.setup;
|
||||
if(props.closeOnClick !== undefined)
|
||||
this.closeOnClick = props.closeOnClick;
|
||||
|
||||
this.connections = [
|
||||
this.connect("click", () => {
|
||||
this.onClick && this.onClick();
|
||||
this.closeOnClick && closeRunner();
|
||||
}),
|
||||
this.onClick = () => {
|
||||
props.onClick && props.onClick();
|
||||
this.closeOnClick && closeRunner();
|
||||
};
|
||||
|
||||
this.connect("destroy-event", () => this.connections.map((id: number) =>
|
||||
this.disconnect(id)))
|
||||
];
|
||||
this.set_class_name("result");
|
||||
this.set_hexpand(true);
|
||||
|
||||
this.add(new Widget.Icon({
|
||||
visible: Boolean(props.icon),
|
||||
icon: props.icon || "image-missing"
|
||||
} as Widget.IconProps));
|
||||
|
||||
this.add(new Widget.Box({
|
||||
className: "result",
|
||||
hexpand: true,
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
valign: Gtk.Align.CENTER,
|
||||
children: [
|
||||
new Widget.Icon({
|
||||
visible: Boolean(props.icon),
|
||||
icon: props.icon || "image-missing"
|
||||
} as Widget.IconProps),
|
||||
new Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
valign: Gtk.Align.CENTER,
|
||||
children: [
|
||||
new Widget.Label({
|
||||
className: "title",
|
||||
xalign: 0,
|
||||
truncate: true,
|
||||
label: props.title
|
||||
} as Widget.LabelProps),
|
||||
new Widget.Label({
|
||||
className: "description",
|
||||
visible: Boolean(props.description),
|
||||
truncate: true,
|
||||
xalign: 0,
|
||||
label: props.description || ""
|
||||
} as Widget.LabelProps)
|
||||
]
|
||||
} as Widget.BoxProps),
|
||||
new Widget.Label({
|
||||
className: "title",
|
||||
xalign: 0,
|
||||
truncate: true,
|
||||
label: props.title
|
||||
} as Widget.LabelProps),
|
||||
new Widget.Label({
|
||||
className: "description",
|
||||
visible: Boolean(props.description),
|
||||
truncate: true,
|
||||
xalign: 0,
|
||||
label: props.description || ""
|
||||
} as Widget.LabelProps)
|
||||
]
|
||||
} as Widget.BoxProps));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user