Attempting threaded thumbnailing update
This commit is contained in:
parent
0c5d179c1c
commit
f14058634c
@ -53,4 +53,4 @@ class Builtins:
|
||||
# NOTE: Just reminding myself we can add to builtins two different ways...
|
||||
# __builtins__.update({"event_system": Builtins()})
|
||||
builtins.event_system = Builtins()
|
||||
builtins.event_sleep_time = 1
|
||||
builtins.event_sleep_time = 0.2
|
||||
|
@ -152,6 +152,7 @@ class View(Settings, Launcher, Icon, Path):
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def get_gtk_icon_str_combo(self):
|
||||
data = []
|
||||
dir = self.get_current_directory()
|
||||
|
@ -8,7 +8,6 @@ from gi.repository import Gtk as gtk
|
||||
|
||||
# Application imports
|
||||
from .mixins import *
|
||||
# from pyfm.shellfm.windows import WindowController
|
||||
from shellfm import WindowController
|
||||
|
||||
|
||||
@ -35,12 +34,6 @@ class Signals(WindowMixin, PaneMixin):
|
||||
self.window4 = self.builder.get_object("window4")
|
||||
self.notebooks = [self.window1, self.window2, self.window3, self.window4]
|
||||
|
||||
event_system.push_gui_event(["update", "window_1", []])
|
||||
event_system.push_gui_event(["update", "window_2", []])
|
||||
event_system.push_fm_event(["update", "window_fm_1", []])
|
||||
event_system.push_fm_event(["update", "window_fm_2", []])
|
||||
|
||||
|
||||
self.single_click_open = False
|
||||
self.is_pane1_hidden = False
|
||||
self.is_pane2_hidden = False
|
||||
@ -60,7 +53,7 @@ class Signals(WindowMixin, PaneMixin):
|
||||
time.sleep(event_sleep_time)
|
||||
event = event_system.consume_gui_event()
|
||||
if event:
|
||||
print(event)
|
||||
type, target, data = event
|
||||
|
||||
|
||||
def tear_down(self, widget, eve):
|
||||
|
@ -27,10 +27,8 @@ class TabMixin(WidgetMixin):
|
||||
|
||||
tab = self.create_tab_widget(view)
|
||||
scroll, store = self.create_grid_iconview_widget(view, wid)
|
||||
index = notebook.append_page(scroll, tab)
|
||||
|
||||
# scroll, store = self.create_grid_treeview_widget(view, wid)
|
||||
self.load_store(view, store, save_state)
|
||||
index = notebook.append_page(scroll, tab)
|
||||
|
||||
self.window_controller.set_active_data(wid, view.get_tab_id())
|
||||
path_entry.set_text(view.get_current_directory())
|
||||
@ -39,6 +37,7 @@ class TabMixin(WidgetMixin):
|
||||
|
||||
# FIXME: set_tab_reorderable doesn't seem to work...
|
||||
# notebook.set_tab_reorderable(tab, True)
|
||||
self.load_store(view, store, save_state)
|
||||
|
||||
def close_tab(self, widget, eve):
|
||||
notebook = widget.get_parent().get_parent()
|
||||
|
@ -1,27 +1,67 @@
|
||||
# Python imports
|
||||
import threading, subprocess
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GLib
|
||||
from gi.repository import GdkPixbuf
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
|
||||
class WidgetMixin:
|
||||
# This feels ugly but I don't see a better option than itterating over the list.
|
||||
# @threaded
|
||||
# def load_store(self, view, store, save_state=True):
|
||||
# store.clear()
|
||||
# files = view.get_pixbuf_icon_str_combo()
|
||||
#
|
||||
# for data in files:
|
||||
# store.append(data)
|
||||
#
|
||||
# if save_state:
|
||||
# self.window_controller.save_state()
|
||||
|
||||
|
||||
|
||||
|
||||
def load_store(self, view, store, save_state=True):
|
||||
store.clear()
|
||||
files = view.get_pixbuf_icon_str_combo()
|
||||
|
||||
for data in files:
|
||||
store.append(data)
|
||||
files = view.get_files()
|
||||
dir = view.get_current_directory()
|
||||
for file in files:
|
||||
try:
|
||||
self.create_icon(view, store, dir, file[0])
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
if save_state:
|
||||
self.window_controller.save_state()
|
||||
|
||||
|
||||
@threaded
|
||||
def create_icon(self, view, store, dir, file):
|
||||
icon = view.create_icon(dir, file).get_pixbuf()
|
||||
data = [icon, file]
|
||||
GLib.idle_add(self.update_store, (store, data,))
|
||||
|
||||
def update_store(self, item):
|
||||
store, data = item
|
||||
store.append(data)
|
||||
|
||||
|
||||
|
||||
|
||||
def create_tab_widget(self, view):
|
||||
tab = Gtk.Box()
|
||||
label = Gtk.Label()
|
||||
|
Loading…
Reference in New Issue
Block a user