idle_add refactor for event source clearing; Gtk main call moved
This commit is contained in:
@@ -41,13 +41,15 @@ class FileActionSignalsMixin:
|
||||
Gio.FileMonitorEvent.MOVED_OUT]:
|
||||
|
||||
if eve_type in [Gio.FileMonitorEvent.MOVED_IN, Gio.FileMonitorEvent.MOVED_OUT]:
|
||||
self.update_on_soft_lock_end(data[0])
|
||||
# self.update_on_soft_lock_end(data[0])
|
||||
GLib.Thread("", self.soft_lock_countdown, data[0])
|
||||
elif data[0] in self.soft_update_lock.keys():
|
||||
self.soft_update_lock[data[0]]["last_update_time"] = time.time()
|
||||
else:
|
||||
self.soft_lock_countdown(data[0])
|
||||
# self.soft_lock_countdown(data[0])
|
||||
GLib.Thread("", self.soft_lock_countdown, data[0])
|
||||
|
||||
@daemon_threaded
|
||||
# @daemon_threaded
|
||||
def soft_lock_countdown(self, tab_widget):
|
||||
self.soft_update_lock[tab_widget] = { "last_update_time": time.time()}
|
||||
|
||||
@@ -61,6 +63,8 @@ class FileActionSignalsMixin:
|
||||
|
||||
self.soft_update_lock.pop(tab_widget, None)
|
||||
GLib.idle_add(self.update_on_soft_lock_end, *(tab_widget,))
|
||||
thread = GLib.Thread.self()
|
||||
thread.unref()
|
||||
|
||||
|
||||
def update_on_soft_lock_end(self, tab_widget):
|
||||
|
||||
@@ -57,25 +57,32 @@ class GridMixin:
|
||||
else:
|
||||
asyncio.run( self.create_icons(tab, store, dir, files) )
|
||||
|
||||
thread = GLib.Thread.self()
|
||||
thread.unref()
|
||||
|
||||
async def create_icons(self, tab, store, dir, files):
|
||||
icons = [self.get_icon(tab, dir, file[0]) for file in files]
|
||||
data = await asyncio.gather(*icons)
|
||||
tasks = [self.update_store(i, store, icon) for i, icon in enumerate(data)]
|
||||
await asyncio.gather(*tasks)
|
||||
|
||||
GLib.idle_add(Gtk.main_iteration)
|
||||
GLib.idle_add(self.do_ui_update)
|
||||
|
||||
async def update_store(self, i, store, icon):
|
||||
itr = store.get_iter(i)
|
||||
GLib.idle_add(self.insert_store, store, itr, icon)
|
||||
|
||||
async def get_icon(self, tab, dir, file):
|
||||
return tab.create_icon(dir, file)
|
||||
|
||||
def insert_store(self, store, itr, icon):
|
||||
store.set_value(itr, 0, icon)
|
||||
# Note: If the function returns GLib.SOURCE_REMOVE or False it is automatically removed from the list of event sources and will not be called again.
|
||||
return False
|
||||
|
||||
async def get_icon(self, tab, dir, file):
|
||||
return tab.create_icon(dir, file)
|
||||
def do_ui_update(self):
|
||||
Gtk.main_iteration()
|
||||
return False
|
||||
|
||||
def create_tab_widget(self, tab):
|
||||
return TabHeaderWidget(tab, self.close_tab)
|
||||
|
||||
@@ -57,25 +57,32 @@ class GridMixin:
|
||||
else:
|
||||
asyncio.run( self.create_icons(tab, store, dir, files) )
|
||||
|
||||
thread = GLib.Thread.self()
|
||||
thread.unref()
|
||||
|
||||
async def create_icons(self, tab, store, dir, files):
|
||||
icons = [self.get_icon(tab, dir, file[0]) for file in files]
|
||||
data = await asyncio.gather(*icons)
|
||||
tasks = [self.update_store(i, store, icon) for i, icon in enumerate(data)]
|
||||
await asyncio.gather(*tasks)
|
||||
|
||||
GLib.idle_add(Gtk.main_iteration)
|
||||
GLib.idle_add(self.do_ui_update)
|
||||
|
||||
async def update_store(self, i, store, icon):
|
||||
itr = store.get_iter(i)
|
||||
GLib.idle_add(self.insert_store, store, itr, icon)
|
||||
|
||||
async def get_icon(self, tab, dir, file):
|
||||
return tab.create_icon(dir, file)
|
||||
|
||||
def insert_store(self, store, itr, icon):
|
||||
store.set_value(itr, 0, icon)
|
||||
# Note: If the function returns GLib.SOURCE_REMOVE or False it is automatically removed from the list of event sources and will not be called again.
|
||||
return False
|
||||
|
||||
async def get_icon(self, tab, dir, file):
|
||||
return tab.create_icon(dir, file)
|
||||
def do_ui_update(self):
|
||||
Gtk.main_iteration()
|
||||
return False
|
||||
|
||||
def create_tab_widget(self, tab):
|
||||
return TabHeaderWidget(tab, self.close_tab)
|
||||
|
||||
@@ -87,12 +87,14 @@ class Window(Gtk.ApplicationWindow):
|
||||
cr.set_operator(cairo.OPERATOR_SOURCE)
|
||||
cr.paint()
|
||||
cr.set_operator(cairo.OPERATOR_OVER)
|
||||
|
||||
|
||||
def _load_interactive_debug(self):
|
||||
self.set_interactive_debugging(True)
|
||||
|
||||
|
||||
def _tear_down(self, widget = None, eve = None):
|
||||
event_system.emit("shutting_down")
|
||||
settings_manager.clear_pid()
|
||||
Gtk.main_quit()
|
||||
Gtk.main_quit()
|
||||
|
||||
def main(self):
|
||||
Gtk.main()
|
||||
Reference in New Issue
Block a user