Fixed search failing in some dirs; fixed pathbar autofilling with one found path

This commit is contained in:
2023-09-16 01:18:36 -05:00
parent b5d1bbeccd
commit df688d919e
10 changed files with 132 additions and 80 deletions

View File

@@ -113,8 +113,7 @@ class Controller(UIMixin, SignalsMixins, Controller_Data):
def do_action_from_menu_controls(self, _action=None, eve=None):
if not _action:
return
if not _action: return
if not isinstance(_action, str):
action = _action.get_name()

View File

@@ -1,18 +1,19 @@
# Python imports
import os
import gc
import time
# Lib imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
# Application imports
from .grid_mixin import GridMixin
class TabMixin(GridMixin):
"""docstring for TabMixin"""
@@ -173,27 +174,7 @@ class TabMixin(GridMixin):
path = widget.get_text()
if isinstance(focused_obj, Gtk.Entry):
path_menu_buttons = self.builder.get_object("path_menu_buttons")
query = widget.get_text().replace(dir, "")
files = tab.get_files() + tab.get_hidden()
self.clear_children(path_menu_buttons)
show_path_menu = False
for file, hash, size in files:
if os.path.isdir(f"{dir}{file}"):
if query.lower() in file.lower():
button = Gtk.Button(label=file)
button.show()
button.connect("clicked", self.set_path_entry)
path_menu_buttons.add(button)
show_path_menu = True
if not show_path_menu:
event_system.emit("hide_path_menu")
else:
event_system.emit("show_path_menu")
widget.grab_focus_without_selecting()
widget.set_position(-1)
self.process_path_menu(widget, tab, dir)
if path.endswith(".") or path == dir:
return
@@ -205,21 +186,52 @@ class TabMixin(GridMixin):
icon_grid.clear_and_set_new_store()
self.update_tab(tab_label, tab, icon_grid.get_store(), wid, tid)
try:
widget.grab_focus_without_selecting()
widget.set_position(-1)
except Exception as e:
pass
def process_path_menu(self, gtk_entry, tab, dir):
path_menu_buttons = self.builder.get_object("path_menu_buttons")
query = gtk_entry.get_text().replace(dir, "")
files = tab.get_files() + tab.get_hidden()
def set_path_entry(self, button=None, eve=None):
self.clear_children(path_menu_buttons)
show_path_menu = False
for file, hash, size in files:
if os.path.isdir(f"{dir}{file}"):
if query.lower() in file.lower():
button = Gtk.Button(label=file)
button.show()
button.connect("clicked", self.set_path_entry)
path_menu_buttons.add(button)
show_path_menu = True
if not show_path_menu:
event_system.emit("hide_path_menu")
else:
event_system.emit("show_path_menu")
buttons = path_menu_buttons.get_children()
if len(buttons) == 1:
self.slowed_focus(buttons[0])
@daemon_threaded
def slowed_focus(self, button):
time.sleep(0.05)
GLib.idle_add(self.do_focused_click, *(button,))
def do_focused_click(self, button):
button.grab_focus()
button.clicked()
def set_path_entry(self, button = None, eve = None):
self.path_auto_filled = True
state = self.get_current_state()
path = f"{state.tab.get_current_directory()}/{button.get_label()}"
path_entry = self.builder.get_object("path_entry")
path_entry.set_text(path)
path_entry.grab_focus_without_selecting()
path_entry.set_position(-1)
event_system.emit("hide_path_menu")
def show_hide_hidden_files(self):
wid, tid = self.fm_controller.get_active_wid_and_tid()
tab = self.get_fm_window(wid).get_tab_by_id(tid)

View File

