💥 ags(runner): fix ResultWidget.closeOnClick property, do not close runner on media control plugin
This commit is contained in:
@@ -46,9 +46,7 @@ export namespace Runner {
|
||||
showResultsPlaceHolderOnStartup?: boolean;
|
||||
};
|
||||
|
||||
export function close() {
|
||||
runnerInstance?.close();
|
||||
}
|
||||
export function close() { runnerInstance?.close(); }
|
||||
|
||||
const plugins = new Set<Runner.Plugin>([]);
|
||||
|
||||
@@ -98,6 +96,7 @@ export namespace Runner {
|
||||
if(resultWidget instanceof ResultWidget) {
|
||||
entry.isFocus = false;
|
||||
resultWidget.onClick();
|
||||
resultWidget.closeOnClick && Runner.close();
|
||||
}
|
||||
},
|
||||
primary_icon_name: "system-search"
|
||||
@@ -140,13 +139,14 @@ export namespace Runner {
|
||||
resultsList.insert(resultWidget, -1);
|
||||
|
||||
resultsList.connect("row-activated", (_, row: Gtk.ListBoxRow) => {
|
||||
const rWidget = row.get_child()!;
|
||||
const rWidget = row.get_child();
|
||||
if(rWidget instanceof ResultWidget) {
|
||||
if(!onClickTimeout) {
|
||||
rWidget.onClick();
|
||||
if(onClickTimeout) return;
|
||||
|
||||
// Timeout, so it doesn't fire the event a hundred times :skull:
|
||||
onClickTimeout = timeout(500, () => onClickTimeout = undefined);
|
||||
}
|
||||
rWidget.onClick();
|
||||
rWidget.closeOnClick && Runner.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -172,6 +172,7 @@ export namespace Runner {
|
||||
&& keyVal !== Gdk.KEY_Down && keyVal !== Gdk.KEY_Up
|
||||
&& keyVal !== Gdk.KEY_Return) {
|
||||
searchEntry.grab_focus_without_selecting();
|
||||
return;
|
||||
}
|
||||
|
||||
event.get_keyval()[1] === Gdk.KEY_F5 &&
|
||||
|
||||
@@ -11,6 +11,7 @@ export const PluginMedia = {
|
||||
if(!player) return new ResultWidget({
|
||||
icon: "folder-music-symbolic",
|
||||
title: "Couldn't find any players",
|
||||
closeOnClick: false,
|
||||
description: "No media / player found with mpris"
|
||||
} as ResultWidgetProps);
|
||||
return [
|
||||
@@ -18,6 +19,7 @@ export const PluginMedia = {
|
||||
icon: bind(player, "playbackStatus").as((status) => status === AstalMpris.PlaybackStatus.PLAYING ?
|
||||
"media-playback-pause-symbolic"
|
||||
: "media-playback-start-symbolic"),
|
||||
closeOnClick: false,
|
||||
title: Variable.derive([
|
||||
bind(player, "title"),
|
||||
bind(player, "artist"),
|
||||
@@ -29,6 +31,7 @@ export const PluginMedia = {
|
||||
} as ResultWidgetProps),
|
||||
new ResultWidget({
|
||||
icon: "media-skip-backward-symbolic",
|
||||
closeOnClick: false,
|
||||
title: Variable.derive([
|
||||
bind(player, "title"),
|
||||
bind(player, "artist")
|
||||
@@ -39,6 +42,7 @@ export const PluginMedia = {
|
||||
} as ResultWidgetProps),
|
||||
new ResultWidget({
|
||||
icon: "media-skip-forward-symbolic",
|
||||
closeOnClick: false,
|
||||
title: Variable.derive([
|
||||
bind(player, "title"),
|
||||
bind(player, "artist")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Binding, register } from "astal";
|
||||
import { Gtk, Widget } from "astal/gtk3";
|
||||
import { Runner } from "../../runner/Runner";
|
||||
|
||||
export { ResultWidget, ResultWidgetProps };
|
||||
|
||||
@@ -22,21 +21,15 @@ class ResultWidget extends Widget.Box {
|
||||
|
||||
|
||||
constructor(props: ResultWidgetProps) {
|
||||
super();
|
||||
if(props.icon)
|
||||
super({
|
||||
className: "result",
|
||||
hexpand: true
|
||||
});
|
||||
|
||||
this.icon = props.icon;
|
||||
if(props.setup)
|
||||
this.setup = props.setup;
|
||||
if(props.closeOnClick !== undefined)
|
||||
this.closeOnClick = props.closeOnClick;
|
||||
|
||||
this.onClick = () => {
|
||||
props.onClick && props.onClick();
|
||||
this.closeOnClick && Runner.close();
|
||||
};
|
||||
|
||||
this.set_class_name("result");
|
||||
this.set_hexpand(true);
|
||||
this.closeOnClick = props.closeOnClick ?? true;
|
||||
this.onClick = () => props.onClick?.();
|
||||
|
||||
this.add(new Widget.Icon({
|
||||
visible: Boolean(props.icon),
|
||||
|
||||
Reference in New Issue
Block a user