develop #11

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

View File

@ -60,9 +60,11 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkLabel" id="current_dir_lbl"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property> <property name="margin-start">5</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">5</property> <property name="margin-top">5</property>
@ -76,6 +78,22 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="current_dir_lbl">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="justify">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
@ -91,7 +109,7 @@
<object class="GtkTreeSelection"/> <object class="GtkTreeSelection"/>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkTreeViewColumn" id="du_tree_view">
<property name="title" translatable="yes">Disk Usage</property> <property name="title" translatable="yes">Disk Usage</property>
<child> <child>
<object class="GtkCellRendererText"/> <object class="GtkCellRendererText"/>
@ -113,7 +131,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@ -33,9 +33,13 @@ class Plugin(PluginBase):
self._connect_builder_signals(self, self._builder) self._connect_builder_signals(self, self._builder)
self._du_dialog = self._builder.get_object("du_dialog") self._du_dialog = self._builder.get_object("du_dialog")
self._du_tree_view = self._builder.get_object("du_tree_view")
self._du_store = self._builder.get_object("du_store") self._du_store = self._builder.get_object("du_store")
self._current_dir_lbl = self._builder.get_object("current_dir_lbl") self._current_dir_lbl = self._builder.get_object("current_dir_lbl")
self._current_dir_lbl.set_line_wrap(False)
self._current_dir_lbl.set_ellipsize(1) # NONE = 0¶, START = 1¶, MIDDLE = 2¶, END = 3¶
self._event_system.subscribe("show_du_menu", self._show_du_menu) self._event_system.subscribe("show_du_menu", self._show_du_menu)
def generate_reference_ui_element(self): def generate_reference_ui_element(self):
@ -49,7 +53,9 @@ class Plugin(PluginBase):
self._event_system.emit("get_current_state") self._event_system.emit("get_current_state")
def _set_current_dir_lbl(self, widget=None, eve=None): def _set_current_dir_lbl(self, widget=None, eve=None):
self._current_dir_lbl.set_label(f"Current Directory:\n{self._fm_state.tab.get_current_directory()}") path = self._fm_state.tab.get_current_directory()
self._current_dir_lbl.set_label(path)
self._current_dir_lbl.set_tooltip_text(path)
def _show_du_menu(self, widget=None, eve=None): def _show_du_menu(self, widget=None, eve=None):
self._fm_state = None self._fm_state = None
@ -72,7 +78,7 @@ class Plugin(PluginBase):
# NOTE: Last entry is curret dir. Move to top of list and pop off... # NOTE: Last entry is curret dir. Move to top of list and pop off...
size, file = parts[-1].split("\t") size, file = parts[-1].split("\t")
self._du_store.append([size, file.split("/")[-1]]) self._du_tree_view.set_title(f"Disk Usage: {file.split('/')[-1]} ( {size} )")
parts.pop() parts.pop()
for part in parts: for part in parts:

View File

@ -39,19 +39,21 @@ class Plugin(PluginBase):
trash_a = Gtk.MenuItem("Trash Actions") trash_a = Gtk.MenuItem("Trash Actions")
trash_menu = Gtk.Menu() trash_menu = Gtk.Menu()
self.restore = Gtk.MenuItem("Restore From Trash") self.restore = Gtk.ImageMenuItem("Restore From Trash")
self.restore.set_image( Gtk.Image.new_from_icon_name("gtk-undelete", 3) )
self.restore.connect("activate", self.restore_trash_files) self.restore.connect("activate", self.restore_trash_files)
self.empty = Gtk.MenuItem("Empty Trash") self.empty = Gtk.ImageMenuItem("Empty Trash")
self.empty.set_image( Gtk.Image.new_from_icon_name("gtk-delete", 3) )
self.empty.connect("activate", self.empty_trash) self.empty.connect("activate", self.empty_trash)
trash = Gtk.ImageMenuItem("Trash") trash = Gtk.ImageMenuItem("Trash")
trash.set_image( Gtk.Image.new_from_icon_name("user-trash", 16) ) trash.set_image( Gtk.Image.new_from_icon_name("user-trash", 3) )
trash.connect("activate", self.trash_files) trash.connect("activate", self.trash_files)
trash.set_always_show_image(True) trash.set_always_show_image(True)
go_to = Gtk.ImageMenuItem("Go To Trash") go_to = Gtk.ImageMenuItem("Go To Trash")
go_to.set_image( Gtk.Image.new_from_icon_name("user-trash", 16) ) go_to.set_image( Gtk.Image.new_from_icon_name("gtk-go-forward", 3) )
go_to.connect("activate", self.go_to_trash) go_to.connect("activate", self.go_to_trash)
go_to.set_always_show_image(True) go_to.set_always_show_image(True)

View File

@ -47,6 +47,8 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
event_system.subscribe("paste_files", self.paste_files) event_system.subscribe("paste_files", self.paste_files)
event_system.subscribe("move_files", self.move_files) event_system.subscribe("move_files", self.move_files)
event_system.subscribe("copy_name", self.copy_name) 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("create_files", self.create_files)
event_system.subscribe("rename_files", self.rename_files) event_system.subscribe("rename_files", self.rename_files)
@ -79,8 +81,16 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
def copy_path(self): def copy_path(self):
state = event_system.emit_and_await("get_current_state") state = event_system.emit_and_await("get_current_state")
dir = state.tab.get_current_directory() path = state.tab.get_current_directory()
event_system.emit("set_clipboard_data", (file_name,)) 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): def open_files(self):
state = event_system.emit_and_await("get_current_state") state = event_system.emit_and_await("get_current_state")

