Changeset e31acf


Ignore:
Timestamp:
11/04/2016 11:54:46 PM (9 years ago)
Author:
Calum Lind <calumlind+deluge@gmail.com>
Branches:
2.0.x, develop, master
Children:
0890cc
Parents:
d0d070
git-author:
Calum Lind <calumlind+deluge@gmail.com> (11/04/2016 11:36:33 PM)
git-committer:
Calum Lind <calumlind+deluge@gmail.com> (11/04/2016 11:54:46 PM)
Message:

[GTKUI] Restart application when switching modes

Location:
deluge/ui/gtkui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • deluge/ui/gtkui/gtkui.py

    rd0d070 re31acf  
    258258        yield self.shutdown()
    259259
    260         # Modal dialogs can prevent the application exiting so destroy mainwindow
    261         # Must do this here to avoid hang when closing with SIGINT (CTRL-C)
     260        # The gtk modal dialogs (e.g. Preferences) can prevent the application
     261        # quitting, so force exiting by destroying MainWindow. Must be done here
     262        # to avoid hanging when quitting with SIGINT (CTRL-C).
    262263        self.mainwindow.window.destroy()
    263264
    264265        reactor.stop()
     266
     267        # Restart the application after closing if MainWindow attribute set.
     268        if component.get('MainWindow').restart:
     269            os.execv(sys.argv[0], sys.argv)
    265270
    266271    def print_rpc_stats(self):
  • deluge/ui/gtkui/mainwindow.py

    rd0d070 re31acf  
    108108        # UI when it is minimized.
    109109        self.is_minimized = False
     110        self.restart = False
    110111
    111112        self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0, 80)], gtk.gdk.ACTION_COPY)
     
    201202        return self.main_builder
    202203
    203     def quit(self, shutdown=False):
     204    def quit(self, shutdown=False, restart=False):
     205        """Quits the GtkUI application.
     206
     207        Args:
     208            shutdown (bool): Whether or not to shutdown the daemon as well.
     209            restart (bool): Whether or not to restart the application after closing.
     210
    204211        """
    205         Quits the GtkUI
    206 
    207         :param shutdown: whether or not to shutdown the daemon as well
    208         :type shutdown: boolean
    209         """
     212
    210213        def quit_gtkui():
    211214            def stop_gtk_reactor(result=None):
     215                self.restart = restart
    212216                try:
    213217                    reactor.callLater(0, reactor.fireSystemEvent, 'gtkui_close')
  • deluge/ui/gtkui/preferences.py

    rd0d070 re31acf  
    702702                                       client.connected() and
    703703                                       client.is_localhost())
    704                     component.get('MainWindow').quit(shutdown=shutdown_daemon)
     704                    component.get('MainWindow').quit(shutdown=shutdown_daemon, restart=True)
    705705                else:
    706706                    self.gtkui_config['standalone'] = not new_gtkui_standalone
     
    709709                    self.builder.get_object('radio_thinclient').set_active(
    710710                        not self.gtkui_config['standalone'])
     711            mode = 'Thinclient' if was_standalone else 'Standalone'
    711712            dialog = YesNoDialog(
    712                 _('Switching client mode...'),
    713                 _('Your current session will be stopped. Do you wish to continue?')
     713                _('Switching Deluge Client Mode...'),
     714                _('Do you want to restart to use %s mode?' % mode)
    714715            )
    715716            dialog.run().addCallback(on_response)
Note: See TracChangeset for help on using the changeset viewer.