Returned instant update of the Peers and Files tabs when user clicks on

torrent. Needs testing.
This commit is contained in:
Alex Dedul 2007-08-06 01:53:59 +00:00
parent 3210066d6b
commit faf5fe5e44
2 changed files with 22 additions and 12 deletions

View File

@ -161,7 +161,7 @@ class DelugeGTK:
def notebook_switch_page(self, notebook, page, page_num): def notebook_switch_page(self, notebook, page, page_num):
# Force an update when user changes the notebook tab # Force an update when user changes the notebook tab
self.update_torrent_info_widget(None, page_num) self.update_torrent_info_widget(page_num)
def pause_all_clicked(self, arg=None): def pause_all_clicked(self, arg=None):
self.manager.pause_all() self.manager.pause_all()
@ -569,9 +569,16 @@ class DelugeGTK:
# Torrent is already selected, we don't need to do anything # Torrent is already selected, we don't need to do anything
return True return True
unique_id = model.get_value(model.get_iter(path), 0) # We don't call update function directly, because torrent_clicked()
self.update_torrent_info_widget(unique_id) # called by GTK when torrent is not selected yet(read docs on
self.plugins.update_active_plugins() # gtk.TreeSelection.set_select_function()), but update routines
# expect already selected torrent. So queue update functions until we
# exit from torrent_clicked() and torrent will be actually selected by
# the time update functions called. Hope 10ms will be always enough
# for this.
gobject.timeout_add(10, self.update_torrent_info_widget)
gobject.timeout_add(10, self.plugins.update_active_plugins)
return True return True
def torrent_view_clicked(self, widget, event): def torrent_view_clicked(self, widget, event):
@ -899,8 +906,7 @@ class DelugeGTK:
selection_count = 1 selection_count = 1
if selection_count == 1: if selection_count == 1:
unique_id = self.get_selected_torrent() self.update_torrent_info_widget()
self.update_torrent_info_widget(unique_id)
else: # selection_count > 1 else: # selection_count > 1
self.clear_details_pane() self.clear_details_pane()
@ -948,12 +954,8 @@ class DelugeGTK:
self.tray_icon.set_tooltip(msg) self.tray_icon.set_tooltip(msg)
def update_torrent_info_widget(self, unique_id=None, page_num=None): def update_torrent_info_widget(self, page_num=None):
# Usually we don't need to pass unique_id, but there are a special unique_id = self.get_selected_torrent()
# cases like with self.torrent_clicked() and because of them we have
# unique_id param
if unique_id is None:
unique_id = self.get_selected_torrent()
# If no torrents added # If no torrents added
if unique_id is None: if unique_id is None:
return return
@ -964,6 +966,10 @@ class DelugeGTK:
if page_num == 0: # Details if page_num == 0: # Details
self.tab_details.update(unique_id) self.tab_details.update(unique_id)
# We have to return False here to stop calling this function by timer
# over and over again, from self.torrent_clicked() for example.
return False
# Return the id of the last single selected torrent # Return the id of the last single selected torrent
def get_selected_torrent(self): def get_selected_torrent(self):
try: try:

View File

@ -99,6 +99,10 @@ class PluginManager:
if 'update' in dir(plugin): if 'update' in dir(plugin):
plugin.update() plugin.update()
# We have to return False here to stop calling this function by timer
# over and over again, from interface.torrent_clicked() for example.
return False
def shutdown_all_plugins(self): def shutdown_all_plugins(self):
for name in self.enabled_plugins.keys(): for name in self.enabled_plugins.keys():
self.disable_plugin(name) self.disable_plugin(name)