gget r31 - in trunk: data gget
- From: johans svn gnome org
- To: svn-commits-list gnome org
- Subject: gget r31 - in trunk: data gget
- Date: Sat, 12 Jul 2008 15:14:15 +0000 (UTC)
Author: johans
Date: Sat Jul 12 15:14:15 2008
New Revision: 31
URL: http://svn.gnome.org/viewvc/gget?rev=31&view=rev
Log:
Added remove and clear buttons for removing download/completed downloads. Need to update the backend to be able to actually stop a download if its active when removed.
Modified:
trunk/data/gget.glade
trunk/gget/DownloadList.py
trunk/gget/MainWindow.py
Modified: trunk/data/gget.glade
==============================================================================
--- trunk/data/gget.glade (original)
+++ trunk/data/gget.glade Sat Jul 12 15:14:15 2008
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Fri Jul 11 23:36:25 2008 -->
+<!--Generated with glade3 3.4.5 on Sat Jul 12 15:42:09 2008 -->
<glade-interface>
<widget class="GtkWindow" id="main_window">
<property name="width_request">800</property>
@@ -206,6 +206,25 @@
<property name="expand">False</property>
</packing>
</child>
+ <child>
+ <widget class="GtkToolButton" id="remove_tool_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="stock_id">gtk-remove</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkToolButton" id="clear_tool_button">
+ <property name="visible">True</property>
+ <property name="stock_id">gtk-clear</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -306,25 +325,16 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
- <widget class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_URL:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">url_entry</property>
- </widget>
- <packing>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry" id="url_entry">
+ <widget class="GtkFileChooserButton" id="download_filechooserbutton">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
+ <property name="title" translatable="yes">Select download folder</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
</packing>
</child>
<child>
@@ -342,16 +352,25 @@
</packing>
</child>
<child>
- <widget class="GtkFileChooserButton" id="download_filechooserbutton">
+ <widget class="GtkEntry" id="url_entry">
<property name="visible">True</property>
- <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
- <property name="title" translatable="yes">Select download folder</property>
+ <property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_URL:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">url_entry</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
@@ -636,8 +655,8 @@
<widget class="GtkFileChooserButton" id="default_folder_filechooserbutton">
<property name="visible">True</property>
<property name="sensitive">False</property>
- <property name="local_only">False</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
+ <property name="local_only">False</property>
<property name="title" translatable="yes">Select download folder</property>
</widget>
</child>
Modified: trunk/gget/DownloadList.py
==============================================================================
--- trunk/gget/DownloadList.py (original)
+++ trunk/gget/DownloadList.py Sat Jul 12 15:14:15 2008
@@ -35,7 +35,9 @@
"""Singleton holding the list of downloads"""
__gsignals__ = {"download-added": (gobject.SIGNAL_RUN_LAST, None,
- (object,))}
+ (object,)),
+ "download-removed": (gobject.SIGNAL_RUN_LAST, None,
+ (object,))}
instance = None
@@ -82,6 +84,8 @@
file.close()
def add_download(self, uri, path=None):
+ """Constructs a new download object and adds it to the list and xml
+ tree."""
if path is None:
path = self.config.default_folder
@@ -146,6 +150,22 @@
return download_element
return None
+ def remove_download(self, download):
+ """Removes a download object from the list and xml tree."""
+ self.downloads.remove(download)
+ download_element = self.__get_download_element(download)
+ self.tree.getroot().remove(download_element)
+ Utils.debug_print("Removed download %s from list of downloads." %
+ download)
+ self.emit("download-removed", (download))
+ self.__save_xml()
+
+ def remove_completed_downloads(self):
+ """Removes all completed downloads in the list (and xml tree)."""
+ for download in self.downloads:
+ if download.status == Download.COMPLETED:
+ self.remove_download(download)
+
def __save_xml(self):
"""Adds a header and indents the xml tree before saving it to disk."""
file = open(self.download_file_path, "w")
Modified: trunk/gget/MainWindow.py
==============================================================================
--- trunk/gget/MainWindow.py (original)
+++ trunk/gget/MainWindow.py Sat Jul 12 15:14:15 2008
@@ -46,6 +46,7 @@
self.config = config
self.download_list = download_list
self.download_list.connect("download-added", self.__download_added)
+ self.download_list.connect("download-removed", self.__download_removed)
self.__get_widgets()
@@ -121,6 +122,8 @@
self.add_tool_button = xml.get_widget("add_tool_button")
self.pause_tool_button = xml.get_widget("pause_tool_button")
self.cancel_tool_button = xml.get_widget("cancel_tool_button")
+ self.remove_tool_button = xml.get_widget("remove_tool_button")
+ self.clear_tool_button = xml.get_widget("clear_tool_button")
self.downloads_treeview = xml.get_widget("downloads_treeview")
@@ -210,6 +213,10 @@
self.cancel_imi.show()
self.downloads_treeview_menu.append(self.cancel_imi)
+ self.remove_imi = gtk.ImageMenuItem(gtk.STOCK_REMOVE)
+ self.remove_imi.show()
+ self.downloads_treeview_menu.append(self.remove_imi)
+
separator_imi = gtk.SeparatorMenuItem()
separator_imi.show()
self.downloads_treeview_menu.append(separator_imi)
@@ -307,6 +314,10 @@
self.pause_tool_button.connect("clicked",
self.__pause_tool_button_clicked)
self.cancel_tool_button.connect("clicked", self.__cancel_download)
+ self.remove_tool_button.connect("clicked",
+ self.__remove_selected_download)
+ self.clear_tool_button.connect("clicked",
+ self.__clear_tool_button_clicked)
# Download treeview
selection = self.downloads_treeview.get_selection()
@@ -321,6 +332,7 @@
self.pause_imi.connect("activate", self.__pause_imi_activate)
self.resume_imi.connect("activate", self.__resume_imi_activate)
self.cancel_imi.connect("activate", self.__cancel_download)
+ self.remove_imi.connect("activate", self.__remove_selected_download)
self.open_imi.connect("activate", self.__open_imi_activate)
self.open_folder_imi.connect("activate", self.__open_folder_imi_activate)
@@ -409,6 +421,8 @@
self.pause_imi.set_sensitive(True)
self.cancel_tool_button.set_sensitive(True)
self.cancel_imi.set_sensitive(True)
+ self.remove_tool_button.set_sensitive(True)
+ self.remove_imi.set_sensitive(True)
# Set informative window title
# download = downloads_model.get_value(downloads_iter, 0)
@@ -420,6 +434,8 @@
self.pause_imi.set_sensitive(False)
self.cancel_tool_button.set_sensitive(False)
self.cancel_imi.set_sensitive(False)
+ self.remove_tool_button.set_sensitive(False)
+ self.remove_imi.set_sensitive(False)
def __downloads_treeview_row_activated(self, treeview, path, column):
"""Called when a download is double-clicked. Opens the file with the
@@ -435,13 +451,6 @@
if download:
menu.popup(None, None, None, event.button, event.time)
- def __test(self, treeview, event, menu):
- print "foo"
- """Show context menu for downloads treeview"""
- if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
- menu.popup(None, None, None, event.button, event.time)
- return False
-
def __treeview_column_button_press(self, treeview, event, menu):
"""Show context menu for downloads treeview"""
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
@@ -458,6 +467,9 @@
tool_button.set_stock_id(gtk.STOCK_MEDIA_PAUSE)
tool_button.set_label(None)
+ def __clear_tool_button_clicked(self, tool_button):
+ self.download_list.remove_completed_downloads()
+
def __pause_imi_activate(self, imagemenuitem):
download = GUI.get_selected_value(self.downloads_treeview)
if download:
@@ -475,6 +487,11 @@
if download:
pass
+ def __remove_selected_download(self, widget):
+ download = GUI.get_selected_value(self.downloads_treeview)
+ if download:
+ self.download_list.remove_download(download)
+
def __open_imi_activate(self, imagemenuitem):
"""Opens the downloaded file with the associated program."""
download = GUI.get_selected_value(self.downloads_treeview)
@@ -614,6 +631,17 @@
download.connect("status-changed", self.__download_status_changed)
GUI.queue_resize(self.downloads_treeview)
+ def __download_removed(self, download_list, download):
+ """Called when a download is removed from DownloadList. Removes the
+ download from the treeview model."""
+ downloads_iter = self.downloads_model.get_iter_first()
+ for row in self.downloads_model:
+ if row[0] is download:
+ self.downloads_model.remove(downloads_iter)
+ GUI.queue_resize(self.downloads_treeview)
+ break
+ downloads_iter = self.downloads_model.iter_.next(downloads_iter)
+
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."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]