Added dirty start check, added images to plugin buttons, cleanup
This commit is contained in:
parent
49ed89201a
commit
75da08d081
|
@ -81,8 +81,12 @@ class Plugin(PluginBase):
|
|||
self._archiver_dialogue = self._builder.get_object("archiver_dialogue")
|
||||
self._arc_command_buffer = self._builder.get_object("arc_command_buffer")
|
||||
|
||||
icon = Gtk.Image(stock=Gtk.STOCK_FLOPPY)
|
||||
button = Gtk.Button(label=self.name)
|
||||
|
||||
button.set_image(icon)
|
||||
button.connect("button-release-event", self.show_archiver_dialogue)
|
||||
|
||||
return button
|
||||
|
||||
def run(self):
|
||||
|
|
|
@ -99,8 +99,12 @@ class Plugin(PluginBase):
|
|||
self._file_group = self._builder.get_object("file_group")
|
||||
|
||||
def generate_reference_ui_element(self):
|
||||
icon = Gtk.Image(stock=Gtk.STOCK_PROPERTIES )
|
||||
button = Gtk.Button(label=self.name)
|
||||
|
||||
button.connect("button-release-event", self._show_properties_page)
|
||||
button.set_image(icon)
|
||||
|
||||
return button
|
||||
|
||||
|
||||
|
|
|
@ -70,8 +70,12 @@ class Plugin(PluginBase):
|
|||
self._trailer_link = self._builder.get_object("trailer_link")
|
||||
|
||||
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_info_page)
|
||||
button.set_image(icon)
|
||||
|
||||
return button
|
||||
|
||||
@threaded
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Empty Trash...</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<signal name="button-release-event" handler="empty_trash" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
|
@ -63,7 +64,6 @@
|
|||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Move to Trash...</property>
|
||||
<property name="margin-top">20</property>
|
||||
<property name="image">trash_img</property>
|
||||
<property name="always-show-image">True</property>
|
||||
<signal name="button-release-event" handler="trash_files" swapped="no"/>
|
||||
|
|
|
@ -68,8 +68,13 @@ class Plugin(PluginBase):
|
|||
self._file_hash = self._builder.get_object("file_hash")
|
||||
|
||||
def generate_reference_ui_element(self):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(f"{self.path}/../../icons/video.png", 16, 16, True)
|
||||
icon = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
button = Gtk.Button(label=self.name)
|
||||
|
||||
button.set_image(icon)
|
||||
button.connect("button-release-event", self._show_thumbnailer_page)
|
||||
|
||||
return button
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
|
||||
# Python imports
|
||||
import argparse, faulthandler, traceback
|
||||
from setproctitle import setproctitle
|
||||
|
|
|
@ -54,6 +54,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
|||
if not settings.is_trace_debug():
|
||||
self.fm_controller.save_state()
|
||||
|
||||
settings.clear_pid()
|
||||
time.sleep(event_sleep_time)
|
||||
Gtk.main_quit()
|
||||
|
||||
|
|
|
@ -50,13 +50,8 @@ class DesktopIconMixin:
|
|||
return None
|
||||
|
||||
def traverse_icons_folder(self, path, icon):
|
||||
alt_icon_path = ""
|
||||
|
||||
for (dirpath, dirnames, filenames) in os.walk(path):
|
||||
for file in filenames:
|
||||
appNM = "application-x-" + icon
|
||||
if icon in file or appNM in file:
|
||||
alt_icon_path = dirpath + "/" + file
|
||||
break
|
||||
|
||||
return alt_icon_path
|
||||
return f"{dirpath}/{file}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# System import
|
||||
import os, threading, subprocess, shlex
|
||||
import os, threading, subprocess
|
||||
|
||||
# Lib imports
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Settings:
|
|||
FFMPG_THUMBNLR = f"{CONFIG_PATH}/ffmpegthumbnailer" # Thumbnail generator binary
|
||||
REMUX_FOLDER = f"{USER_HOME}/.remuxs" # Remuxed files folder
|
||||
|
||||
ICON_DIRS = ["/usr/share/pixmaps", "/usr/share/icons", f"{USER_HOME}/.icons" ,]
|
||||
ICON_DIRS = ["/usr/share/icons", f"{USER_HOME}/.icons" "/usr/share/pixmaps"]
|
||||
BASE_THUMBS_PTH = f"{USER_HOME}/.thumbnails" # Used for thumbnail generation
|
||||
ABS_THUMBS_PTH = f"{BASE_THUMBS_PTH}/normal" # Used for thumbnail generation
|
||||
STEAM_ICONS_PTH = f"{BASE_THUMBS_PTH}/steam_icons"
|
||||
|
|
|
@ -38,8 +38,8 @@ class IPCServer:
|
|||
@daemon_threaded
|
||||
def create_ipc_listener(self) -> None:
|
||||
if self._conn_type == "socket":
|
||||
if os.path.exists(self._ipc_address):
|
||||
return
|
||||
if os.path.exists(self._ipc_address) and settings.is_dirty_start():
|
||||
os.unlink(self._ipc_address)
|
||||
|
||||
listener = Listener(address=self._ipc_address, family="AF_UNIX", authkey=self._ipc_authkey)
|
||||
elif "unsecured" not in self._conn_type:
|
||||
|
|
|
@ -31,6 +31,7 @@ class Settings:
|
|||
self._KEY_BINDINGS = f"{self._CONFIG_PATH}/key-bindings.json"
|
||||
self._DEFAULT_ICONS = f"{self._CONFIG_PATH}/icons"
|
||||
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/{app_name.lower()}.png"
|
||||
self._PID_FILE = f"{self._CONFIG_PATH}/solarfm.pid"
|
||||
self._ICON_THEME = Gtk.IconTheme.get_default()
|
||||
|
||||
if not os.path.exists(self._CONFIG_PATH):
|
||||
|
@ -65,6 +66,44 @@ class Settings:
|
|||
|
||||
self._trace_debug = False
|
||||
self._debug = False
|
||||
self._dirty_start = False
|
||||
|
||||
self._check_for_dirty_state()
|
||||
|
||||
|
||||
def _check_for_dirty_state(self):
|
||||
if not os.path.exists(self._PID_FILE):
|
||||
self._write_new_pid()
|
||||
else:
|
||||
with open(self._PID_FILE, "r") as _pid:
|
||||
pid = _pid.readline().strip()
|
||||
if pid not in ("", None):
|
||||
self._check_alive_status(int(pid))
|
||||
else:
|
||||
self._write_new_pid()
|
||||
|
||||
""" Check For the existence of a unix pid. """
|
||||
def _check_alive_status(self, pid):
|
||||
print(f"PID Found: {pid}")
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except OSError:
|
||||
print("SolarFM Is starting dirty...")
|
||||
self._dirty_start = True
|
||||
self._write_new_pid()
|
||||
|
||||
print("PID is alive... Let downstream errors handle app closure.")
|
||||
|
||||
def _write_new_pid(self):
|
||||
pid = os.getpid()
|
||||
self._write_pid(pid)
|
||||
|
||||
def _clean_pid(self):
|
||||
os.unlink(self._PID_FILE)
|
||||
|
||||
def _write_pid(self, pid):
|
||||
with open(self._PID_FILE, "w") as _pid:
|
||||
_pid.write(f"{pid}")
|
||||
|
||||
|
||||
def create_window(self) -> None:
|
||||
|
@ -104,6 +143,7 @@ class Settings:
|
|||
|
||||
return monitors
|
||||
|
||||
|
||||
def get_main_window(self) -> Gtk.ApplicationWindow: return self._main_window
|
||||
def get_builder(self) -> Gtk.Builder: return self._builder
|
||||
def get_logger(self) -> Logger: return self._logger
|
||||
|
@ -117,6 +157,8 @@ class Settings:
|
|||
|
||||
def is_trace_debug(self) -> str: return self._trace_debug
|
||||
def is_debug(self) -> str: return self._debug
|
||||
def is_dirty_start(self) -> bool: return self._dirty_start
|
||||
def clear_pid(self): self._clean_pid()
|
||||
|
||||
|
||||
def set_trace_debug(self, trace_debug):
|
||||
|
|
|
@ -740,23 +740,6 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Archive</property>
|
||||
<property name="name">archive</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Archive...</property>
|
||||
<property name="always-show-image">True</property>
|
||||
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
|
@ -1079,17 +1062,6 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem">
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="name">delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Reference in New Issue