added images to plugin menu options, added testing for generators, attempted mitigation of memory leak
This commit is contained in:
@@ -47,6 +47,8 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
|
||||
event_system.subscribe("paste_files", self.paste_files)
|
||||
event_system.subscribe("move_files", self.move_files)
|
||||
event_system.subscribe("copy_name", self.copy_name)
|
||||
event_system.subscribe("copy_path", self.copy_path)
|
||||
event_system.subscribe("copy_path_name", self.copy_path_name)
|
||||
event_system.subscribe("create_files", self.create_files)
|
||||
event_system.subscribe("rename_files", self.rename_files)
|
||||
|
||||
@@ -79,8 +81,16 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
|
||||
|
||||
def copy_path(self):
|
||||
state = event_system.emit_and_await("get_current_state")
|
||||
dir = state.tab.get_current_directory()
|
||||
event_system.emit("set_clipboard_data", (file_name,))
|
||||
path = state.tab.get_current_directory()
|
||||
print(path)
|
||||
event_system.emit("set_clipboard_data", (path,))
|
||||
|
||||
def copy_path_name(self):
|
||||
state = event_system.emit_and_await("get_current_state")
|
||||
if len(state.uris) == 1:
|
||||
file = state.uris[0].replace("file://")
|
||||
print(file)
|
||||
event_system.emit("set_clipboard_data", (file,))
|
||||
|
||||
def open_files(self):
|
||||
state = event_system.emit_and_await("get_current_state")
|
||||
|
@@ -14,11 +14,10 @@ from ...widgets.icon_tree_widget import IconTreeWidget
|
||||
|
||||
|
||||
|
||||
|
||||
class GridMixin:
|
||||
"""docstring for GridMixin"""
|
||||
|
||||
def load_store(self, tab, store, save_state = False):
|
||||
def load_store(self, tab, store, save_state = False, use_generator = False):
|
||||
store.clear()
|
||||
dir = tab.get_current_directory()
|
||||
files = tab.get_files()
|
||||
@@ -27,19 +26,33 @@ class GridMixin:
|
||||
store.append([None, file[0]])
|
||||
|
||||
Gtk.main_iteration()
|
||||
for i, file in enumerate(files):
|
||||
self.create_icon(i, tab, store, dir, file[0])
|
||||
if use_generator:
|
||||
# NOTE: tab > icon > _get_system_thumbnail_gtk_thread must not be used
|
||||
# as the attempted promotion back to gtk threading stalls the generator. (We're already in main gtk thread)
|
||||
for i, icon in enumerate( self.create_icons_generator(tab, dir, files) ):
|
||||
self.load_icon(i, store, icon)
|
||||
else:
|
||||
for i, file in enumerate(files):
|
||||
self.create_icon(i, tab, store, dir, file[0])
|
||||
|
||||
# NOTE: Not likely called often from here but it could be useful
|
||||
if save_state and not trace_debug:
|
||||
self.fm_controller.save_state()
|
||||
|
||||
def create_icons_generator(self, tab, dir, files):
|
||||
for file in files:
|
||||
icon = tab.create_icon(dir, file[0])
|
||||
yield icon
|
||||
|
||||
@daemon_threaded
|
||||
def create_icon(self, i, tab, store, dir, file):
|
||||
icon = tab.create_icon(dir, file)
|
||||
GLib.idle_add(self.update_store, *(i, store, icon,))
|
||||
|
||||
@daemon_threaded
|
||||
def load_icon(self, i, store, icon):
|
||||
GLib.idle_add(self.update_store, *(i, store, icon,))
|
||||
|
||||
def update_store(self, i, store, icon):
|
||||
itr = store.get_iter(i)
|
||||
store.set_value(itr, 0, icon)
|
||||
|
@@ -50,8 +50,6 @@ class TabMixin(GridMixin):
|
||||
self.set_file_watcher(tab)
|
||||
|
||||
|
||||
|
||||
|
||||
def close_tab(self, button, eve = None):
|
||||
notebook = button.get_parent().get_parent()
|
||||
if notebook.get_n_pages() == 1:
|
||||
@@ -63,7 +61,6 @@ class TabMixin(GridMixin):
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}")
|
||||
icon_grid = scroll.get_children()[0]
|
||||
store = icon_grid.get_model()
|
||||
page_num = notebook.page_num(scroll)
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
watcher = tab.get_dir_watcher()
|
||||
|
||||
@@ -71,12 +68,14 @@ class TabMixin(GridMixin):
|
||||
self.get_fm_window(wid).delete_tab_by_id(tid)
|
||||
|
||||
store.clear()
|
||||
# store.run_dispose()
|
||||
icon_grid.destroy()
|
||||
# icon_grid.run_dispose()
|
||||
scroll.destroy()
|
||||
scroll.run_dispose()
|
||||
tab_box.destroy()
|
||||
notebook.remove_page(page_num)
|
||||
tab_box.run_dispose()
|
||||
|
||||
del page_num
|
||||
del store
|
||||
del icon_grid
|
||||
del scroll
|
||||
|
@@ -14,11 +14,10 @@ from ...widgets.icon_tree_widget import IconTreeWidget
|
||||
|
||||
|
||||
|
||||
|
||||
class GridMixin:
|
||||
"""docstring for GridMixin"""
|
||||
|
||||
def load_store(self, tab, store, save_state=False):
|
||||
def load_store(self, tab, store, save_state = False, use_generator = False):
|
||||
store.clear()
|
||||
dir = tab.get_current_directory()
|
||||
files = tab.get_files()
|
||||
@@ -27,19 +26,33 @@ class GridMixin:
|
||||
store.append([None, file[0]])
|
||||
|
||||
Gtk.main_iteration()
|
||||
for i, file in enumerate(files):
|
||||
self.create_icon(i, tab, store, dir, file[0])
|
||||
if use_generator:
|
||||
# NOTE: tab > icon > _get_system_thumbnail_gtk_thread must not be used
|
||||
# as the attempted promotion back to gtk threading stalls the generator. (We're already in main gtk thread)
|
||||
for i, icon in enumerate( self.create_icons_generator(tab, dir, files) ):
|
||||
self.load_icon(i, store, icon)
|
||||
else:
|
||||
for i, file in enumerate(files):
|
||||
self.create_icon(i, tab, store, dir, file[0])
|
||||
|
||||
# NOTE: Not likely called often from here but it could be useful
|
||||
if save_state and not trace_debug:
|
||||
self.fm_controller.save_state()
|
||||
|
||||
def create_icons_generator(self, tab, dir, files):
|
||||
for file in files:
|
||||
icon = tab.create_icon(dir, file[0])
|
||||
yield icon
|
||||
|
||||
@daemon_threaded
|
||||
def create_icon(self, i, tab, store, dir, file):
|
||||
icon = tab.create_icon(dir, file)
|
||||
GLib.idle_add(self.update_store, *(i, store, icon,))
|
||||
|
||||
@daemon_threaded
|
||||
def load_icon(self, i, store, icon):
|
||||
GLib.idle_add(self.update_store, *(i, store, icon,))
|
||||
|
||||
def update_store(self, i, store, icon):
|
||||
itr = store.get_iter(i)
|
||||
store.set_value(itr, 0, icon)
|
||||
|
@@ -63,23 +63,21 @@ class TabMixin(GridMixin):
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}")
|
||||
icon_grid = scroll.get_children()[0]
|
||||
store = icon_grid.get_model()
|
||||
page_num = notebook.page_num(scroll)
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
watcher = tab.get_dir_watcher()
|
||||
|
||||
watcher.cancel()
|
||||
self.get_fm_window(wid).delete_tab_by_id(tid)
|
||||
|
||||
icon_grid = scroll.get_children()[0]
|
||||
store = icon_grid.get_model()
|
||||
|
||||
store.clear()
|
||||
store.run_dispose()
|
||||
icon_grid.destroy()
|
||||
icon_grid.run_dispose()
|
||||
scroll.destroy()
|
||||
scroll.run_dispose()
|
||||
tab_box.destroy()
|
||||
notebook.remove_page(page_num)
|
||||
tab_box.run_dispose()
|
||||
|
||||
del page_num
|
||||
del store
|
||||
del icon_grid
|
||||
del scroll
|
||||
@@ -89,6 +87,7 @@ class TabMixin(GridMixin):
|
||||
|
||||
if not settings.is_trace_debug():
|
||||
self.fm_controller.save_state()
|
||||
|
||||
self.set_window_title()
|
||||
|
||||
# NOTE: Not actually getting called even tho set in the glade file...
|
||||
|
@@ -50,7 +50,7 @@ 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, 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.")
|
||||
|
Reference in New Issue
Block a user