Changeset 15e0e0
- Timestamp:
- 06/07/2017 11:36:09 AM (8 years ago)
- Branches:
- 2.0.x, develop, master
- Children:
- 29191e
- Parents:
- d47457
- git-author:
- Calum Lind <calumlind+deluge@gmail.com> (04/03/2017 11:06:04 AM)
- git-committer:
- Calum Lind <calumlind+deluge@gmail.com> (06/07/2017 11:36:09 AM)
- Location:
- deluge/ui/console
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/ui/console/cmdline/commands/quit.py
rd47457 r15e0e0 11 11 from __future__ import unicode_literals 12 12 13 from twisted.internet import error, reactor 14 15 from deluge.ui.client import client 13 import deluge.component as component 16 14 17 15 from . import BaseCommand … … 24 22 25 23 def handle(self, options): 26 if client.connected(): 27 def on_disconnect(result): 28 reactor.stop() 29 return client.disconnect().addCallback(on_disconnect) 30 else: 31 try: 32 reactor.stop() 33 except error.ReactorNotRunning: 34 pass 24 component.get('ConsoleUI').quit() -
deluge/ui/console/main.py
rd47457 r15e0e0 17 17 import time 18 18 19 from twisted.internet import defer, reactor19 from twisted.internet import defer, error, reactor 20 20 21 21 import deluge.common … … 156 156 curses.wrapper(self.run) 157 157 158 def quit(self): 159 if client.connected(): 160 def on_disconnect(result): 161 reactor.stop() 162 return client.disconnect().addCallback(on_disconnect) 163 else: 164 try: 165 reactor.stop() 166 except error.ReactorNotRunning: 167 pass 168 158 169 def exec_args(self, options): 159 170 """Execute console commands from command line.""" -
deluge/ui/console/modes/addtorrents.py
rd47457 r15e0e0 451 451 return 452 452 453 if util.is_printable_ch ar(c):453 if util.is_printable_chr(c): 454 454 if chr(c) == 'Q': 455 from twisted.internet import reactor 456 if client.connected(): 457 def on_disconnect(result): 458 reactor.stop() 459 client.disconnect().addCallback(on_disconnect) 460 else: 461 reactor.stop() 462 return 455 component.get('ConsoleUI').quit() 463 456 elif chr(c) == 'q': 464 457 self.back_to_overview() … … 488 481 self.back_to_overview() 489 482 else: 490 if util.is_printable_ch ar(c):483 if util.is_printable_chr(c): 491 484 if chr(c) == 'h': 492 485 self.popup = MessagePopup(self, 'Help', HELP_STR, width_req=0.75) -
deluge/ui/console/modes/connectionmanager.py
rd47457 r15e0e0 14 14 import deluge.component as component 15 15 from deluge.decorators import overrides 16 from deluge.ui.client import client17 16 from deluge.ui.console.modes.basemode import BaseMode 17 from deluge.ui.console.utils.curses_util import is_printable_chr 18 18 from deluge.ui.console.widgets.popup import InputPopup, PopupsHandler, SelectablePopup 19 19 from deluge.ui.hostlist import HostList … … 39 39 40 40 def update_select_host_popup(self): 41 selected_index = None 42 if self.popup: 43 selected_index = self.popup.current_selection() 41 selected_index = self.popup.current_selection() if self.popup else None 44 42 45 popup = SelectablePopup(self, _('Select Host'), self._host_selected, border_off_west=1, active_wrap=True) 46 popup.add_header("{!white,black,bold!}'Q'=%s, 'a'=%s, 'D'=%s" % 47 (_('Quit'), _('Add New Host'), _('Delete Host')), 48 space_below=True) 43 popup = SelectablePopup( 44 self, _('Select Host'), self._host_selected, border_off_west=1, active_wrap=True) 45 popup.add_header( 46 "{!white,black,bold!}'Q'=%s, 'a'=%s, 'D'=%s" % 47 (_('Quit'), _('Add Host'), _('Delete Host')), space_below=True) 49 48 self.push_popup(popup, clear=True) 50 49 … … 59 58 self.popup.add_line(host_id, host_str, selectable=True, use_underline=True, **args) 60 59 61 if selected_index is not None:60 if selected_index: 62 61 self.popup.set_selection(selected_index) 63 62 self.inlist = True … … 65 64 66 65 def update_hosts_status(self): 67 68 66 for host_entry in self.hostlist.get_hosts_info(): 69 67 def on_host_status(status_info): 70 68 self.statuses[status_info[0]] = status_info 71 69 self.update_select_host_popup() 72 73 70 self.hostlist.get_host_status(host_entry[0]).addCallback(on_host_status) 74 71 75 72 def _on_connected(self, result): 76 d = component.get('ConsoleUI').start_console()77 78 73 def on_console_start(result): 79 74 component.get('ConsoleUI').set_mode('TorrentList') 75 d = component.get('ConsoleUI').start_console() 80 76 d.addCallback(on_console_start) 81 77 … … 101 97 def add_popup(self): 102 98 self.inlist = False 103 popup = InputPopup(self, _('Add Host (Up & Down arrows to navigate, Esc to cancel)'), 104 border_off_north=1, border_off_east=1, 105 close_cb=self._do_add) 99 popup = InputPopup( 100 self, 101 _('Add Host (Up & Down arrows to navigate, Esc to cancel)'), 102 border_off_north=1, 103 border_off_east=1, 104 close_cb=self._do_add) 106 105 popup.add_text_input('hostname', _('Hostname:')) 107 106 popup.add_text_input('port', _('Port:')) … … 112 111 113 112 def add_host(self, hostname, port, username, password): 113 log.info('Adding host: %s', hostname) 114 114 try: 115 115 self.hostlist.add_host(hostname, port, username, password) 116 116 except ValueError as ex: 117 self.report_message(_('Error adding host'), '%s' % ex) 118 return 117 self.report_message(_('Error adding host'), '%s: %s' % (hostname, ex)) 119 118 else: 120 119 self.update_select_host_popup() 121 120 122 121 def delete_host(self, host_id): 123 log. debug('deleting host: %s', host_id)122 log.info('Deleting host: %s', host_id) 124 123 self.hostlist.remove_host(host_id) 125 124 self.update_select_host_popup() … … 172 171 c = self.stdscr.getch() 173 172 174 if c > 31 and c < 256: 175 if chr(c) == 'q' and self.inlist: 176 return 173 if is_printable_chr(c): 177 174 if chr(c) == 'Q': 178 from twisted.internet import reactor 179 if client.connected(): 180 def on_disconnect(result): 181 reactor.stop() 182 client.disconnect().addCallback(on_disconnect) 183 else: 184 reactor.stop() 185 return 186 if chr(c) == 'D' and self.inlist: 187 host_id = self.popup.current_selection()[1] 188 self.delete_host(host_id) 189 return 190 if chr(c) == 'a' and self.inlist: 191 self.add_popup() 192 return 175 component.get('ConsoleUI').quit() 176 elif self.inlist: 177 if chr(c) == 'q': 178 return 179 elif chr(c) == 'D': 180 host_id = self.popup.current_selection()[1] 181 self.delete_host(host_id) 182 return 183 elif chr(c) == 'a': 184 self.add_popup() 185 return 193 186 194 187 if self.popup: … … 196 189 self.pop_popup() 197 190 self.refresh() 198 return -
deluge/ui/console/modes/preferences/preferences.py
rd47457 r15e0e0 293 293 return 294 294 295 if util.is_printable_char(c): 296 if chr(c) == 'Q': 297 from twisted.internet import reactor 298 if client.connected(): 299 def on_disconnect(result): 300 reactor.stop() 301 client.disconnect().addCallback(on_disconnect) 302 else: 303 reactor.stop() 304 return 305 elif chr(c) == 'h': 295 if util.is_printable_chr(c): 296 char = chr(c) 297 if char == 'Q': 298 component.get('ConsoleUI').quit() 299 elif char == 'h': 306 300 self.push_popup(MessagePopup(self, 'Preferences Help', HELP_STR)) 307 301 -
deluge/ui/console/modes/torrentlist/torrentlist.py
rd47457 r15e0e0 260 260 self.refresh() 261 261 return ret 262 if util.is_printable_ch ar(c):262 if util.is_printable_chr(c): 263 263 if chr(c) == 'Q': 264 from twisted.internet import reactor 265 if client.connected(): 266 def on_disconnect(result): 267 reactor.stop() 268 client.disconnect().addCallback(on_disconnect) 269 else: 270 reactor.stop() 271 return 264 component.get('ConsoleUI').quit() 272 265 elif chr(c) == 'C': 273 266 self.consoleui.set_mode('ConnectionManager') … … 313 306 return 314 307 315 elif util.is_printable_ch ar(c):308 elif util.is_printable_chr(c): 316 309 if chr(c) == 'a': 317 310 show_torrent_add_popup(self) -
deluge/ui/console/utils/curses_util.py
rd47457 r15e0e0 32 32 33 33 34 def is_printable_ch ar(c):34 def is_printable_chr(c): 35 35 return c >= 32 and c <= 126 36 36 -
deluge/ui/console/widgets/fields.py
rd47457 r15e0e0 850 850 def search_handler(key): 851 851 """Handle keyboard input to seach the list""" 852 if not util.is_printable_ch ar(key):852 if not util.is_printable_chr(key): 853 853 return 854 854 selected = select_popup.current_selection()
Note:
See TracChangeset
for help on using the changeset viewer.