Skip to content

Commit

Permalink
Add settings for showing URL and max results (#13)
Browse files Browse the repository at this point in the history
* Add option to show url.

* Add number of results setting.

* Tidy up: removed messy log.

* Remove potato.

* Use self.preferences instead.

* Fix reference.

Co-authored-by: dom <>
  • Loading branch information
1dom committed Jun 13, 2022
1 parent 68ac781 commit 92f81be
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
32 changes: 21 additions & 11 deletions brotab_ulauncher/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
from brotab_ulauncher.client import BrotabClient
from brotab_ulauncher.listeners import KeywordQueryEventListener, ItemEnterEventListener

DISPLAY_MAX_RESULTS = 20


class BrotabExtension(Extension):
""" Main Extension Class """
Expand Down Expand Up @@ -64,17 +62,29 @@ def search_tabs(self, event):
items = []
tabs = self.brotab_client.search_tabs(event.get_argument())

for tab in tabs[:DISPLAY_MAX_RESULTS]:
max_results = int(self.preferences["max_results"])

for tab in tabs[:max_results]:
data = {"tab": tab["prefix"], "mode": self.mode}

items.append(
ExtensionSmallResultItem(
icon="images/%s" % tab["icon"],
name=tab["name"],
description=tab["url"],
on_enter=ExtensionCustomAction(data),
on_alt_enter=CopyToClipboardAction(tab["url"]),
))
if self.preferences["show_url"] == "Yes":
items.append(
ExtensionResultItem(
icon="images/%s" % tab["icon"],
name=tab["name"],
description=tab["url"],
on_enter=ExtensionCustomAction(data),
on_alt_enter=CopyToClipboardAction(tab["url"]),
))
else:
items.append(
ExtensionSmallResultItem(
icon="images/%s" % tab["icon"],
name=tab["name"],
description=tab["url"],
on_enter=ExtensionCustomAction(data),
on_alt_enter=CopyToClipboardAction(tab["url"]),
))

if not items:
return self.show_no_results_message()
Expand Down
15 changes: 15 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@
"name": "Closetab",
"description": "Close an active tab WARNING: Only is ready to accept cltab, cl or clt keywords",
"default_value": "cltab"
},
{
"id": "show_url",
"type": "select",
"name": "Show URL",
"description": "Show URL in search results",
"default_value": "No",
"options":["Yes","No"]
},
{
"id": "max_results",
"type": "input",
"name": "Max Results",
"description": "Maximum number of search results to show.",
"default_value": 20
}
]
}

0 comments on commit 92f81be

Please sign in to comment.