@@ -1,17 +1,19 @@
# Python imports
import os
import gc
import time
# Lib imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
# Application imports
from .grid_mixin import GridMixin
class TabMixin(GridMixin):
"""docstring for TabMixin"""
@@ -85,6 +87,7 @@ class TabMixin(GridMixin):
del watcher
del tab
gc.collect()
if not settings_manager.is_trace_debug():
self.fm_controller.save_state()
@@ -173,27 +176,7 @@ class TabMixin(GridMixin):
path = widget.get_text()
if isinstance(focused_obj, Gtk.Entry):
path_menu_buttons = self.builder.get_object("path_menu_buttons")
query = widget.get_text().replace(dir, "")
files = tab.get_files() + tab.get_hidden()
self.clear_children(path_menu_buttons)
show_path_menu = False
for file, hash, size in files:
if os.path.isdir(f"{dir}{file}"):
if query.lower() in file.lower():
button = Gtk.Button(label=file)
button.show()
button.connect("clicked", self.set_path_entry)
path_menu_buttons.add(button)
show_path_menu = True
if not show_path_menu:
event_system.emit("hide_path_menu")
else:
event_system.emit("show_path_menu")
widget.grab_focus_without_selecting()
widget.set_position(-1)
self.process_path_menu(widget, tab, dir)
if path.endswith(".") or path == dir:
return
@@ -201,18 +184,50 @@ class TabMixin(GridMixin):
if not tab.set_path(path):
return
icon_grid = self.get_icon_grid_from_notebook(notebook, f"{wid}|{tid}")
icon_grid.clear_and_set_new_store()
self.update_tab(tab_label, tab, store, wid, tid)
try:
widget.grab_focus_without_selecting()
widget.set_position(-1)
except Exception as e:
pass
def process_path_menu(self, gtk_entry, tab, dir):
path_menu_buttons = self.builder.get_object("path_menu_buttons")
query = gtk_entry.get_text().replace(dir, "")
files = tab.get_files() + tab.get_hidden()
def set_path_entry(self, button=None, eve=None):
self.clear_children(path_menu_buttons)
show_path_menu = False
for file, hash, size in files:
if os.path.isdir(f"{dir}{file}"):
if query.lower() in file.lower():
button = Gtk.Button(label=file)
button.show()
button.connect("clicked", self.set_path_entry)
path_menu_buttons.add(button)
show_path_menu = True
if not show_path_menu:
event_system.emit("hide_path_menu")
else:
event_system.emit("show_path_menu")
buttons = path_menu_buttons.get_children()
if len(buttons) == 1:
self.slowed_focus(buttons[0])
@daemon_threaded
def slowed_focus(self, button):
time.sleep(0.05)
GLib.idle_add(self.do_focused_click, *(button,))
def do_focused_click(self, button):
button.grab_focus()
button.clicked()
def set_path_entry(self, button = None, eve = None):
self.path_auto_filled = True
state = self.get_current_state()
path = f"{state.tab.get_current_directory()}/{button.get_label()}"
path_entry = self.builder.get_object("path_entry")
path_entry.set_text(path)
path_entry.grab_focus_without_selecting()
path_entry.set_position(-1)

View File

@@ -106,7 +106,7 @@ class WindowMixin(TabMixin):
state = self.get_current_state()
notebook = self.builder.get_object(f"window_{state.wid}")
tab_label = self.get_tab_label(notebook, icons_grid)
tab_label = self.get_tab_label(notebook, state.icon_grid)
fileName = state.store[item][1]
dir = state.tab.get_current_directory()
@@ -114,7 +114,8 @@ class WindowMixin(TabMixin):
if isdir(file):
state.tab.set_path(file)
self.update_tab(tab_label, state.tab, state.store, state.wid, state.tid)
state.icon_grid.clear_and_set_new_store()
self.update_tab(tab_label, state.tab, state.icon_grid.get_store(), state.wid, state.tid)
else:
event_system.emit("open_files")
except WindowException as e:

View File

@@ -94,4 +94,5 @@ class Window(Gtk.ApplicationWindow):
settings_manager.clear_pid()
time.sleep(event_sleep_time)
Gtk.main_quit()

View File

@@ -0,0 +1,11 @@
<frozen importlib._bootstrap_external>:672: size=5717 KiB, count=60317, average=97 B
<frozen importlib._bootstrap>:241: size=534 KiB, count=5538, average=99 B
/usr/lib/python3.10/abc.py:106: size=77.9 KiB, count=290, average=275 B
<frozen importlib._bootstrap_external>:128: size=62.1 KiB, count=532, average=119 B
/usr/lib/python3.10/sre_compile.py:804: size=57.7 KiB, count=110, average=537 B
/home/abaddon/Coding/Projects/Active/Python_Projects/000_Usable/gtk/SolarFM/src/versions/solarfm-0.0.1/solarfm/./shellfm/windows/tabs/tab.py:79: size=56.4 KiB, count=875, average=66 B
/usr/lib/python3.10/site-packages/gi/types.py:52: size=54.0 KiB, count=509, average=109 B
/usr/lib/python3.10/site-packages/gi/module.py:207: size=49.6 KiB, count=233, average=218 B
/usr/lib/python3.10/site-packages/gi/types.py:51: size=40.1 KiB, count=733, average=56 B
<frozen importlib._bootstrap>:359: size=38.6 KiB, count=549, average=72 B