title: pygtk glib.timeout_add(): How to tell if timer not being destroyed?
body: <p>In my application I use a function to show GtkInfoBars with a timeout (as described <a href="https://stackoverflow.com/a/1309257/406281">https://stackoverflow.com/a/1309257/406281</a>) thanks to glib.timeout_add_seconds().</p>
  
  <p>I understand that glib.timeout_add_seconds() is supposed to set a function to be called at regular intervals until said function returns False.</p>
  
  <p>I'm not doing that, but everything works as expected. It's perfectly simple. Here's my code:</p>
  
  <pre><code>def infobar(self, message, msgtype=gtk.MESSAGE_INFO, timeout=5):
      bar = gtk.InfoBar()
      bar.set_message_type(msgtype)
      bar.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
      bar.connect("response", lambda *args: bar.hide())
      self.vb2.pack_end(bar, False, False)
      label = gtk.Label()
      label.set_markup(message)
      content = bar.get_content_area()
      content.add(label)
      label.show()
      bar.show()
      if timeout:
          glib.timeout_add_seconds(timeout, bar.hide)
  </code></pre>
  
  <p><strong>SO. Question time.</strong> Look at what I did in the last line. Simply put, is this okay? Will the timeout destroy itself after the second call to bar.hide() fails? Or am I accumulating extra neutered timeouts that will wake up every 5 seconds [technically] using up resources?</p>
  
  <hr>
  
  <p><em>As an addendum:</em></p>
  
  <p>If, as I suspect, this is bad, and I really do need to return False to destroy the timeouts, I need some help -- I can't figure out how to play around with the code in order to satisfy these conditions: I need to allow multiple InfoBars at the same time, with each still staying connected to their own timer and button-response signal (as the code is now) <strong>OR</strong> I need each new InfoBar to replace any previous one (I can't figure out how to do this without inheriting the timer from the previous InfoBar--it gets messy).</p>
  
  <p>Thanks for reading!</p>