Skip to content

Commit

Permalink
feat: Scrollable launcher results
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Jan 5, 2021
1 parent 90585cb commit 66575fa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
24 changes: 19 additions & 5 deletions src/dialog_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class Search {
private list: St.Widget;
private text: Clutter.Text;
private widgets: Array<St.Widget>;
private scroller: St.Widget;

private apply_cb: (index: number) => boolean;
private cancel_cb: () => void;
Expand Down Expand Up @@ -130,8 +131,13 @@ export class Search {
vertical: true,
});

const scroller = new St.ScrollView()
scroller.add_actor(this.list)

this.dialog.contentLayout.add(this.entry);
this.dialog.contentLayout.add(this.list);
this.dialog.contentLayout.add(scroller);

this.scroller = scroller

// Ensure that the width is at least 640 pixels wide.
this.dialog.contentLayout.width = Math.max(Lib.current_monitor().width / 4, 640);
Expand Down Expand Up @@ -167,7 +173,7 @@ export class Search {
}

list_max() {
return 9;
return 18;
}

reset() {
Expand All @@ -182,9 +188,10 @@ export class Search {
}

select() {
this.widgets[this.active_id].add_style_pseudo_class(
"select"
);
const widget = this.widgets[this.active_id]
widget.add_style_pseudo_class("select")

imports.misc.util.ensureActorVisibleInScrollView(this.scroller, widget)
}

select_id(id: number) {
Expand Down Expand Up @@ -232,6 +239,13 @@ export class Search {
this.select();
this.select_cb(0);
}

const vscroll = (this.scroller as any).get_vscroll_bar()
if ((this.scroller as any).vscrollbar_visible) {
vscroll.show()
} else {
vscroll.hide()
}
}

set_text(text: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/mod.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ declare namespace Clutter {
get_parent(): Clutter.Actor | null;
get_stage(): Clutter.Actor | null;
get_transition(param: string): any | null;
grab_key_focus(): void;
is_visible(): boolean;
queue_redraw(): void;
remove_all_children(): void;
Expand Down Expand Up @@ -290,6 +291,5 @@ declare namespace St {
clutter_text: any;

get_clutter_text(): Clutter.Text;
grab_key_focus(): void;
}
}
2 changes: 1 addition & 1 deletion src/plugins/files/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class App {
directory
})

if (this.selections.length === 10) break
if (this.selections.length === 20) break
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/recent/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class App {
this.results = items
.filter(item => item.display_name.toLowerCase().includes(normalized))
.sort((a, b) => a.display_name.localeCompare(b.display_name))
.slice(0, 9)
.slice(0, 20)

let id = 0

Expand Down

0 comments on commit 66575fa

Please sign in to comment.