gget r40 - in trunk: data gget
- From: johans svn gnome org
- To: svn-commits-list gnome org
- Subject: gget r40 - in trunk: data gget
- Date: Mon, 28 Jul 2008 15:39:09 +0000 (UTC)
Author: johans
Date: Mon Jul 28 15:39:09 2008
New Revision: 40
URL: http://svn.gnome.org/viewvc/gget?rev=40&view=rev
Log:
Code dump from this weekends cabin hacking. Mostly bug fixes.
Modified:
trunk/data/gget.glade
trunk/data/gget.schemas.in
trunk/gget/AddDownloadDialog.py
trunk/gget/Configuration.py
trunk/gget/Download.py
trunk/gget/DownloadList.py
trunk/gget/DownloadManager.py
trunk/gget/MainWindow.py
trunk/gget/Notification.py
trunk/gget/PreferencesDialog.py
trunk/gget/Utils.py
Modified: trunk/data/gget.glade
==============================================================================
--- trunk/data/gget.glade (original)
+++ trunk/data/gget.glade Mon Jul 28 15:39:09 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 Mon Jul 21 00:07:25 2008 -->
+<!--Generated with glade3 3.4.5 on Mon Jul 28 10:43:15 2008 -->
<glade-interface>
<widget class="GtkWindow" id="main_window">
<property name="width_request">800</property>
@@ -58,6 +58,7 @@
<child>
<widget class="GtkImageMenuItem" id="select_all_menu_item">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="label" translatable="yes">Select all</property>
<property name="use_underline">True</property>
<accelerator key="a" modifiers="GDK_CONTROL_MASK" signal="activate"/>
@@ -72,6 +73,7 @@
<child>
<widget class="GtkMenuItem" id="unselect_all_menu_item">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="label" translatable="yes">Unselect all</property>
<property name="use_underline">True</property>
<accelerator key="a" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK" signal="activate"/>
@@ -207,6 +209,7 @@
<child>
<widget class="GtkToolButton" id="add_tool_button">
<property name="visible">True</property>
+ <property name="tooltip_text">Add new download</property>
<property name="stock_id">gtk-add</property>
</widget>
<packing>
@@ -224,9 +227,21 @@
</packing>
</child>
<child>
+ <widget class="GtkToolButton" id="resume_tool_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="label" translatable="yes">Resume</property>
+ <property name="stock_id">gtk-media-play</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkToolButton" id="cancel_tool_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
+ <property name="tooltip_text">Cancel selected downloads</property>
<property name="stock_id">gtk-cancel</property>
</widget>
<packing>
@@ -237,6 +252,7 @@
<widget class="GtkToolButton" id="remove_tool_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
+ <property name="tooltip_text">Remove selected downloads</property>
<property name="stock_id">gtk-remove</property>
</widget>
<packing>
@@ -246,6 +262,8 @@
<child>
<widget class="GtkToolButton" id="clear_tool_button">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="tooltip_text">Remove completed downloads</property>
<property name="stock_id">gtk-clear</property>
</widget>
<packing>
@@ -256,6 +274,7 @@
<widget class="GtkToolButton" id="details_tool_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
+ <property name="tooltip_text">Show details about the selected download</property>
<property name="label" translatable="yes">Details</property>
<property name="stock_id">gtk-info</property>
</widget>
@@ -363,16 +382,25 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
- <widget class="GtkFileChooserButton" id="download_filechooserbutton">
+ <widget class="GtkLabel" id="label3">
<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="xalign">1</property>
+ <property name="label" translatable="yes">_URI:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">uri_entry</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="uri_entry">
+ <property name="visible">True</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>
@@ -390,25 +418,16 @@
</packing>
</child>
<child>
- <widget class="GtkEntry" id="uri_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>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_URI:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">uri_entry</property>
- </widget>
- <packing>
- <property name="x_options">GTK_FILL</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
</packing>
</child>
</widget>
@@ -585,18 +604,6 @@
<property name="draw_indicator">True</property>
</widget>
</child>
- <child>
- <widget class="GtkCheckButton" id="autoresume_checkbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Resume paused downloads</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
</widget>
</child>
</widget>
@@ -1181,83 +1188,89 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <widget class="GtkLabel" id="label8">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>Name:</b></property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label9">
+ <widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>Folder:</b></property>
- <property name="use_markup">True</property>
+ <property name="bottom_padding">18</property>
+ <child>
+ <widget class="GtkLabel" id="uri_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </widget>
+ </child>
</widget>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label10">
+ <widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>Current size:</b></property>
- <property name="use_markup">True</property>
+ <property name="top_padding">18</property>
+ <child>
+ <widget class="GtkLabel" id="date_started_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </widget>
+ </child>
</widget>
<packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label11">
+ <widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>Total size:</b></property>
- <property name="use_markup">True</property>
+ <property name="top_padding">18</property>
+ <child>
+ <widget class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>Date started:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ </child>
</widget>
<packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label12">
+ <widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>MIME-type:</b></property>
- <property name="use_markup">True</property>
+ <property name="bottom_padding">18</property>
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>URI:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ </child>
</widget>
<packing>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label14">
+ <widget class="GtkLabel" id="date_completed_label">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>Date completed:</b></property>
- <property name="use_markup">True</property>
+ <property name="xalign">0</property>
</widget>
<packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
@@ -1265,29 +1278,29 @@
</packing>
</child>
<child>
- <widget class="GtkLabel" id="name_label">
+ <widget class="GtkLabel" id="mime_type_label">
<property name="visible">True</property>
<property name="xalign">0</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>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="folder_label">
+ <widget class="GtkLabel" id="total_size_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -1307,41 +1320,41 @@
</packing>
</child>
<child>
- <widget class="GtkLabel" id="total_size_label">
+ <widget class="GtkLabel" id="folder_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="mime_type_label">
+ <widget class="GtkLabel" id="name_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="date_completed_label">
+ <widget class="GtkLabel" id="label14">
<property name="visible">True</property>
- <property name="xalign">0</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>Date completed:</b></property>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
@@ -1349,77 +1362,71 @@
</packing>
</child>
<child>
- <widget class="GtkAlignment" id="alignment1">
+ <widget class="GtkLabel" id="label12">
<property name="visible">True</property>
- <property name="bottom_padding">18</property>
- <child>
- <widget class="GtkLabel" id="label7">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>URI:</b></property>
- <property name="use_markup">True</property>
- </widget>
- </child>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>MIME-type:</b></property>
+ <property name="use_markup">True</property>
</widget>
<packing>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkAlignment" id="alignment2">
+ <widget class="GtkLabel" id="label11">
<property name="visible">True</property>
- <property name="top_padding">18</property>
- <child>
- <widget class="GtkLabel" id="label13">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes"><b>Date started:</b></property>
- <property name="use_markup">True</property>
- </widget>
- </child>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>Total size:</b></property>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkAlignment" id="alignment3">
+ <widget class="GtkLabel" id="label10">
<property name="visible">True</property>
- <property name="top_padding">18</property>
- <child>
- <widget class="GtkLabel" id="date_started_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </widget>
- </child>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>Current size:</b></property>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkAlignment" id="alignment4">
+ <widget class="GtkLabel" id="label9">
<property name="visible">True</property>
- <property name="bottom_padding">18</property>
- <child>
- <widget class="GtkLabel" id="uri_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </widget>
- </child>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>Folder:</b></property>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>Name:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
Modified: trunk/data/gget.schemas.in
==============================================================================
--- trunk/data/gget.schemas.in (original)
+++ trunk/data/gget.schemas.in Mon Jul 28 15:39:09 2008
@@ -80,20 +80,6 @@
</locale>
</schema>
<schema>
- <key>/schemas/apps/gget/general/autoresume</key>
- <applyto>/apps/gget/general/autoresume</applyto>
- <owner>gget</owner>
- <type>bool</type>
- <default>false</default>
- <locale name="C">
- <short>Autoresume downloads on startup</short>
- <long>
- Whether GGet should automatically resume paused downloads
- on startup.
- </long>
- </locale>
- </schema>
- <schema>
<key>/schemas/apps/gget/general/window_width</key>
<applyto>/apps/gget/general/window_width</applyto>
<owner>gget</owner>
Modified: trunk/gget/AddDownloadDialog.py
==============================================================================
--- trunk/gget/AddDownloadDialog.py (original)
+++ trunk/gget/AddDownloadDialog.py Mon Jul 28 15:39:09 2008
@@ -44,6 +44,8 @@
self.uri_entry.set_text(uri)
else:
self.uri_entry.set_text(GUI.get_uri_from_clipboard() or "")
+ # self.uri_entry.paste_clipboard()
+ # self.uri_entry.select_region(0, -1)
folder = Utils.get_folder_for_extension(uri)
if not folder:
@@ -79,6 +81,8 @@
uri = GUI.get_uri_from_clipboard()
if uri:
self.uri_entry.set_text(uri)
+ # self.uri_entry.select_region(0, -1)
+ # self.uri_entry.grab_focus()
def __uri_entry_activate(self, entry):
self.add_button.clicked()
Modified: trunk/gget/Configuration.py
==============================================================================
--- trunk/gget/Configuration.py (original)
+++ trunk/gget/Configuration.py Mon Jul 28 15:39:09 2008
@@ -36,7 +36,6 @@
KEY_SHOW_MAIN_WINDOW = "/general/show_main_window"
KEY_SHOW_NOTIFICATIONS = "/general/show_notifications"
KEY_AUTOSTART = "/general/autostart"
-KEY_AUTORESUME = "/general/autoresume"
KEY_WINDOW_WIDTH = "/general/window_width"
KEY_WINDOW_HEIGHT = "/general/window_height"
KEY_WINDOW_POSITION_X = "/general/window_position_x"
@@ -82,7 +81,6 @@
KEY_SHOW_MAIN_WINDOW: 'bool',
KEY_SHOW_NOTIFICATIONS: 'bool',
KEY_AUTOSTART: 'bool',
- KEY_AUTORESUME: 'bool',
KEY_WINDOW_WIDTH: 'int',
KEY_WINDOW_HEIGHT: 'int',
KEY_WINDOW_POSITION_X: 'int',
@@ -226,15 +224,6 @@
autostart = property(get_autostart, set_autostart)
- # Autoresume
- def get_autoresume(self):
- return self.__get_option(KEY_AUTORESUME)
-
- def set_autoresume(self, autoresume):
- self.__set_option(KEY_AUTORESUME, autoresume)
-
- autoresume = property(get_autoresume, set_autoresume)
-
# Window width
def get_window_width(self):
return self.__get_option(KEY_WINDOW_WIDTH)
Modified: trunk/gget/Download.py
==============================================================================
--- trunk/gget/Download.py (original)
+++ trunk/gget/Download.py Mon Jul 28 15:39:09 2008
@@ -69,14 +69,16 @@
if folder:
self.path = folder
- if uri.endswith(".metalink") or metalink.urlhead(uri,
- metalink=True)["content-type"].startswith(metalink.MIME_TYPE):
- self.is_metalink = True
- else:
- self.is_metalink = False
+ # if uri.endswith(".metalink") or metalink.urlhead(uri,
+ # metalink=True)["content-type"].startswith(metalink.MIME_TYPE):
+ # self.is_metalink = True
+ # else:
+ # self.is_metalink = False
self.file = os.path.join(path, self.file_name)
+ self.has_started = False
+
self.canceled = False
self.paused = False
@@ -159,10 +161,11 @@
if self.percent_complete > 100:
self.percent_complete = 100
- if self.status != DOWNLOADING and self.bitrate != 0.0:
+ if not self.has_started:
+ self.has_started = True
self.set_status(DOWNLOADING)
- if self.percent_complete == 100:
+ if self.status != COMPLETED and self.percent_complete == 100:
self.set_status(COMPLETED)
Utils.debug_print("Percent complete: %s" % self.percent_complete)
@@ -175,6 +178,11 @@
self.emit("bitrate", bit_rate)
def set_canceled(self, canceled):
+ if canceled:
+ if not (self.status != CONNECTING or self.status != DOWNLOADING or \
+ self.status != ERROR):
+ return
+
self.canceled = canceled
if canceled:
self.set_status(CANCELED)
@@ -182,6 +190,10 @@
self.set_status(DOWNLOADING)
def set_paused(self, paused):
+ if paused:
+ if not (self.status != CONNECTING or self.status != DOWNLOADING):
+ return
+
self.paused = paused
if paused:
self.set_status(PAUSED)
@@ -218,4 +230,8 @@
if self.config.show_notifications:
Notification(download)
+ if self.bit_rate != 0.0:
+ self.bit_rate = 0.0
+ self.emit("bitrate", self.bit_rate)
+
# vim: set sw=4 et sts=4 tw=79 fo+=l:
Modified: trunk/gget/DownloadList.py
==============================================================================
--- trunk/gget/DownloadList.py (original)
+++ trunk/gget/DownloadList.py Mon Jul 28 15:39:09 2008
@@ -146,6 +146,9 @@
if download_element:
status_element = download_element.find("status")
status_element.text = str(status)
+ if status == Download.COMPLETED:
+ date_completed = download_element.find("date_completed")
+ date_completed.text = download.get_date_str("completed")
self.__save_xml()
def __get_download_element(self, download):
Modified: trunk/gget/DownloadManager.py
==============================================================================
--- trunk/gget/DownloadManager.py (original)
+++ trunk/gget/DownloadManager.py Mon Jul 28 15:39:09 2008
@@ -57,23 +57,48 @@
metalink.USER_AGENT = "%s %s" % (NAME, VERSION)
- # Setup proxy
+ self.__set_proxies()
+
+ def __set_proxies(self):
if self.config.proxy_mode == "gnome":
if self.config.use_http_proxy:
if self.config.use_http_proxy_auth:
- metalink.HTTP_PROXY = "http://%s:%s %s:%s" % (self.config.http_proxy_user, self.config.http_proxy_pass, self.config.http_proxy_host, self.config.http_proxy_port)
+ self.set_proxy("http", "http://%s:%s %s:%s" % \
+ (self.config.http_proxy_user,
+ self.config.http_proxy_pass,
+ self.config.http_proxy_host,
+ self.config.http_proxy_port))
if self.config.use_same_proxy:
- metalink.HTTPS_PROXY = "https://%s:%s %s:%s" % (self.config.http_proxy_user, self.config.http_proxy_pass, self.config.proxy_https_host, self.config.proxy_https_port)
- metalink.FTP_PROXY = "ftp://%s:%s %s:%s" % (self.config.http_proxy_user, self.config.http_proxy_pass, self.config.proxy_ftp_host, self.config.proxy_ftp_port)
+ self.set_proxy("https", "https://%s:%s %s:%s" % \
+ (self.config.http_proxy_user,
+ self.config.http_proxy_pass,
+ self.config.proxy_https_host,
+ self.config.proxy_https_port))
+ self.set_proxy("ftp", "ftp://%s:%s %s:%s" % \
+ (self.config.http_proxy_user,
+ self.config.http_proxy_pass,
+ self.config.proxy_ftp_host,
+ self.config.proxy_ftp_port))
else:
- metalink.HTTP_PROXY = "http://%s:%s" % (self.config.http_proxy_host, self.config.http_proxy_port)
- metalink.HTTPS_PROXY = "https://%s:%s" % (self.config.proxy_https_host, self.config.proxy_https_port)
- metalink.FTP_PROXY = "ftp://%s:%s" % (self.config.proxy_ftp_host, self.config.proxy_ftp_port)
+ self.set_proxy("http", "http://%s:%s" % \
+ (self.config.http_proxy_host,
+ self.config.http_proxy_port))
+ self.set_proxy("https", "https://%s:%s" % \
+ (self.config.proxy_https_host,
+ self.config.proxy_https_port))
+ self.set_proxy("ftp", "ftp://%s:%s" % \
+ (self.config.proxy_ftp_host,
+ self.config.proxy_ftp_port))
elif self.config.proxy_mode == "manual":
if self.config.proxy_auth:
- metalink.HTTP_PROXY = "http://%s:%s %s:%s" % (self.config.proxy_user, self.config.proxy_password, self.config.proxy_host, self.config.proxy_port)
+ self.set_proxy("http", "http://%s:%s %s:%s" % \
+ (self.config.proxy_user,
+ self.config.proxy_password,
+ self.config.proxy_host,
+ self.config.proxy_port))
else:
- metalink.HTTP_PROXY = "http://%s:%s" % (self.config.proxy_host, self.config.proxy_port)
+ self.set_proxy("http", "http://%s:%s" % \
+ (self.config.proxy_host, self.config.proxy_port))
def __download_added(self, download_list, download):
"""Called when a new download is added to DownloadList. Starts the
@@ -100,23 +125,24 @@
"bitrate": download.bitrate,
"cancel": download.cancel,
"pause": download.pause})
+
+ if not result:
+ download.set_status(Download.ERROR)
+ print "Failed downloading of file %s" % download.uri
+
except Exception, e:
pass
- if not result:
- download.set_status(Download.ERROR)
- print "Failed downloading of file %s" % download.uri
-
def set_proxy(self, protocol, proxy):
"""Sets the proxy to use for the specified protocol."""
if protocol == "http":
metalink.HTTP_PROXY = proxy
- Utils.debug_print("HTTP proxy: %s", metalink.HTTP_PROXY)
+ Utils.debug_print("HTTP proxy: %s" % metalink.HTTP_PROXY)
elif protocol == "https":
metalink.HTTPS_PROXY = proxy
- Utils.debug_print("HTTPS proxy: %s", metalink.HTTPS_PROXY)
+ Utils.debug_print("HTTPS proxy: %s" % metalink.HTTPS_PROXY)
elif protocol == "ftp":
metalink.FTP_PROXY = proxy
- Utils.debug_print("FTP proxy: %s", metalink.FTP_PROXY)
+ Utils.debug_print("FTP proxy: %s" % metalink.FTP_PROXY)
# vim: set sw=4 et sts=4 tw=79 fo+=l:
Modified: trunk/gget/MainWindow.py
==============================================================================
--- trunk/gget/MainWindow.py (original)
+++ trunk/gget/MainWindow.py Mon Jul 28 15:39:09 2008
@@ -29,6 +29,7 @@
import gnome.ui
import Configuration
+import Download
import GUI
import Utils
from GUI import ErrorDialog
@@ -124,6 +125,7 @@
self.add_tool_button = xml.get_widget("add_tool_button")
self.pause_tool_button = xml.get_widget("pause_tool_button")
+ self.resume_tool_button = xml.get_widget("resume_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")
@@ -213,6 +215,7 @@
self.resume_imi = gtk.ImageMenuItem(_("Resume"))
self.resume_imi.get_image().set_from_stock(gtk.STOCK_MEDIA_PLAY,
gtk.ICON_SIZE_MENU)
+ self.resume_imi.set_sensitive(False)
self.downloads_treeview_menu.append(self.resume_imi)
self.cancel_imi = gtk.ImageMenuItem(gtk.STOCK_CANCEL)
@@ -332,6 +335,8 @@
self.add_tool_button.connect("clicked", self.show_add_download_dialog)
self.pause_tool_button.connect("clicked",
self.__pause_tool_button_clicked)
+ self.resume_tool_button.connect("clicked",
+ self.__resume_tool_button_clicked)
self.cancel_tool_button.connect("clicked",
self.__cancel_selected_downloads)
self.remove_tool_button.connect("clicked",
@@ -341,7 +346,11 @@
self.details_tool_button.connect("clicked",
self.__details_selected_download)
- # Download treeview
+ # Downloads model and treeview
+ self.downloads_model.connect("row-deleted",
+ self.__downloads_model_row_deleted)
+ self.downloads_model.connect("row-inserted",
+ self.__downloads_models_row_inserted)
self.downloads_treeview_selection.connect("changed",
self.__downloads_treeview_selection_changed)
self.downloads_treeview.connect("row-activated",
@@ -442,37 +451,111 @@
ad = AboutDialog()
ad.run()
+ def __downloads_model_row_deleted(self, model, path):
+ """Called when a new download is removed from the model."""
+ number_rows = len(model)
+ if number_rows <= 0:
+ self.clear_tool_button.set_sensitive(False)
+ self.select_all_menu_item.set_sensitive(False)
+ self.unselect_all_menu_item.set_sensitive(False)
+
+ def __downloads_models_row_inserted(self, model, path, iter):
+ """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):
- """When selection changes set sensitivity appropriately."""
- num_selected = selection.count_selected_rows()
+ """Called when selection changes. Sets download releated widgets and
+ their sensitivity."""
+ downloads = GUI.get_selected_values(self.downloads_treeview)
+ number_selected = selection.count_selected_rows()
# Disable tool buttons and menu items if nothing is selected, else
# enable them
- if num_selected < 1:
+ if number_selected < 1:
self.__download_widgets_set_sensitive(False)
- elif num_selected == 1:
+ elif number_selected == 1:
self.__download_widgets_set_sensitive(True)
- elif num_selected > 1:
+ if downloads:
+ status = downloads[0].status
+ self.__set_widgets_sensitivity_for_status(status)
+
+ elif number_selected > 1:
self.__download_widgets_set_sensitive(True)
+
+ has_cancled = has_paused = False
+ if downloads:
+ for download in downloads:
+ self.__set_widgets_sensitivity_for_status(download.status)
+
# Details should only be possible if one row is selected
self.details_tool_button.set_sensitive(False)
self.details_imi.set_sensitive(False)
- # Set informative window title
- # download = downloads_model.get_value(downloads_iter, 0)
- # if download:
- # self.window.set_title("%s %s (%.2f%%)" % (NAME, download.file_name, download.percent_complete))
+ # Select all should not be availible if all is selected already
+ if number_selected == len(self.downloads_model):
+ self.select_all_menu_item.set_sensitive(False)
+ elif not self.select_all_menu_item.props.sensitive:
+ self.select_all_menu_item.set_sensitive(True)
def __download_widgets_set_sensitive(self, sensitive):
"""Sets the sensitivity property for widgets associated with a the
downloads treeview."""
self.pause_tool_button.set_sensitive(sensitive)
self.pause_imi.set_sensitive(sensitive)
+ self.resume_tool_button.set_sensitive(sensitive)
+ self.resume_imi.set_sensitive(sensitive)
self.cancel_tool_button.set_sensitive(sensitive)
self.cancel_imi.set_sensitive(sensitive)
self.remove_tool_button.set_sensitive(sensitive)
self.remove_imi.set_sensitive(sensitive)
self.details_tool_button.set_sensitive(sensitive)
self.details_imi.set_sensitive(sensitive)
+ self.unselect_all_menu_item.set_sensitive(sensitive)
+
+ def __set_widgets_sensitivity_for_status(self, status,
+ single_selection=True):
+ """Sets the appropriate sensitivity property for widgets based on the
+ given status."""
+
+ if status == Download.COMPLETED:
+ if single_selection:
+ self.pause_tool_button.set_sensitive(False)
+ self.pause_imi.set_sensitive(False)
+ self.resume_tool_button.set_sensitive(False)
+ self.resume_imi.set_sensitive(False)
+ self.cancel_tool_button.set_sensitive(False)
+ self.cancel_imi.set_sensitive(False)
+
+ elif status == Download.CANCELED:
+ if single_selection:
+ self.pause_tool_button.set_sensitive(False)
+ self.pause_imi.set_sensitive(False)
+ self.cancel_tool_button.set_sensitive(False)
+ self.cancel_imi.set_sensitive(False)
+ self.resume_tool_button.set_sensitive(True)
+ self.resume_imi.set_sensitive(True)
+
+ elif status == Download.PAUSED:
+ if single_selection:
+ self.pause_tool_button.set_sensitive(False)
+ self.pause_imi.set_sensitive(False)
+ self.resume_tool_button.set_sensitive(True)
+ self.resume_imi.set_sensitive(True)
+ self.cancel_tool_button.set_sensitive(True)
+ self.cancel_imi.set_sensitive(True)
+
+ elif status == Download.DOWNLOADING or status == Download.CONNECTING:
+ if single_selection:
+ self.resume_tool_button.set_sensitive(False)
+ self.resume_imi.set_sensitive(False)
+ self.pause_tool_button.set_sensitive(True)
+ self.pause_imi.set_sensitive(True)
+
+ self.pause_imi.props.visible = self.pause_imi.props.sensitive
+ self.resume_imi.props.visible = self.resume_imi.props.sensitive
+ self.cancel_imi.props.visible = self.cancel_imi.props.sensitive
def __downloads_treeview_row_activated(self, treeview, path, column):
"""Called when a download is double-clicked. Opens the file with the
@@ -486,43 +569,39 @@
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
n_selected = self.downloads_treeview_selection.count_selected_rows()
if n_selected == 1:
+ self.open_imi.set_sensitive(True)
+ self.open_folder_imi.set_sensitive(True)
+ self.details_imi.set_sensitive(True)
menu.popup(None, None, None, event.button, event.time)
-
- 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:
- menu.popup(None, None, None, event.button, event.time)
+ return True
+ elif n_selected > 1:
+ self.open_imi.set_sensitive(False)
+ self.open_folder_imi.set_sensitive(False)
+ self.details_imi.set_sensitive(False)
+ menu.popup(None, None, None, event.button, event.time)
+ return True
+ return False
def __pause_tool_button_clicked(self, tool_button):
- downloads = GUI.get_selected_values(self.downloads_treeview)
- if downloads:
- pause = (tool_button.get_stock_id() == gtk.STOCK_MEDIA_PAUSE)
- if pause:
- tool_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
- tool_button.set_label(_("Resume"))
- else:
- tool_button.set_stock_id(gtk.STOCK_MEDIA_PAUSE)
- tool_button.set_label(None)
+ self.__pause_selected_downloads()
- for download in downloads:
- download.set_paused(pause)
+ def __resume_tool_button_clicked(self, tool_button):
+ self.__pause_selected_downloads(False)
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:
- imagemenuitem.hide()
- self.resume_imi.show()
- download.set_paused(True)
+ self.__pause_selected_downloads()
def __resume_imi_activate(self, imagemenuitem):
- download = GUI.get_selected_value(self.downloads_treeview)
- if download:
- imagemenuitem.hide()
- self.pause_imi.show()
- download.set_paused(False)
+ self.__pause_selected_downloads(False)
+
+ def __pause_selected_downloads(self, pause=True):
+ downloads = GUI.get_selected_values(self.downloads_treeview)
+ if downloads:
+ for download in downloads:
+ download.set_paused(pause)
def __cancel_selected_downloads(self, widget):
"""Cancels the selected download in DownloadList."""
@@ -698,12 +777,12 @@
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."""
- # self.window.set_title("%s %s (%.2f%%)" % (NAME, download.file_name, download.percent_complete))
self.update_download_row(download)
def __download_status_changed(self, download, status):
"""Called when the status of a download changes. Tells the treeview to
update the row with that download."""
+ self.__set_widgets_sensitivity_for_status(status)
self.update_download_row(download)
def update_download_row(self, download):
Modified: trunk/gget/Notification.py
==============================================================================
--- trunk/gget/Notification.py (original)
+++ trunk/gget/Notification.py Mon Jul 28 15:39:09 2008
@@ -48,7 +48,7 @@
pynotify.init(NAME)
- self.notification = pynotify.Notification(_("Download Completed!"),
+ self.notification = pynotify.Notification(_("Download Completed"),
_("%s has been downloaded successfully.") %
self.download.file_name)
@@ -85,6 +85,7 @@
elif action == "folder":
uri = gnomevfs.make_uri_from_input(self.download.path)
gnomevfs.url_show(uri)
+ notification.close()
def __closed(self, notification):
notification.close()
Modified: trunk/gget/PreferencesDialog.py
==============================================================================
--- trunk/gget/PreferencesDialog.py (original)
+++ trunk/gget/PreferencesDialog.py Mon Jul 28 15:39:09 2008
@@ -28,6 +28,7 @@
import Configuration
import GUI
+from DownloadManager import DownloadManager
from TrayIcon import TrayIcon
from gget import NAME
@@ -37,6 +38,7 @@
class PreferencesDialog:
def __init__(self, config):
self.config = config
+ self.download_manager = DownloadManager()
self.__get_widgets()
self.__make_extensions_treeview()
@@ -48,7 +50,6 @@
self.main_window_checkbutton.set_active(self.config.show_main_window)
self.notifications_checkbutton.set_active(self.config.show_notifications)
self.autostart_checkbutton.set_active(self.config.autostart)
- self.autoresume_checkbutton.set_active(self.config.autoresume)
self.main_window_checkbutton.set_sensitive(self.config.show_status_icon)
@@ -92,7 +93,6 @@
self.notifications_checkbutton = xml.get_widget("notifications_checkbutton")
self.autostart_checkbutton = xml.get_widget("autostart_checkbutton")
- self.autoresume_checkbutton = xml.get_widget("autoresume_checkbutton")
# Folders tab
self.ask_folder_radiobutton = xml.get_widget("ask_folder_radiobutton")
@@ -181,8 +181,6 @@
self.autostart_checkbutton.connect("toggled",
self.__autostart_checkbutton_toggled)
- self.autoresume_checkbutton.connect("toggled",
- self.__autoresume_checkbutton_toggled)
# Folders tab
self.ask_folder_radiobutton.connect("toggled",
@@ -232,8 +230,6 @@
self.__show_notifications_key_changed)
self.config.add_notify(Configuration.KEY_AUTOSTART,
self.__autostart_key_changed)
- self.config.add_notify(Configuration.KEY_AUTORESUME,
- self.__autoresume_key_changed)
self.config.add_notify(Configuration.KEY_ASK_FOR_LOCATION,
self.__ask_for_location_key_changed)
self.config.add_notify(Configuration.KEY_DEFAULT_FOLDER,
@@ -324,15 +320,6 @@
else:
self.autostart_checkbutton.set_active(True)
- def __autoresume_key_changed(self, client, cnxn_id, entry, data):
- if not entry.value:
- self.autoresume_checkbutton.set_active(True)
- elif entry.value.type == gconf.VALUE_BOOL:
- value = entry.value.get_bool()
- self.autoresume_checkbutton.set_active(value)
- else:
- self.autoresume_checkbutton.set_active(True)
-
def __ask_for_location_key_changed(self, client, cnxn_id, entry, data):
if not entry.value:
self.ask_folder_radiobutton.set_active(True)
@@ -370,9 +357,23 @@
elif mode == "gnome":
self.gnome_radiobutton.set_active(True)
self.manual_proxy_vbox.set_sensitive(False)
+ if self.config.use_http_proxy:
+ if self.config.use_http_proxy_auth:
+ self.download_manager.set_proxy("http", "http://%s:%s %s:%s" % (self.config.http_proxy_user, self.config.http_proxy_pass, self.config.http_proxy_host, self.config.http_proxy_port))
+ if self.config.use_same_proxy:
+ self.download_manager.set_proxy("https", "https://%s:%s %s:%s" % (self.config.http_proxy_user, self.config.http_proxy_pass, self.config.proxy_https_host, self.config.proxy_https_port))
+ self.download_manager.set_proxy("ftp", "ftp://%s:%s %s:%s" % (self.config.http_proxy_user, self.config.http_proxy_pass, self.config.proxy_ftp_host, self.config.proxy_ftp_port))
+ else:
+ self.download_manager.set_proxy("http", "http://%s:%s" % (self.config.http_proxy_host, self.config.http_proxy_port))
+ self.download_manager.set_proxy("https", "https://%s:%s" % (self.config.proxy_https_host, self.config.proxy_https_port))
+ self.download_manager.set_proxy("ftp", "ftp://%s:%s" % (self.config.proxy_ftp_host, self.config.proxy_ftp_port))
elif mode == "manual":
self.manual_radiobutton.set_active(True)
self.manual_proxy_vbox.set_sensitive(True)
+ if self.config.proxy_auth:
+ self.download_manager.set_proxy("http", "http://%s:%s %s:%s" % (self.config.proxy_user, self.config.proxy_password, self.config.proxy_host, self.config.proxy_port))
+ else:
+ self.download_manager.set_proxy("http", "http://%s:%s" % (self.config.proxy_host, self.config.proxy_port))
def __proxy_host_key_changed(self, client, cnxn_id, entry, data):
if entry.value.type == gconf.VALUE_STRING:
@@ -408,9 +409,6 @@
def __autostart_checkbutton_toggled(self, checkbutton):
self.config.autostart = checkbutton.get_active()
- def __autoresume_checkbutton_toggled(self, checkbutton):
- self.config.autoresume = checkbutton.get_active()
-
def __ask_folder_radiobutton_toggled(self, radiobutton):
active = radiobutton.get_active()
self.config.ask_for_location = active
Modified: trunk/gget/Utils.py
==============================================================================
--- trunk/gget/Utils.py (original)
+++ trunk/gget/Utils.py Mon Jul 28 15:39:09 2008
@@ -29,6 +29,8 @@
from Configuration import Configuration
def get_readable_size(bits):
+ if bits is None:
+ return ""
for unit in ['bytes','KB','MB','GB','TB']:
if float(bits) < 1024.0:
return "%3.1f %s" % (bits, unit)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]