[GTKUI] Restart application when switching modes
This commit is contained in:
parent
d0d070aaf0
commit
e31acfc31c
|
@ -257,12 +257,17 @@ class GtkUI(object):
|
||||||
# Shut down components
|
# Shut down components
|
||||||
yield self.shutdown()
|
yield self.shutdown()
|
||||||
|
|
||||||
# Modal dialogs can prevent the application exiting so destroy mainwindow
|
# The gtk modal dialogs (e.g. Preferences) can prevent the application
|
||||||
# Must do this here to avoid hang when closing with SIGINT (CTRL-C)
|
# quitting, so force exiting by destroying MainWindow. Must be done here
|
||||||
|
# to avoid hanging when quitting with SIGINT (CTRL-C).
|
||||||
self.mainwindow.window.destroy()
|
self.mainwindow.window.destroy()
|
||||||
|
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
|
|
||||||
|
# Restart the application after closing if MainWindow attribute set.
|
||||||
|
if component.get('MainWindow').restart:
|
||||||
|
os.execv(sys.argv[0], sys.argv)
|
||||||
|
|
||||||
def print_rpc_stats(self):
|
def print_rpc_stats(self):
|
||||||
if not client.connected():
|
if not client.connected():
|
||||||
return
|
return
|
||||||
|
|
|
@ -107,6 +107,7 @@ class MainWindow(component.Component):
|
||||||
# Keep track of window's minimization state so that we don't update the
|
# Keep track of window's minimization state so that we don't update the
|
||||||
# UI when it is minimized.
|
# UI when it is minimized.
|
||||||
self.is_minimized = False
|
self.is_minimized = False
|
||||||
|
self.restart = False
|
||||||
|
|
||||||
self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0, 80)], gtk.gdk.ACTION_COPY)
|
self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0, 80)], gtk.gdk.ACTION_COPY)
|
||||||
|
|
||||||
|
@ -200,15 +201,18 @@ class MainWindow(component.Component):
|
||||||
"""Returns a reference to the main window GTK builder object."""
|
"""Returns a reference to the main window GTK builder object."""
|
||||||
return self.main_builder
|
return self.main_builder
|
||||||
|
|
||||||
def quit(self, shutdown=False):
|
def quit(self, shutdown=False, restart=False):
|
||||||
"""
|
"""Quits the GtkUI application.
|
||||||
Quits the GtkUI
|
|
||||||
|
Args:
|
||||||
|
shutdown (bool): Whether or not to shutdown the daemon as well.
|
||||||
|
restart (bool): Whether or not to restart the application after closing.
|
||||||
|
|
||||||
:param shutdown: whether or not to shutdown the daemon as well
|
|
||||||
:type shutdown: boolean
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def quit_gtkui():
|
def quit_gtkui():
|
||||||
def stop_gtk_reactor(result=None):
|
def stop_gtk_reactor(result=None):
|
||||||
|
self.restart = restart
|
||||||
try:
|
try:
|
||||||
reactor.callLater(0, reactor.fireSystemEvent, 'gtkui_close')
|
reactor.callLater(0, reactor.fireSystemEvent, 'gtkui_close')
|
||||||
except ReactorNotRunning:
|
except ReactorNotRunning:
|
||||||
|
|
|
@ -701,16 +701,17 @@ class Preferences(component.Component):
|
||||||
shutdown_daemon = (not client.is_standalone() and
|
shutdown_daemon = (not client.is_standalone() and
|
||||||
client.connected() and
|
client.connected() and
|
||||||
client.is_localhost())
|
client.is_localhost())
|
||||||
component.get('MainWindow').quit(shutdown=shutdown_daemon)
|
component.get('MainWindow').quit(shutdown=shutdown_daemon, restart=True)
|
||||||
else:
|
else:
|
||||||
self.gtkui_config['standalone'] = not new_gtkui_standalone
|
self.gtkui_config['standalone'] = not new_gtkui_standalone
|
||||||
self.builder.get_object('radio_standalone').set_active(
|
self.builder.get_object('radio_standalone').set_active(
|
||||||
self.gtkui_config['standalone'])
|
self.gtkui_config['standalone'])
|
||||||
self.builder.get_object('radio_thinclient').set_active(
|
self.builder.get_object('radio_thinclient').set_active(
|
||||||
not self.gtkui_config['standalone'])
|
not self.gtkui_config['standalone'])
|
||||||
|
mode = 'Thinclient' if was_standalone else 'Standalone'
|
||||||
dialog = YesNoDialog(
|
dialog = YesNoDialog(
|
||||||
_('Switching client mode...'),
|
_('Switching Deluge Client Mode...'),
|
||||||
_('Your current session will be stopped. Do you wish to continue?')
|
_('Do you want to restart to use %s mode?' % mode)
|
||||||
)
|
)
|
||||||
dialog.run().addCallback(on_response)
|
dialog.run().addCallback(on_response)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue