[sugar] Notify active event firing

Benjamin M. Schwartz bmschwar
Sun Nov 4 01:45:23 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Arjun Sarwal wrote:
> I need to turn off some drawing code when the user switches to Home View
> (why waste so much of CPU power in the meanwhile)
> How can I do that ?

I just figured this out while writing Clock.  In my activity's __init__, I do:

        self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.connect("visibility-notify-event", self._visible_cb)

then later,

    def _visible_cb(self, widget, event):
        if event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED:
            self._innards.pause()
        else:
            self._innards.resume()

It works perfectly.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHLWoFUJT6e6HFtqQRAqymAKCWPL7JWKoF2U5s4peSynzJzGM0mgCeOnt4
i+BsLLgvgud2lvpQM6MSQeA=
=Cigo
-----END PGP SIGNATURE-----





More information about the Sugar-devel mailing list