Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Python widget: how to know when it is removed from desktop?

    Reply
    Slocan | # 1 | 2010-05-12, 16:20 | Report

    Here is the scenario:
    - Add a widget to home screen (python gtk widget)
    - Add a timeout_add_seconds function to trigger regular refreshes (check servers for rss updates)
    - Remove the widget from the home screen

    The problem when doing so, the widget stays in memory and the function keeps getting called.
    Is there a signal, or a property, that can be checked to make sure the widget is still on the home screen?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    qwerty12 | # 2 | 2010-05-13, 12:07 | Report

    Disclaimer: I'm **** at Python and I've never created a GObject in Python. I've made my fair share in (rather ****) C, though.

    In C, you'd remove timeout sources in the finalize/dispose function. In PyGObject, I have no idea how you override them. Probably due to Python's automatic memory management - after all, who needs to worry about this ****?!

    Anyway, gtk.Object offers a "destroy" signal. Guess what it does and when it's invoked

    Anyway, looking at http://sites.google.com/site/gobjecttutorial/#d0e754, here's my attempt:
    http://slexy.org/view/s2cDBWJkob

    It works, but there may be better ways of doing this.

    P.S. I don't know what this timer does, but if it's not needed when the focus is not on the desktop, connect to the "notify::is-on-current-desktop" signal.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by qwerty12; 2010-05-13 at 12:24.
    The Following 2 Users Say Thank You to qwerty12 For This Useful Post:
    krk969, Slocan

     
    Slocan | # 3 | 2010-05-13, 23:14 | Report

    Originally Posted by qwerty12 View Post
    Anyway, looking at http://sites.google.com/site/gobjecttutorial/#d0e754, here's my attempt:
    http://slexy.org/view/s2cDBWJkob
    That works perfectly! I added a:
    Code:
    hildondesktop.HomePluginItem.do_destroy(self)
    to make sure the original code is called too, although I don't know if it's actually needed.
    Thanks a bunch!

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Slocan For This Useful Post:
    qwerty12

     
vBulletin® Version 3.8.8
Normal Logout