[Launcher] Prepare UI
This commit is contained in:
parent
666a047814
commit
791f10aad4
@ -7,15 +7,9 @@ function hide() {
|
||||
|
||||
export default function Launcher(monitor: Gdk.Monitor) {
|
||||
const { CENTER } = Gtk.Align
|
||||
const apps = new Apps.Apps()
|
||||
const width = Variable(1000)
|
||||
|
||||
const text = Variable("")
|
||||
const list = text(text => apps.fuzzy_query(text).slice(0, MAX_ITEMS))
|
||||
const onEnter = () => {
|
||||
apps.fuzzy_query(text.get())?.[0].launch()
|
||||
hide()
|
||||
}
|
||||
|
||||
return <window
|
||||
name="launcher"
|
||||
@ -25,40 +19,14 @@ export default function Launcher(monitor: Gdk.Monitor) {
|
||||
application={App}
|
||||
onShow={(self) => {
|
||||
text.set("")
|
||||
width.set(self.get_current_monitor().workarea.width)
|
||||
width.set(self.get_current_monitor().get_width_mm())
|
||||
}}
|
||||
onKeyPressEvent={function (self, event: Gdk.KeyEvent) {
|
||||
if (event.get_keyval() === Gdk.KEY_Escape)
|
||||
self.hide()
|
||||
onKeyPressed={(self, keyval, keycode) => {
|
||||
print( 'key pressed: ' + keyval + ' which has code ' + keycode );
|
||||
}}>
|
||||
<box>
|
||||
<eventbox widthRequest={width(w => w / 2)} expand onClick={hide} />
|
||||
<box hexpand={false} vertical>
|
||||
<eventbox heightRequest={100} onClick={hide} />
|
||||
<box widthRequest={500} className="Applauncher" vertical>
|
||||
<entry
|
||||
placeholderText="Search"
|
||||
text={text()}
|
||||
onChanged={self => text.set(self.text)}
|
||||
onActivate={onEnter}
|
||||
/>
|
||||
<box spacing={6} vertical>
|
||||
{list.as(list => list.map(app => (
|
||||
<AppButton app={app} />
|
||||
)))}
|
||||
</box>
|
||||
<box
|
||||
halign={CENTER}
|
||||
className="not-found"
|
||||
vertical
|
||||
visible={list.as(l => l.length === 0)}>
|
||||
<icon icon="system-search-symbolic" />
|
||||
<label label="No match found" />
|
||||
</box>
|
||||
</box>
|
||||
<eventbox expand onClick={hide} />
|
||||
</box>
|
||||
<eventbox widthRequest={width(w => w / 2)} expand onClick={hide} />
|
||||
|
||||
</box>
|
||||
|
||||
</window>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user