Bringing to latest changes #3
|
@ -101,7 +101,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
||||||
self.fm_controller.save_state(path)
|
self.fm_controller.save_state(path)
|
||||||
elif action == "load_session":
|
elif action == "load_session":
|
||||||
path = f"{save_load_dialog.get_file().get_path()}"
|
path = f"{save_load_dialog.get_file().get_path()}"
|
||||||
session_json = self.fm_controller.load_state(path)
|
session_json = self.fm_controller.get_state_from_file(path)
|
||||||
self.load_session(session_json)
|
self.load_session(session_json)
|
||||||
if (response == Gtk.ResponseType.CANCEL) or (response == Gtk.ResponseType.DELETE_EVENT):
|
if (response == Gtk.ResponseType.CANCEL) or (response == Gtk.ResponseType.DELETE_EVENT):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -56,8 +56,8 @@ class Controller_Data:
|
||||||
self.bottom_file_count_label = self.builder.get_object("bottom_file_count_label")
|
self.bottom_file_count_label = self.builder.get_object("bottom_file_count_label")
|
||||||
self.bottom_path_label = self.builder.get_object("bottom_path_label")
|
self.bottom_path_label = self.builder.get_object("bottom_path_label")
|
||||||
|
|
||||||
self.trash_files_path = GLib.get_user_data_dir() + "/Trash/files"
|
self.trash_files_path = f"{GLib.get_user_data_dir()}/Trash/files"
|
||||||
self.trash_info_path = GLib.get_user_data_dir() + "/Trash/info"
|
self.trash_info_path = f"{GLib.get_user_data_dir()}/Trash/info"
|
||||||
|
|
||||||
# In compress commands:
|
# In compress commands:
|
||||||
# %n: First selected filename/dir to archive
|
# %n: First selected filename/dir to archive
|
||||||
|
|
|
@ -15,9 +15,9 @@ from .widget_mixin import WidgetMixin
|
||||||
class TabMixin(WidgetMixin):
|
class TabMixin(WidgetMixin):
|
||||||
"""docstring for TabMixin"""
|
"""docstring for TabMixin"""
|
||||||
|
|
||||||
def create_tab(self, wid=None, path=None):
|
def create_tab(self, wid=None, tid=None, path=None):
|
||||||
if not wid:
|
if not wid:
|
||||||
wid, _tid = self.fm_controller.get_active_wid_and_tid()
|
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||||
|
|
||||||
notebook = self.builder.get_object(f"window_{wid}")
|
notebook = self.builder.get_object(f"window_{wid}")
|
||||||
path_entry = self.builder.get_object(f"path_entry")
|
path_entry = self.builder.get_object(f"path_entry")
|
||||||
|
@ -25,7 +25,12 @@ class TabMixin(WidgetMixin):
|
||||||
tab.logger = self.logger
|
tab.logger = self.logger
|
||||||
|
|
||||||
tab.set_wid(wid)
|
tab.set_wid(wid)
|
||||||
if path: tab.set_path(path)
|
if not path:
|
||||||
|
if wid and tid:
|
||||||
|
_tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||||
|
tab.set_path(_tab.get_current_directory())
|
||||||
|
else:
|
||||||
|
tab.set_path(path)
|
||||||
|
|
||||||
tab_widget = self.create_tab_widget(tab)
|
tab_widget = self.create_tab_widget(tab)
|
||||||
scroll, store = self.create_icon_grid_widget(tab, wid)
|
scroll, store = self.create_icon_grid_widget(tab, wid)
|
||||||
|
@ -123,7 +128,7 @@ class TabMixin(WidgetMixin):
|
||||||
|
|
||||||
if action == "create_tab":
|
if action == "create_tab":
|
||||||
dir = tab.get_current_directory()
|
dir = tab.get_current_directory()
|
||||||
self.create_tab(wid, dir)
|
self.create_tab(wid, None, dir)
|
||||||
self.fm_controller.save_state()
|
self.fm_controller.save_state()
|
||||||
return
|
return
|
||||||
if action == "go_up":
|
if action == "go_up":
|
||||||
|
|
|
@ -27,8 +27,14 @@ class WidgetMixin:
|
||||||
dir = tab.get_current_directory()
|
dir = tab.get_current_directory()
|
||||||
files = tab.get_files()
|
files = tab.get_files()
|
||||||
|
|
||||||
for i, file in enumerate(files):
|
# NOTE: We insure all indecies exist before calling threads that update
|
||||||
|
# icon positions. In addition, adding the name allows us to see
|
||||||
|
# the "file" during long or heavy number of icon updates.
|
||||||
|
for file in files:
|
||||||
store.append([None, file[0]])
|
store.append([None, file[0]])
|
||||||
|
|
||||||
|
# Now we update as fast as possible the icons.
|
||||||
|
for i, file in enumerate(files):
|
||||||
self.create_icon(i, tab, store, dir, file[0])
|
self.create_icon(i, tab, store, dir, file[0])
|
||||||
|
|
||||||
# NOTE: Not likely called often from here but it could be useful
|
# NOTE: Not likely called often from here but it could be useful
|
||||||
|
@ -37,27 +43,12 @@ class WidgetMixin:
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
def create_icon(self, i, tab, store, dir, file):
|
def create_icon(self, i, tab, store, dir, file):
|
||||||
icon = tab.create_icon(dir, file)
|
icon = tab.create_icon(dir, file)
|
||||||
|
GLib.idle_add(self.update_store, *(i, store, icon, tab, dir, file,))
|
||||||
|
|
||||||
|
def update_store(self, i, store, icon, tab, dir, file):
|
||||||
fpath = f"{dir}/{file}"
|
fpath = f"{dir}/{file}"
|
||||||
GLib.idle_add(self.update_store, (i, store, icon, tab, fpath,))
|
itr = store.get_iter(i)
|
||||||
|
|
||||||
# NOTE: Might need to keep an eye on this throwing invalid iters when too
|
|
||||||
# many updates are happening to a folder. Example: /tmp
|
|
||||||
def update_store(self, item):
|
|
||||||
i, store, icon, tab, fpath = item
|
|
||||||
itr = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
itr = store.get_iter(i)
|
|
||||||
except Exception as e:
|
|
||||||
try:
|
|
||||||
time.sleep(0.2)
|
|
||||||
itr = store.get_iter(i)
|
|
||||||
except Exception as e:
|
|
||||||
print(":Invalid Itr detected: (Potential race condition...)")
|
|
||||||
print(f"Index Requested: {i}")
|
|
||||||
print(f"Store Size: {len(store)}")
|
|
||||||
return
|
|
||||||
|
|
||||||
if not icon:
|
if not icon:
|
||||||
icon = self.get_system_thumbnail(fpath, tab.SYS_ICON_WH[0])
|
icon = self.get_system_thumbnail(fpath, tab.SYS_ICON_WH[0])
|
||||||
|
@ -69,7 +60,6 @@ class WidgetMixin:
|
||||||
|
|
||||||
store.set_value(itr, 0, icon)
|
store.set_value(itr, 0, icon)
|
||||||
|
|
||||||
|
|
||||||
def get_system_thumbnail(self, filename, size):
|
def get_system_thumbnail(self, filename, size):
|
||||||
try:
|
try:
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
|
@ -115,7 +105,7 @@ class WidgetMixin:
|
||||||
def create_icon_grid_widget(self, tab, wid):
|
def create_icon_grid_widget(self, tab, wid):
|
||||||
scroll = Gtk.ScrolledWindow()
|
scroll = Gtk.ScrolledWindow()
|
||||||
grid = Gtk.IconView()
|
grid = Gtk.IconView()
|
||||||
store = Gtk.ListStore(GdkPixbuf.Pixbuf or GdkPixbuf.PixbufAnimation or None, str)
|
store = Gtk.ListStore(GdkPixbuf.Pixbuf or GdkPixbuf.PixbufAnimation or None, str or None)
|
||||||
|
|
||||||
grid.set_model(store)
|
grid.set_model(store)
|
||||||
grid.set_pixbuf_column(0)
|
grid.set_pixbuf_column(0)
|
||||||
|
@ -157,7 +147,7 @@ class WidgetMixin:
|
||||||
def create_icon_tree_widget(self, tab, wid):
|
def create_icon_tree_widget(self, tab, wid):
|
||||||
scroll = Gtk.ScrolledWindow()
|
scroll = Gtk.ScrolledWindow()
|
||||||
grid = Gtk.TreeView()
|
grid = Gtk.TreeView()
|
||||||
store = Gtk.TreeStore(GdkPixbuf.Pixbuf or GdkPixbuf.PixbufAnimation or None, str)
|
store = Gtk.TreeStore(GdkPixbuf.Pixbuf or GdkPixbuf.PixbufAnimation or None, str or None)
|
||||||
column = Gtk.TreeViewColumn("Icons")
|
column = Gtk.TreeViewColumn("Icons")
|
||||||
icon = Gtk.CellRendererPixbuf()
|
icon = Gtk.CellRendererPixbuf()
|
||||||
name = Gtk.CellRendererText()
|
name = Gtk.CellRendererText()
|
||||||
|
|
|
@ -256,4 +256,4 @@ class WindowMixin(TabMixin):
|
||||||
|
|
||||||
|
|
||||||
def create_new_tab_notebook(self, widget=None, wid=None, path=None):
|
def create_new_tab_notebook(self, widget=None, wid=None, path=None):
|
||||||
self.create_tab(wid, path)
|
self.create_tab(wid, None, path)
|
||||||
|
|
Loading…
Reference in New Issue