develop #11

Merged
itdominator merged 36 commits from develop into master 2023-09-19 01:11:24 +00:00
6 changed files with 27 additions and 12 deletions
Showing only changes of commit b5d1bbeccd - Show all commits

View File

@ -73,7 +73,8 @@ class FileActionSignalsMixin:
_store, tab_widget_label = self.get_store_and_label_from_notebook(notebook, f"{wid}|{tid}") _store, tab_widget_label = self.get_store_and_label_from_notebook(notebook, f"{wid}|{tid}")
tab.load_directory() tab.load_directory()
self.load_store(tab, store) icon_grid.clear_and_set_new_store()
self.load_store(tab, icon_grid.get_store())
tab_widget_label.set_label(tab.get_end_of_path()) tab_widget_label.set_label(tab.get_end_of_path())
state = self.get_current_state() state = self.get_current_state()

View File

@ -18,7 +18,6 @@ class GridMixin:
"""docstring for GridMixin""" """docstring for GridMixin"""
def load_store(self, tab, store, save_state = False, use_generator = False): def load_store(self, tab, store, save_state = False, use_generator = False):
store.clear()
dir = tab.get_current_directory() dir = tab.get_current_directory()
files = tab.get_files() files = tab.get_files()
@ -116,3 +115,10 @@ class GridMixin:
tab_label = notebook.get_tab_label(obj).get_children()[0] tab_label = notebook.get_tab_label(obj).get_children()[0]
return store, tab_label return store, tab_label
def get_icon_grid_from_notebook(self, notebook, _name):
for obj in notebook.get_children():
icon_grid = obj.get_children()[0]
name = icon_grid.get_name()
if name == _name:
return icon_grid

View File

@ -1,5 +1,6 @@
# Python imports # Python imports
import os import os
import gc
# Lib imports # Lib imports
import gi import gi
@ -60,7 +61,7 @@ class TabMixin(GridMixin):
tid = self.get_id_from_tab_box(tab_box) tid = self.get_id_from_tab_box(tab_box)
scroll = self.builder.get_object(f"{wid}|{tid}") scroll = self.builder.get_object(f"{wid}|{tid}")
icon_grid = scroll.get_children()[0] icon_grid = scroll.get_children()[0]
store = icon_grid.get_model() store = icon_grid.get_store()
tab = self.get_fm_window(wid).get_tab_by_id(tid) tab = self.get_fm_window(wid).get_tab_by_id(tid)
watcher = tab.get_dir_watcher() watcher = tab.get_dir_watcher()
@ -83,6 +84,7 @@ class TabMixin(GridMixin):
del watcher del watcher
del tab del tab
gc.collect()
if not settings_manager.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
@ -199,7 +201,9 @@ class TabMixin(GridMixin):
if not tab.set_path(path): if not tab.set_path(path):
return return
self.update_tab(tab_label, tab, store, wid, tid) icon_grid = self.get_icon_grid_from_notebook(notebook, f"{wid}|{tid}")
icon_grid.clear_and_set_new_store()
self.update_tab(tab_label, tab, icon_grid.get_store(), wid, tid)
try: try:
widget.grab_focus_without_selecting() widget.grab_focus_without_selecting()

View File

@ -108,10 +108,9 @@ class WindowMixin(TabMixin):
self.execute_files() self.execute_files()
return return
state = self.get_current_state() state = self.get_current_state()
notebook = self.builder.get_object(f"window_{state.wid}") notebook = self.builder.get_object(f"window_{state.wid}")
tab_label = self.get_tab_label(notebook, icons_grid) tab_label = self.get_tab_label(notebook, state.icon_grid)
fileName = state.store[item][1] fileName = state.store[item][1]
dir = state.tab.get_current_directory() dir = state.tab.get_current_directory()
@ -119,7 +118,8 @@ class WindowMixin(TabMixin):
if isdir(file): if isdir(file):
state.tab.set_path(file) state.tab.set_path(file)
self.update_tab(tab_label, state.tab, state.store, state.wid, state.tid) state.icon_grid.clear_and_set_new_store()
self.update_tab(tab_label, state.tab, state.icon_grid.get_store(), state.wid, state.tid)
else: else:
event_system.emit("open_files") event_system.emit("open_files")
except WindowException as e: except WindowException as e:

View File

@ -20,7 +20,7 @@ class IconGridWidget(Gtk.IconView):
def __init__(self): def __init__(self):
super(IconGridWidget, self).__init__() super(IconGridWidget, self).__init__()
self._store = None # self._store = None
self._setup_styling() self._setup_styling()
self._setup_signals() self._setup_signals()
@ -62,8 +62,7 @@ class IconGridWidget(Gtk.IconView):
self.connect("drag-motion", grid_on_drag_motion) self.connect("drag-motion", grid_on_drag_motion)
def _load_widgets(self): def _load_widgets(self):
self._store = Gtk.ListStore(GdkPixbuf.Pixbuf or GdkPixbuf.PixbufAnimation or None, str or None) self.clear_and_set_new_store()
self.set_model(self._store)
def _set_up_dnd(self): def _set_up_dnd(self):
URI_TARGET_TYPE = 80 URI_TARGET_TYPE = 80
@ -75,4 +74,9 @@ class IconGridWidget(Gtk.IconView):
def get_store(self): def get_store(self):
return self._store return self.get_model()
def clear_and_set_new_store(self):
self.set_model(None)
store = Gtk.ListStore(GdkPixbuf.Pixbuf or GdkPixbuf.PixbufAnimation or None, str or None)
self.set_model(store)