Author: andar
Revision: 5380
Log:
Fix dialogs so that they do not run another gtk main loop, but rather
run within the current
twisted mainloop
Diff:
Modified: trunk/deluge/ui/gtkui/dialogs.py
===================================================================
--- trunk/deluge/ui/gtkui/dialogs.py 2009-06-10 20:18:22 UTC (rev 5379)
+++ trunk/deluge/ui/gtkui/dialogs.py 2009-06-10 22:23:49 UTC (rev 5380)
@@ -33,8 +33,12 @@
#
import gtk
+
+from twisted.internet import defer
+
import deluge.component as component
+
class BaseDialog(gtk.Dialog):
"""
Base dialog class that should be used with all dialogs.
@@ -54,6 +58,9 @@
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT |
gtk.DIALOG_NO_SEPARATOR,
buttons=buttons)
+ self.connect("delete-event", self._on_delete_event)
+ self.connect("response", self._on_response)
+
# Setup all the formatting and such to make our dialog look pretty
self.set_border_width(5)
self.set_default_size(200, 100)
@@ -78,12 +85,23 @@
self.vbox.set_spacing(5)
self.vbox.show_all()
- def run(self):
- # Destroy the dialog once we get a response and return it
- response = super(BaseDialog, self).run()
+ def _on_delete_event(self, widget, event):
+ self.deferred.callback(gtk.RESPONSE_DELETE_EVENT)
self.destroy()
- return response
+ def _on_response(self, widget, response):
+ self.deferred.callback(response)
+ self.destroy()
+
+ def run(self):
+ """
+ Shows the dialog and returns a Deferred object. The deferred, when
fired
+ will contain the response ID.
+ """
+ self.deferred = defer.Deferred()
+ self.show()
+ return self.deferred
+
class YesNoDialog(BaseDialog):
"""
Displays a dialog asking the user to select Yes or No to a question.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---