Added dirty start check, added images to plugin buttons, cleanup
This commit is contained in:
@@ -49,8 +49,8 @@ class FileSearchMixin:
|
||||
GLib.idle_add(self.reset_file_list_box)
|
||||
|
||||
# NOTE: If query create new process and do all new loop.
|
||||
self.pause_fifo_update = False
|
||||
if query:
|
||||
self.pause_fifo_update = False
|
||||
GLib.idle_add(self._exec_find_file_query, query)
|
||||
|
||||
def _exec_find_file_query(self, widget=None, eve=None):
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# Python imports
|
||||
import threading, subprocess, signal, json, shlex
|
||||
import ctypes, threading, subprocess, signal, json, shlex
|
||||
libgcc_s = ctypes.CDLL('libgcc_s.so.1')
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
@@ -49,8 +50,8 @@ class GrepSearchMixin:
|
||||
GLib.idle_add(self.reset_grep_box)
|
||||
|
||||
# NOTE: If query create new process and do all new loop.
|
||||
self.pause_fifo_update = False
|
||||
if query:
|
||||
self.pause_fifo_update = False
|
||||
GLib.idle_add(self._exec_grep_query, query)
|
||||
|
||||
def _exec_grep_query(self, widget=None, eve=None):
|
||||
|
@@ -80,8 +80,12 @@ class Plugin(IPCServer, FileSearchMixin, GrepSearchMixin, PluginBase):
|
||||
self.create_ipc_listener()
|
||||
|
||||
def generate_reference_ui_element(self):
|
||||
icon = Gtk.Image(stock=Gtk.STOCK_FIND)
|
||||
button = Gtk.Button(label=self.name)
|
||||
|
||||
button.connect("button-release-event", self._show_page)
|
||||
button.set_image(icon)
|
||||
|
||||
return button
|
||||
|
||||
|
||||
|
@@ -16,9 +16,9 @@ from multiprocessing.connection import Client
|
||||
_ipc_address = f'/tmp/solarfm-search_grep-ipc.sock'
|
||||
_ipc_authkey = b'' + bytes(f'solarfm-search_grep-ipc', 'utf-8')
|
||||
|
||||
filter = (".mkv", ".mp4", ".webm", ".avi", ".mov", ".m4v", ".mpg", ".mpeg", ".wmv", ".flv") + \
|
||||
(".png", ".jpg", ".jpeg", ".gif", ".ico", ".tga", ".webp") + \
|
||||
(".psf", ".mp3", ".ogg", ".flac", ".m4a")
|
||||
filter = (".cpp", ".css", ".c", ".go", ".html", ".htm", ".java", ".js", ".json", ".lua", ".md", ".py", ".rs", ".toml", ".xml", ".pom") + \
|
||||
(".txt", ".text", ".sh", ".cfg", ".conf", ".log")
|
||||
|
||||
|
||||
# NOTE: Threads WILL NOT die with parent's destruction.
|
||||
def threaded(fn):
|
||||
@@ -59,7 +59,7 @@ def _search_for_string(file, query):
|
||||
grep_result_set = {}
|
||||
padding = 15
|
||||
|
||||
with open(file, 'r') as fp:
|
||||
with open(file, 'rb') as fp:
|
||||
# NOTE: I know there's an issue if there's a very large file with content
|
||||
# all on one line will lower and dupe it. And, yes, it will only
|
||||
# return one instance from the file.
|
||||
@@ -80,7 +80,7 @@ def _search_for_string(file, query):
|
||||
else:
|
||||
line = raw
|
||||
|
||||
b64_line = base64.urlsafe_b64encode(line.encode('utf-8')).decode('utf-8')
|
||||
b64_line = base64.urlsafe_b64encode(line).decode('utf-8')
|
||||
if f"{b64_file}" in grep_result_set.keys():
|
||||
grep_result_set[f"{b64_file}"][f"{i+1}"] = b64_line
|
||||
else:
|
||||
@@ -109,7 +109,7 @@ def grep_search(path, query):
|
||||
if os.path.isdir(target):
|
||||
grep_search(target, query)
|
||||
else:
|
||||
if not target.lower().endswith(filter):
|
||||
if target.lower().endswith(filter):
|
||||
size = os.path.getsize(target)
|
||||
if not size > 5000:
|
||||
_search_for_string(target, query)
|
||||
@@ -125,7 +125,7 @@ def search(args):
|
||||
file_search(args.dir, args.query.lower())
|
||||
|
||||
if args.type == "grep_search":
|
||||
grep_search(args.dir, args.query.lower())
|
||||
grep_search(args.dir, args.query.lower().encode("utf-8"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user