Changeset 80e56e
- Timestamp:
- 01/17/2014 10:51:54 PM (12 years ago)
- Branches:
- 2.0.x, develop, master
- Children:
- 01d2ef8
- Parents:
- 2b64d7
- git-author:
- bendikro <bendikro@gmail.com> (10/04/2013 09:44:17 AM)
- git-committer:
- Calum Lind <calumlind+deluge@gmail.com> (01/17/2014 10:51:54 PM)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/ui/gtkui/torrentview.py
r2b64d7 r80e56e 42 42 import gobject 43 43 import logging 44 import warnings45 44 46 45 from twisted.internet import reactor 47 46 48 47 import listview 49 import deluge.common50 48 import deluge.component as component 51 49 from deluge.ui.client import client … … 366 364 self.set_columns_to_update() 367 365 self.update_view(load_new_list=True) 366 self.select_first_row() 368 367 369 368 def stop(self): … … 398 397 see: core.get_torrents_status 399 398 """ 400 self.treeview.get_selection().unselect_all()401 399 search_filter = self.filter and self.filter.get('name', None) or None 402 400 self.filter = dict(filter_dict) # Copied version of filter_dict. 403 401 if search_filter and 'name' not in filter_dict: 404 402 self.filter['name'] = search_filter 405 self.update( )403 self.update(select_row=True) 406 404 407 405 def set_columns_to_update(self, columns=None): … … 429 427 return status_keys 430 428 431 def send_status_request(self, columns=None ):429 def send_status_request(self, columns=None, select_row=False): 432 430 # Store the 'status_fields' we need to send to core 433 431 status_keys = self.set_columns_to_update(columns) … … 442 440 # Request the statuses for all these torrent_ids, this is async so we 443 441 # will deal with the return in a signal callback. 444 component.get("SessionProxy").get_torrents_status(442 d = component.get("SessionProxy").get_torrents_status( 445 443 self.filter, status_keys).addCallback(self._on_get_torrents_status) 446 447 def update(self): 444 if select_row: 445 d.addCallback(self.select_first_row) 446 447 def select_first_row(self, ignored=None): 448 """ 449 Set the first row in the list selected if a selection does 450 not already exist 451 """ 452 rows = self.treeview.get_selection().get_selected_rows()[1] 453 # Only select row if noe rows are selected 454 if not rows: 455 self.treeview.get_selection().select_path((0,)) 456 457 def update(self, select_row=False): 458 """ 459 Sends a status request to core and updates the torrent list with the result. 460 461 :param select_row: if the first row in the list should be selected if 462 no rows are already selected. 463 :type select_row: boolean 464 465 """ 448 466 if self.got_state: 449 467 if self.search_box.search_pending is not None and self.search_box.search_pending.active(): … … 451 469 return 452 470 # Send a status request 453 gobject.idle_add(self.send_status_request )471 gobject.idle_add(self.send_status_request, None, select_row) 454 472 455 473 def update_view(self, load_new_list=False): … … 515 533 self.prev_status = status 516 534 517 def _on_get_torrents_status(self, status ):535 def _on_get_torrents_status(self, status, select_row=False): 518 536 """Callback function for get_torrents_status(). 'status' should be a 519 537 dictionary of {torrent_id: {key, value}}.""" … … 521 539 if self.search_box.prefiltered is not None: 522 540 self.search_box.prefiltered = None 541 523 542 if self.status == self.prev_status and self.prev_status: 524 543 # We do not bother updating since the status hasn't changed 525 544 self.prev_status = self.status 526 545 return 527 gobject.idle_add(self.update_view)546 self.update_view() 528 547 529 548 def add_rows(self, torrent_ids):
Note:
See TracChangeset
for help on using the changeset viewer.