gget r49 - trunk/gget
- From: johans svn gnome org
- To: svn-commits-list gnome org
- Subject: gget r49 - trunk/gget
- Date: Mon, 4 Aug 2008 12:47:15 +0000 (UTC)
Author: johans
Date: Mon Aug 4 12:47:15 2008
New Revision: 49
URL: http://svn.gnome.org/viewvc/gget?rev=49&view=rev
Log:
Only enable the clear toolbutton when there are completed downloads in the list.
Modified:
trunk/gget/MainWindow.py
Modified: trunk/gget/MainWindow.py
==============================================================================
--- trunk/gget/MainWindow.py (original)
+++ trunk/gget/MainWindow.py Mon Aug 4 12:47:15 2008
@@ -465,7 +465,6 @@
"""Called when a new download is added to the model."""
number_rows = len(model)
if number_rows == 1:
- self.clear_tool_button.set_sensitive(True)
self.select_all_menu_item.set_sensitive(True)
def __downloads_treeview_selection_changed(self, selection):
@@ -796,17 +795,34 @@
download.connect("status-changed", self.__download_status_changed)
GUI.queue_resize(self.downloads_treeview)
+ # Enable clear button if necessary
+ if not self.clear_tool_button.props.sensitive and download.status == \
+ Download.COMPLETED:
+ self.clear_tool_button.set_sensitive(True)
+
def __download_removed(self, download_list, download):
"""Called when a download is removed from DownloadList. Removes the
- download from the treeview model."""
+ download from the treeview model. Also checks if there a any completed
+ downloads in the list so the clear button can be enabled/disabled
+ appropriately."""
downloads_iter = self.downloads_model.get_iter_first()
+ has_completed = False
+ iter_to_remove = None
for row in self.downloads_model:
+ if row[0].status == Download.COMPLETED:
+ has_completed = True
+
if row[0] is download:
- self.downloads_model.remove(downloads_iter)
- GUI.queue_resize(self.downloads_treeview)
- break
+ iter_to_remove = downloads_iter
+
downloads_iter = self.downloads_model.iter_next(downloads_iter)
+ if iter_to_remove:
+ self.downloads_model.remove(iter_to_remove)
+ GUI.queue_resize(self.downloads_treeview)
+
+ self.clear_tool_button.props.sensitive = has_completed
+
def __download_update(self, download, block_count, block_size, total_size):
"""Called on download updates. Finds the associated treeview row and
fires a row changed signal."""
@@ -816,6 +832,12 @@
"""Called when the status of a download changes. Tells the treeview to
update the row with that download."""
self.__downloads_treeview_selection_changed(self.downloads_treeview_selection)
+
+ # Enable clear button if necessary
+ if not self.clear_tool_button.props.sensitive and status == \
+ Download.COMPLETED:
+ self.clear_tool_button.set_sensitive(True)
+
self.update_download_row(download)
def update_download_row(self, download):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]