Skip to content

Commit

Permalink
run callback when GLib is idle
Browse files Browse the repository at this point in the history
  • Loading branch information
graphicore committed Oct 21, 2013
1 parent fcf35da commit fa3ca58
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gtk_inks_editor.py
Expand Up @@ -23,7 +23,7 @@
import os
from weakref import ref as weakref

from gi.repository import Gtk, Gdk, GObject, GdkPixbuf, Pango
from gi.repository import Gtk, Gdk, GObject, GdkPixbuf, Pango, GLib
import cairo

from gtk_curve_editor import CurveEditor
Expand Down Expand Up @@ -139,12 +139,15 @@ def _update_surface(self, weakref_model):
state['update_needed'] = weakref_model
return False
state['waiting'] = True
callback = (self._receive_surface, iid)
callback = (self._worker_callback, iid)
self._gradient_worker.add_job(callback, ink_model)

# this timout shall not be executed repeatedly, thus returning false
return False

def _worker_callback(self, *args):
GLib.idle_add(self._receive_surface, *args)

def _receive_surface(self, iid, w, h, rowstride, buf):
if iid not in self.state:
return
Expand Down Expand Up @@ -258,12 +261,15 @@ def _update_surface(self, weakref_model):

self._waiting = True

callback = (self._receive_surface, )
callback = (self._worker_callback, )
self._gradient_worker.add_job(callback, *inks_model.visible_curves)

# this timout shall not be executed repeatedly, thus returning false
return False

def _worker_callback(self, *args):
GLib.idle_add(self._receive_surface, *args)

def _receive_surface(self, w, h, rowstride, buf):
if self._no_inks:
# this may receive a surface after all inks are invisible
Expand Down

0 comments on commit fa3ca58

Please sign in to comment.