mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-03 15:13:23 +00:00
Fix dialogs so that they do not run another gtk main loop, but rather run within the current
twisted mainloop
This commit is contained in:
parent
a82a5277a5
commit
e7158c499f
@ -33,8 +33,12 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
|
from twisted.internet import defer
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
|
||||||
|
|
||||||
class BaseDialog(gtk.Dialog):
|
class BaseDialog(gtk.Dialog):
|
||||||
"""
|
"""
|
||||||
Base dialog class that should be used with all dialogs.
|
Base dialog class that should be used with all dialogs.
|
||||||
@ -54,6 +58,9 @@ class BaseDialog(gtk.Dialog):
|
|||||||
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
|
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
|
||||||
buttons=buttons)
|
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
|
# Setup all the formatting and such to make our dialog look pretty
|
||||||
self.set_border_width(5)
|
self.set_border_width(5)
|
||||||
self.set_default_size(200, 100)
|
self.set_default_size(200, 100)
|
||||||
@ -78,11 +85,22 @@ class BaseDialog(gtk.Dialog):
|
|||||||
self.vbox.set_spacing(5)
|
self.vbox.set_spacing(5)
|
||||||
self.vbox.show_all()
|
self.vbox.show_all()
|
||||||
|
|
||||||
def run(self):
|
def _on_delete_event(self, widget, event):
|
||||||
# Destroy the dialog once we get a response and return it
|
self.deferred.callback(gtk.RESPONSE_DELETE_EVENT)
|
||||||
response = super(BaseDialog, self).run()
|
|
||||||
self.destroy()
|
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):
|
class YesNoDialog(BaseDialog):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user