Autoimport toggle button

This commit is contained in:
Matt Turnbull 2008-12-13 00:52:31 +00:00
parent ec7c21621d
commit cbac52ccbb

View File

@ -71,7 +71,8 @@ class GuiAutoImport (threading.Thread):
self.addSites(self.mainVBox)
self.startButton=gtk.Button("Start Autoimport")
self.doAutoImportBool = False
self.startButton=gtk.ToggleButton("Start Autoimport")
self.startButton.connect("clicked", self.startClicked, "start clicked")
self.mainVBox.add(self.startButton)
self.startButton.show()
@ -103,7 +104,7 @@ class GuiAutoImport (threading.Thread):
"""Callback for timer to do an import iteration."""
self.importer.runUpdated()
print "GuiAutoImport.import_dir done"
return True
return self.doAutoImportBool
def startClicked(self, widget, data):
"""runs when user clicks start on auto import tab"""
@ -117,6 +118,9 @@ class GuiAutoImport (threading.Thread):
# That is not correct. It should open another dir for importing while piping the
# results to the same pipe. This means that self.path should be a a list of dirs
# to watch.
if widget.get_active(): # toggled on
self.doAutoImportBool = True
widget.set_label(u'Stop Autoimport')
try: #uhhh, I don't this this is the best way to check for the existence of an attr
getattr(self, "pipe_to_hud")
except AttributeError:
@ -145,6 +149,11 @@ class GuiAutoImport (threading.Thread):
interval=int(self.intervalEntry.get_text())
gobject.timeout_add(interval*1000, self.do_import)
else: # toggled off
self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer
#TODO: other clean up, such as killing HUD
print "Stopping autoimport"
widget.set_label(u'Start Autoimport')
#end def GuiAutoImport.startClicked
def get_vbox(self):