fix launcher
This commit is contained in:
1 parent
7107732a32
commit
16c444c41f
2 files changed
+45
-47
No files matched your search
@@ -149,14 +149,13 @@ class Launcher(Window):
|
||||
def arrange_viewport(self, query: str = ""):
|
||||
|
||||
self.get_viewport().children = []
|
||||
dynamic_buttons = []
|
||||
for command, handler_name in self.command_map.items():
|
||||
if query.startswith(command):
|
||||
handler = getattr(self, handler_name, None)
|
||||
if handler:
|
||||
handler(query[len(command) :].strip())
|
||||
return
|
||||
|
||||
self.scrolled_revealer.unreveal()
|
||||
if query.startswith(":"):
|
||||
self.additional_box.set_visible(False)
|
||||
self.update_dynamic_button([self.default_button])
|
||||
@@ -225,25 +224,21 @@ class Launcher(Window):
|
||||
self.network_menu.show_wifi_menu(self.viewport)
|
||||
dynamic_buttons = self.network_menu.get_wifi_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_emojis(self, query: str):
|
||||
self.emoji_manager.show_emojis(self.get_viewport(), query)
|
||||
dynamic_buttons = self.emoji_manager.get_emoji_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_clipboard_history(self, query: str):
|
||||
self.clipboard_manager.show_clipboard_history(self.get_viewport(), query)
|
||||
dynamic_buttons = self.clipboard_manager.get_clipboard_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_powermenu(self, query: str = ""):
|
||||
self.power_menu.show_power_menu(self.get_viewport(), query)
|
||||
dynamic_buttons = self.power_menu.get_power_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_shell_commands(self, query: str):
|
||||
if not query:
|
||||
@@ -254,7 +249,6 @@ class Launcher(Window):
|
||||
self.shell_command_manager.show_shell_commands(self.get_viewport(), query)
|
||||
dynamic_buttons = self.shell_command_manager.get_shell_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_wallpapers(self, query: str):
|
||||
if query == "random":
|
||||
@@ -263,10 +257,8 @@ class Launcher(Window):
|
||||
self.wallpaper_manager.show_wallpaper_thumbnails(self.get_viewport(), query)
|
||||
dynamic_buttons = self.wallpaper_manager.get_wallpaper_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
|
||||
def show_bluetooth_settings(self, *_):
|
||||
self.bluetooth_menu.show_bluetooth_menu(self.viewport)
|
||||
dynamic_buttons = self.bluetooth_menu.get_bluetooth_buttons()
|
||||
self.update_dynamic_button(dynamic_buttons)
|
||||
self.scrolled_revealer.reveal()
|
||||
@@ -5,59 +5,65 @@ from fabric.widgets.label import Label
|
||||
|
||||
|
||||
def handle_application_search(launcher, query: str):
|
||||
query = query.strip()
|
||||
# Reveal the full app list if the query is empty
|
||||
if not query:
|
||||
launcher.additional_box.set_visible(True)
|
||||
if not query.strip():
|
||||
launcher.scrolled_revealer.unreveal()
|
||||
launcher.additional_box.set_visible(True)
|
||||
return
|
||||
|
||||
# Hide full app list and search through the available apps
|
||||
launcher.additional_box.set_visible(False)
|
||||
filtered_apps = [
|
||||
app
|
||||
for app in launcher.all_apps
|
||||
if query.casefold()
|
||||
in (
|
||||
" ".join(filter(None, [app.display_name, app.name, app.generic_name]))
|
||||
(app.display_name or "")
|
||||
+ " "
|
||||
+ (app.name or "")
|
||||
+ " "
|
||||
+ (app.generic_name or "")
|
||||
).casefold()
|
||||
]
|
||||
|
||||
# Display filtered apps or hide the search results view if no matches
|
||||
if filtered_apps:
|
||||
launcher.viewport.children = [
|
||||
Button(
|
||||
child=Box(
|
||||
orientation="h",
|
||||
bake_application_slot(launcher, app) for app in filtered_apps[:6]
|
||||
]
|
||||
launcher.scrolled_revealer.reveal()
|
||||
launcher.additional_box.set_visible(False)
|
||||
else:
|
||||
launcher.scrolled_revealer.unreveal()
|
||||
|
||||
|
||||
def bake_application_slot(launcher, app, **kwargs) -> Button:
|
||||
return Button(
|
||||
child=Box(
|
||||
orientation="h",
|
||||
spacing=10,
|
||||
children=[
|
||||
Image(pixbuf=app.get_icon_pixbuf(), h_align="start", size=62),
|
||||
Box(
|
||||
orientation="v",
|
||||
spacing=10,
|
||||
children=[
|
||||
Image(pixbuf=app.get_icon_pixbuf(), h_align="start", size=68),
|
||||
Box(
|
||||
orientation="v",
|
||||
spacing=10,
|
||||
children=[
|
||||
Label(
|
||||
name="title",
|
||||
label=app.display_name or "Unknown",
|
||||
h_align="start",
|
||||
v_align="center",
|
||||
),
|
||||
Label(
|
||||
name="description",
|
||||
label=app.description or "",
|
||||
justification="left",
|
||||
line_wrap="char",
|
||||
v_align="center",
|
||||
),
|
||||
],
|
||||
Label(
|
||||
label=app.display_name or "Unknown",
|
||||
h_expand=True,
|
||||
name="title",
|
||||
v_align="center",
|
||||
h_align="start",
|
||||
),
|
||||
Label(
|
||||
label=app.description or "",
|
||||
name="description",
|
||||
h_expand=True,
|
||||
v_align="center",
|
||||
justification="left",
|
||||
line_wrap="char",
|
||||
),
|
||||
],
|
||||
),
|
||||
name="app-item",
|
||||
on_clicked=lambda *_: (app.launch(), launcher.set_visible(False)),
|
||||
)
|
||||
for app in filtered_apps[:6] # Limit to 6 apps
|
||||
]
|
||||
launcher.scrolled_revealer.reveal()
|
||||
else:
|
||||
launcher.scrolled_revealer.unreveal()
|
||||
],
|
||||
),
|
||||
name="app-item",
|
||||
on_clicked=lambda *_: (app.launch(), launcher.set_visible(False)),
|
||||
**kwargs,
|
||||
)
|
||||
Reference in new issue
Block a user