Changing out threading for some sections; added 2 new tab option
This commit is contained in:
parent
d936b17429
commit
9336df2afa
@ -135,6 +135,8 @@ class Controller(UIMixin, SignalsMixins, Controller_Data):
|
||||
event_system.emit("open_files")
|
||||
if action == "open_with":
|
||||
event_system.emit("show_appchooser_menu")
|
||||
if action == "open_2_new_tab":
|
||||
event_system.emit("open_2_new_tab")
|
||||
if action == "execute":
|
||||
event_system.emit("execute_files")
|
||||
if action == "execute_in_terminal":
|
||||
|
@ -40,6 +40,7 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
|
||||
|
||||
event_system.subscribe("open_files", self.open_files)
|
||||
event_system.subscribe("open_with_files", self.open_with_files)
|
||||
event_system.subscribe("open_2_new_tab", self.open_2_new_tab)
|
||||
event_system.subscribe("execute_files", self.execute_files)
|
||||
|
||||
event_system.subscribe("cut_files", self.cut_files)
|
||||
@ -104,6 +105,12 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
|
||||
|
||||
state.tab.app_chooser_exec(app_info, uris)
|
||||
|
||||
def open_2_new_tab(self):
|
||||
state = event_system.emit_and_await("get_current_state")
|
||||
uri = state.uris[0]
|
||||
message = f"FILE|{uri}"
|
||||
logger.info(message)
|
||||
event_system.emit("post_file_to_ipc", message)
|
||||
|
||||
def execute_files(self, in_terminal=False):
|
||||
state = event_system.emit_and_await("get_current_state")
|
||||
@ -111,4 +118,4 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
|
||||
command = None
|
||||
for path in state.uris:
|
||||
command = f"{shlex.quote(path)}" if not in_terminal else f"{state.tab.terminal_app} -e {shlex.quote(path)}"
|
||||
state.tab.execute(shlex.split(command), start_dir=state.tab.get_current_directory())
|
||||
state.tab.execute(shlex.split(command), start_dir=state.tab.get_current_directory())
|
@ -48,7 +48,7 @@ class FileActionSignalsMixin:
|
||||
else:
|
||||
self.soft_lock_countdown(data[0])
|
||||
|
||||
@threaded
|
||||
@daemon_threaded
|
||||
def soft_lock_countdown(self, tab_widget):
|
||||
self.soft_update_lock[tab_widget] = { "last_update_time": time.time()}
|
||||
|
||||
@ -102,4 +102,4 @@ class FileActionSignalsMixin:
|
||||
|
||||
items = icon_grid.get_selected_items()
|
||||
if len(items) > 0:
|
||||
icon_grid.scroll_to_path(items[0], False, 0.5, 0.5)
|
||||
icon_grid.scroll_to_path(items[0], False, 0.5, 0.5)
|
@ -26,13 +26,13 @@ class GridMixin:
|
||||
store.append([None, file[0]])
|
||||
|
||||
Gtk.main_iteration()
|
||||
thread = self.generate_icons(tab, store, dir, files)
|
||||
GLib.Thread("", self.generate_icons, tab, store, dir, files)
|
||||
|
||||
# NOTE: Not likely called often from here but it could be useful
|
||||
if save_state and not trace_debug:
|
||||
self.fm_controller.save_state()
|
||||
|
||||
@daemon_threaded
|
||||
|
||||
def generate_icons(self, tab, store, dir, files):
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
@ -47,6 +47,7 @@ class GridMixin:
|
||||
async def create_icons(self, tab, store, dir, files):
|
||||
tasks = [self.update_store(i, store, dir, tab, file[0]) for i, file in enumerate(files)]
|
||||
await asyncio.gather(*tasks)
|
||||
GLib.idle_add(Gtk.main_iteration)
|
||||
|
||||
async def update_store(self, i, store, dir, tab, file):
|
||||
icon = tab.create_icon(dir, file)
|
||||
|
@ -6,6 +6,7 @@ gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import GLib
|
||||
|
||||
# Application imports
|
||||
from .mixins.ui.pane_mixin import PaneMixin
|
||||
@ -37,14 +38,12 @@ class UIMixin(PaneMixin, WindowMixin):
|
||||
event_system.emit("load_files_view_state", (nickname, tabs, isHidden))
|
||||
|
||||
|
||||
|
||||
@daemon_threaded
|
||||
def _focus_last_visible_notebook(self, icon_grid):
|
||||
import time
|
||||
|
||||
window = settings_manager.get_main_window()
|
||||
while not window.is_visible() and not window.get_realized():
|
||||
time.sleep(0.1)
|
||||
time.sleep(0.2)
|
||||
|
||||
icon_grid.event(Gdk.Event().new(type = Gdk.EventType.BUTTON_RELEASE))
|
||||
|
||||
@ -79,7 +78,7 @@ class UIMixin(PaneMixin, WindowMixin):
|
||||
|
||||
scroll_win = notebook.get_children()[-1]
|
||||
icon_grid = scroll_win.get_children()[0]
|
||||
self._focus_last_visible_notebook(icon_grid)
|
||||
GLib.Thread("", self._focus_last_visible_notebook, icon_grid)
|
||||
except UIMixinException as e:
|
||||
logger.info("\n: The saved session might be missing window data! :\nLocation: ~/.config/solarfm/session.json\nFix: Back it up and delete it to reset.\n")
|
||||
logger.debug(repr(e))
|
||||
|
@ -26,13 +26,12 @@ class GridMixin:
|
||||
store.append([None, file[0]])
|
||||
|
||||
Gtk.main_iteration()
|
||||
thread = self.generate_icons(tab, store, dir, files)
|
||||
GLib.Thread("", self.generate_icons, tab, store, dir, files)
|
||||
|
||||
# NOTE: Not likely called often from here but it could be useful
|
||||
if save_state and not trace_debug:
|
||||
self.fm_controller.save_state()
|
||||
|
||||
@daemon_threaded
|
||||
def generate_icons(self, tab, store, dir, files):
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
|
@ -50,8 +50,8 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
|
||||
|
||||
if not thumbnl:
|
||||
# TODO: Detect if not in a thread and use directly for speed get_system_thumbnail
|
||||
thumbnl = self.get_system_thumbnail(full_path, self.sys_icon_wh[0])
|
||||
# thumbnl = self._get_system_thumbnail_gtk_thread(full_path, self.sys_icon_wh[0])
|
||||
# thumbnl = self.get_system_thumbnail(full_path, self.sys_icon_wh[0])
|
||||
thumbnl = self._get_system_thumbnail_gtk_thread(full_path, self.sys_icon_wh[0])
|
||||
if not thumbnl:
|
||||
raise IconException("No known icons found.")
|
||||
|
||||
@ -201,4 +201,4 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,
|
||||
False, 8, w, h, w * 3)
|
||||
|
||||
return pixbuf.scale_simple(wxh[0], wxh[1], 2) # BILINEAR = 2
|
||||
return pixbuf.scale_simple(wxh[0], wxh[1], 2) # BILINEAR = 2
|
Loading…
Reference in New Issue
Block a user