View File

@ -14,11 +14,10 @@ from ...widgets.icon_tree_widget import IconTreeWidget
class GridMixin: class GridMixin:
"""docstring for 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() store.clear()
dir = tab.get_current_directory() dir = tab.get_current_directory()
files = tab.get_files() files = tab.get_files()
@ -27,6 +26,12 @@ class GridMixin:
store.append([None, file[0]]) store.append([None, file[0]])
Gtk.main_iteration() Gtk.main_iteration()
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): for i, file in enumerate(files):
self.create_icon(i, tab, store, dir, file[0]) self.create_icon(i, tab, store, dir, file[0])
@ -34,12 +39,20 @@ class GridMixin:
if save_state and not trace_debug: if save_state and not trace_debug:
self.fm_controller.save_state() 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 @daemon_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,)) 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): def update_store(self, i, store, icon):
itr = store.get_iter(i) itr = store.get_iter(i)
store.set_value(itr, 0, icon) store.set_value(itr, 0, icon)

View File

@ -50,8 +50,6 @@ class TabMixin(GridMixin):
self.set_file_watcher(tab) self.set_file_watcher(tab)
def close_tab(self, button, eve = None): def close_tab(self, button, eve = None):
notebook = button.get_parent().get_parent() notebook = button.get_parent().get_parent()
if notebook.get_n_pages() == 1: if notebook.get_n_pages() == 1:
@ -63,7 +61,6 @@ class TabMixin(GridMixin):
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_model()
page_num = notebook.page_num(scroll)
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()
@ -71,12 +68,14 @@ class TabMixin(GridMixin):
self.get_fm_window(wid).delete_tab_by_id(tid) self.get_fm_window(wid).delete_tab_by_id(tid)
store.clear() store.clear()
# store.run_dispose()
icon_grid.destroy() icon_grid.destroy()
# icon_grid.run_dispose()
scroll.destroy() scroll.destroy()
scroll.run_dispose()
tab_box.destroy() tab_box.destroy()
notebook.remove_page(page_num) tab_box.run_dispose()
del page_num
del store del store
del icon_grid del icon_grid
del scroll del scroll

View File

@ -14,11 +14,10 @@ from ...widgets.icon_tree_widget import IconTreeWidget
class GridMixin: class GridMixin:
"""docstring for 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() store.clear()
dir = tab.get_current_directory() dir = tab.get_current_directory()
files = tab.get_files() files = tab.get_files()
@ -27,6 +26,12 @@ class GridMixin:
store.append([None, file[0]]) store.append([None, file[0]])
Gtk.main_iteration() Gtk.main_iteration()
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): for i, file in enumerate(files):
self.create_icon(i, tab, store, dir, file[0]) self.create_icon(i, tab, store, dir, file[0])
@ -34,12 +39,20 @@ class GridMixin:
if save_state and not trace_debug: if save_state and not trace_debug:
self.fm_controller.save_state() 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 @daemon_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,)) 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): def update_store(self, i, store, icon):
itr = store.get_iter(i) itr = store.get_iter(i)
store.set_value(itr, 0, icon) store.set_value(itr, 0, icon)

View File

@ -63,23 +63,21 @@ class TabMixin(GridMixin):
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_model()
page_num = notebook.page_num(scroll)
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()
watcher.cancel() watcher.cancel()
self.get_fm_window(wid).delete_tab_by_id(tid) self.get_fm_window(wid).delete_tab_by_id(tid)
icon_grid = scroll.get_children()[0]
store = icon_grid.get_model()
store.clear() store.clear()
store.run_dispose()
icon_grid.destroy() icon_grid.destroy()
icon_grid.run_dispose()
scroll.destroy() scroll.destroy()
scroll.run_dispose()
tab_box.destroy() tab_box.destroy()
notebook.remove_page(page_num) tab_box.run_dispose()
del page_num
del store del store
del icon_grid del icon_grid
del scroll del scroll
@ -89,6 +87,7 @@ class TabMixin(GridMixin):
if not settings.is_trace_debug(): if not settings.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
self.set_window_title() self.set_window_title()
# NOTE: Not actually getting called even tho set in the glade file... # NOTE: Not actually getting called even tho set in the glade file...

View File

@ -50,7 +50,7 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
if not thumbnl: if not thumbnl:
# TODO: Detect if not in a thread and use directly for speed get_system_thumbnail # 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]) thumbnl = self._get_system_thumbnail_gtk_thread(full_path, self.sys_icon_wh[0])
if not thumbnl: if not thumbnl:
raise IconException("No known icons found.") raise IconException("No known icons found.")

View File

@ -11,6 +11,8 @@
"Cut": ["STOCK_CUT", "cut"], "Cut": ["STOCK_CUT", "cut"],
"Copy": ["STOCK_COPY", "copy"], "Copy": ["STOCK_COPY", "copy"],
"Copy Name": ["STOCK_COPY", "copy_name"], "Copy Name": ["STOCK_COPY", "copy_name"],
"Copy Path": ["STOCK_COPY", "copy_path"],
"Copy Path+Name": ["STOCK_COPY", "copy_path_name"],
"Paste": ["STOCK_PASTE", "paste"] "Paste": ["STOCK_PASTE", "paste"]
}, },
"Plugins": {} "Plugins": {}