From 7065df205b880d854d47bce30bf0715dab35e75a Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 9 Dec 2008 05:40:56 +0000 Subject: [PATCH] Fix #624 do not allow changing file priorities when using compact allocation --- deluge/ui/gtkui/addtorrentdialog.py | 37 +- deluge/ui/gtkui/files_tab.py | 41 +- .../ui/gtkui/glade/add_torrent_dialog.glade | 134 +- deluge/ui/gtkui/glade/main_window.glade | 1285 +++++++++-------- 4 files changed, 763 insertions(+), 734 deletions(-) diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 6805cdfbd..91b522e93 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -124,6 +124,8 @@ class AddTorrentDialog(component.Component): ] self.core_config = {} + self.glade.get_widget("notebook1").connect("switch-page", self._on_switch_page) + def start(self): self.update_core_config() @@ -157,20 +159,16 @@ class AddTorrentDialog(component.Component): def update_core_config(self): self.core_config = {} - # Send requests to the core for these config values - for key in self.core_keys: - client.get_config_value(self._on_config_value, key) + def _on_config_values(config): + self.core_config = config + + # Send requests to the core for these config values + client.get_config_values(_on_config_values, self.core_keys) # Force a call to the core because we need this data now client.force_call() self.set_default_options() - def _on_config_value(self, value): - for key in self.core_keys: - if not self.core_config.has_key(key): - self.core_config[key] = value - break - def add_from_files(self, filenames): import os.path new_row = None @@ -188,6 +186,7 @@ class AddTorrentDialog(component.Component): [info.info_hash, info.name, filename]) self.files[info.info_hash] = info.files self.infos[info.info_hash] = info.metadata + self.save_torrent_options(new_row) (model, row) = self.listview_torrents.get_selection().get_selected() if not row and new_row: @@ -212,6 +211,8 @@ class AddTorrentDialog(component.Component): [info_hash, name, uri]) self.files[info_hash] = [] self.infos[info_hash] = None + self.save_torrent_options(new_row) + (model, row) = self.listview_torrents.get_selection().get_selected() if not row and new_row: self.listview_torrents.get_selection().select_iter(new_row) @@ -239,6 +240,10 @@ class AddTorrentDialog(component.Component): self.previous_selected_torrent = row + def _on_switch_page(self, widget, page, page_num): + # Save the torrent options when switching notebook pages + self.save_torrent_options() + def prepare_file_store(self, files): self.listview_files.set_model(None) self.files_treestore.clear() @@ -347,6 +352,14 @@ class AddTorrentDialog(component.Component): self.glade.get_widget("entry_download_path").get_text() options["compact_allocation"] = \ self.glade.get_widget("radio_compact").get_active() + + if options["compact_allocation"]: + # We need to make sure all the files are set to download + def set_download_true(model, path, itr): + model[path][0] = True + self.files_treestore.foreach(set_download_true) + self.update_treeview_toggles(self.files_treestore.get_iter_first()) + options["max_download_speed"] = \ self.glade.get_widget("spin_maxdown").get_value() options["max_upload_speed"] = \ @@ -390,6 +403,8 @@ class AddTorrentDialog(component.Component): self.glade.get_widget("radio_compact").set_active( self.core_config["compact_allocation"]) + self.glade.get_widget("radio_full").set_active( + not self.core_config["compact_allocation"]) self.glade.get_widget("spin_maxdown").set_value( self.core_config["max_download_speed_per_torrent"]) self.glade.get_widget("spin_maxup").set_value( @@ -416,6 +431,10 @@ class AddTorrentDialog(component.Component): return files_list def _on_file_toggled(self, render, path): + # Check to see if we can change file priorities + (model, row) = self.listview_torrents.get_selection().get_selected() + if self.options[model[row][0]]["compact_allocation"]: + return (model, paths) = self.listview_files.get_selection().get_selected_rows() if len(paths) > 1: for path in paths: diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index 270d18755..dc133e0a9 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtkui/files_tab.py @@ -160,6 +160,14 @@ class FilesTab(Tab): self.listview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.file_menu = glade.get_widget("menu_file_tab") + self.file_menu_priority_items = [ + glade.get_widget("menuitem_donotdownload"), + glade.get_widget("menuitem_normal"), + glade.get_widget("menuitem_high"), + glade.get_widget("menuitem_highest"), + glade.get_widget("menuitem_priority_sep") + ] + self.listview.connect("row-activated", self._on_row_activated) self.listview.connect("button-press-event", self._on_button_press_event) @@ -271,26 +279,23 @@ class FilesTab(Tab): self.clear() return + status_keys = ["file_progress", "file_priorities"] if torrent_id != self.torrent_id: # We only want to do this if the torrent_id has changed self.treestore.clear() self.torrent_id = torrent_id + status_keys += ["compact"] if self.torrent_id not in self.files_list.keys(): # We need to get the files list log.debug("Getting file list from core..") - client.get_torrent_status( - self._on_get_torrent_files, - self.torrent_id, - ["files", "file_progress", "file_priorities"]) - client.force_call(block=True) + status_keys += ["files"] else: + # We already have the files list stored, so just update the view self.update_files() - client.get_torrent_status(self._on_get_torrent_status, self.torrent_id, ["file_progress", "file_priorities"]) - client.force_call(True) - else: - client.get_torrent_status(self._on_get_torrent_status, self.torrent_id, ["file_progress", "file_priorities"]) - client.force_call(True) + + client.get_torrent_status(self._on_get_torrent_status, self.torrent_id, status_keys) + client.force_call(True) def clear(self): self.treestore.clear() @@ -381,11 +386,6 @@ class FilesTab(Tab): return selected - def _on_get_torrent_files(self, status): - self.files_list[self.torrent_id] = status["files"] - self.update_files() - self._on_get_torrent_status(status) - def get_files_from_tree(self, rows, files_list, indent): if not rows: return None @@ -397,6 +397,14 @@ class FilesTab(Tab): return None def _on_get_torrent_status(self, status): + # Store this torrent's compact setting + if "compact" in status: + self.__compact = status["compact"] + + if "files" in status: + self.files_list[self.torrent_id] = status["files"] + self.update_files() + # (index, iter) files_list = [] self.get_files_from_tree(self.treestore, files_list, 0) @@ -435,6 +443,9 @@ class FilesTab(Tab): else: self.listview.get_selection().select_iter(row) + for widget in self.file_menu_priority_items: + widget.set_sensitive(not self.__compact) + self.file_menu.popup(None, None, None, event.button, event.time) return True diff --git a/deluge/ui/gtkui/glade/add_torrent_dialog.glade b/deluge/ui/gtkui/glade/add_torrent_dialog.glade index 237b9f099..ce979e7d0 100644 --- a/deluge/ui/gtkui/glade/add_torrent_dialog.glade +++ b/deluge/ui/gtkui/glade/add_torrent_dialog.glade @@ -1,6 +1,6 @@ - + 560 @@ -472,7 +472,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Full 0 - True True @@ -487,7 +486,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Compact 0 - True True radio_full @@ -538,7 +536,7 @@ 2 10 - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -548,26 +546,61 @@ 1 2 - 3 - 4 - + True - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 1 - -1 -1 9999 1 10 0 + 0 + Max Down Speed: + + + GTK_FILL + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Max Up Speed: + + + 1 + 2 + GTK_FILL + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Max Connections: - 1 - 2 2 3 - + GTK_FILL + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Max Upload Slots: + + + 3 + 4 + GTK_FILL @@ -590,61 +623,7 @@ - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Max Upload Slots: - - - 3 - 4 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Max Connections: - - - 2 - 3 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Max Up Speed: - - - 1 - 2 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Max Down Speed: - - - GTK_FILL - - - - - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -654,6 +633,25 @@ 1 2 + 2 + 3 + + + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + -1 -1 9999 1 10 0 + + + 1 + 2 + 3 + 4 diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index 91b3d98e3..ce7b5e13a 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -561,7 +561,7 @@ - + True @@ -675,290 +675,165 @@ 10 5 - - True - 0 - - - 5 - 6 - 3 - 4 - GTK_FILL - - - - - True - 0 - <b>Auto Managed:</b> - True - - - 4 - 5 - 3 - 4 - GTK_FILL - - - - + True 0 7 8 - 2 - 3 - GTK_FILL - - - - - True - 0 - - - 7 - 8 - 1 - 2 - GTK_FILL - - - - - True - 0 - <b>Seed Rank:</b> - True - - - 6 - 7 - 2 - 3 - GTK_FILL - - - - - True - 0 - <b>Seeding Time:</b> - True - - - 6 - 7 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 7 - 8 - GTK_FILL - - - - - True - 0 - <b>Active Time:</b> - True - - - 6 - 7 - GTK_FILL - - - - - True - 0 - True - - - 1 - 2 3 4 GTK_FILL - + True 0 + <b>Date Added:</b> + True - 3 - 4 + 6 + 7 3 4 GTK_FILL - - True - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 8 - 4 - 5 - GTK_FILL - - - - - True - 0 - 0 - <b>Tracker Status:</b> - True - - - 4 - 5 - GTK_FILL - GTK_FILL - - - - - True - 0 - True - PANGO_WRAP_WORD_CHAR - - - 5 - 6 - 2 - 3 - GTK_FILL - - - - - True - 0 - 1 - <b>Availability:</b> - True - - - 4 - 5 - 2 - 3 - GTK_FILL - - - - - True - 0 - - - 3 - 4 - 2 - 3 - GTK_FILL - - - - + True 0 1 2 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + GTK_FILL + + + + + True + 0 + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + 1 + 2 + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Downloaded:</b> + True + + + + + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Uploaded:</b> + True + + + + + 1 + 2 + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Share Ratio:</b> + True + + + + 2 3 GTK_FILL - + True - 0 + 5 + + + True + 0 + <b>Next Announce:</b> + True + + - 5 - 6 - 1 - 2 + 3 + 4 GTK_FILL - - True - 0 - <b>Peers:</b> - True - - - 4 - 5 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 5 - 6 - GTK_FILL - - - - - True - 0 - <b>Seeders:</b> - True - - - 4 - 5 - GTK_FILL - - - - + True 15 5 - + True 0 - <b>Pieces:</b> + <b>Speed:</b> True @@ -966,30 +841,6 @@ 2 3 - 3 - 4 - GTK_FILL - - - - - True - 15 - 5 - - - True - 0 - <b>ETA:</b> - True - - - - - 2 - 3 - 2 - 3 GTK_FILL @@ -1016,15 +867,15 @@ - + True 15 5 - + True 0 - <b>Speed:</b> + <b>ETA:</b> True @@ -1032,154 +883,303 @@ 2 3 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Next Announce:</b> - True - - - - - 3 - 4 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Share Ratio:</b> - True - - - - 2 3 GTK_FILL - + True + 15 5 - + True 0 - <b>Uploaded:</b> + <b>Pieces:</b> True - 1 - 2 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Downloaded:</b> - True - - - - - GTK_FILL - - - - - True - 0 - - - 3 - 4 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 3 - 4 - GTK_FILL - - - - - True - 0 - - - 1 - 2 - GTK_FILL - - - - - True - 0 - <b>Date Added:</b> - True - - - 6 - 7 + 2 + 3 3 4 GTK_FILL - + + True + 0 + <b>Seeders:</b> + True + + + 4 + 5 + GTK_FILL + + + + + True + 0 + + + 5 + 6 + GTK_FILL + + + + + True + 0 + <b>Peers:</b> + True + + + 4 + 5 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 5 + 6 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + 2 + 3 + GTK_FILL + + + + + True + 0 + 1 + <b>Availability:</b> + True + + + 4 + 5 + 2 + 3 + GTK_FILL + + + + + True + 0 + True + PANGO_WRAP_WORD_CHAR + + + 5 + 6 + 2 + 3 + GTK_FILL + + + + + True + 0 + 0 + <b>Tracker Status:</b> + True + + + 4 + 5 + GTK_FILL + GTK_FILL + + + + + True + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 8 + 4 + 5 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + 3 + 4 + GTK_FILL + + + + + True + 0 + True + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + True + 0 + <b>Active Time:</b> + True + + + 6 + 7 + GTK_FILL + + + + True 0 7 8 + GTK_FILL + + + + + True + 0 + <b>Seeding Time:</b> + True + + + 6 + 7 + 1 + 2 + GTK_FILL + + + + + True + 0 + <b>Seed Rank:</b> + True + + + 6 + 7 + 2 + 3 + GTK_FILL + + + + + True + 0 + + + 7 + 8 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 7 + 8 + 2 + 3 + GTK_FILL + + + + + True + 0 + <b>Auto Managed:</b> + True + + + 4 + 5 + 3 + 4 + GTK_FILL + + + + + True + 0 + + + 5 + 6 3 4 GTK_FILL @@ -1269,7 +1269,7 @@ - + True 0 True @@ -1277,114 +1277,45 @@ 1 2 - 4 - 5 - - - - - - True - 0 - 1 - <b># of files:</b> - True - - - 4 - 5 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 4 - 1 - 2 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <b>Hash:</b> - True - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - PANGO_WRAP_CHAR - True - - - 1 - 4 - 6 - 7 - - - - - - True - 0 - 1 - <b>Tracker:</b> - True - - - 6 - 7 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Total Size:</b> - True - - - - 3 4 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + True + + + 1 + 4 + 5 + 6 + + + + + + True + 0 + 1 + <b>Status:</b> + True + + + 5 + 6 GTK_FILL - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_STRUCTURE_MASK + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 True PANGO_WRAP_CHAR @@ -1393,27 +1324,8 @@ 1 4 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 0 - 1 - <b>Name:</b> - True - - - - - GTK_FILL + 2 + 3 @@ -1440,7 +1352,110 @@ - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 0 + 1 + <b>Name:</b> + True + + + + + GTK_FILL + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_STRUCTURE_MASK + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 4 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Total Size:</b> + True + + + + + 3 + 4 + GTK_FILL + + + + + + True + 0 + 1 + <b>Tracker:</b> + True + + + 6 + 7 + GTK_FILL + + + + + + True + 0 + PANGO_WRAP_CHAR + True + + + 1 + 4 + 6 + 7 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <b>Hash:</b> + True + + + 1 + 2 + GTK_FILL + + + + + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -1451,43 +1466,28 @@ 1 4 - 2 - 3 + 1 + 2 - + True 0 1 - <b>Status:</b> + <b># of files:</b> True - 5 - 6 + 4 + 5 GTK_FILL - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - True - - - 1 - 4 - 5 - 6 - - - - - + True 0 True @@ -1495,8 +1495,8 @@ 1 2 - 3 - 4 + 4 + 5 @@ -1677,7 +1677,7 @@ - + True True 6 @@ -1687,8 +1687,100 @@ 1 2 + 3 + 4 + + + + + + + True + 0 + Max Upload Slots: + + + 3 + 4 + GTK_FILL + + + + + + True + KiB/s + + + 2 + 3 + 1 + 2 + + + + + + + True + KiB/s + + + 2 + 3 + + + + + + + True + 0 + Max Download Speed: + + + GTK_FILL + + + + + + True + 0 + Max Upload Speed: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Max Connections: + + 2 3 + GTK_FILL + + + + + + True + True + 6 + 1 + -1 -1 999999 1 10 0 + 1 + + + 1 + 2 @@ -1712,110 +1804,18 @@ - + True True 6 1 -1 -1 999999 1 10 0 - 1 1 2 - - - - - - - True - 0 - Max Connections: - - 2 3 - GTK_FILL - - - - - - True - 0 - Max Upload Speed: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Max Download Speed: - - - GTK_FILL - - - - - - True - KiB/s - - - 2 - 3 - - - - - - - True - KiB/s - - - 2 - 3 - 1 - 2 - - - - - - - True - 0 - Max Upload Slots: - - - 3 - 4 - GTK_FILL - - - - - - True - True - 6 - 1 - -1 -1 999999 1 10 0 - - - 1 - 2 - 3 - 4 @@ -1950,8 +1950,8 @@ True False - False GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER + False Select A Folder @@ -2408,6 +2408,7 @@ True + gtk-missing-image False @@ -2453,14 +2454,23 @@ 10 2 - + + True + 0 + <i>Current Version:</i> + True + + + GTK_FILL + + + + True 1 2 - 1 - 2 @@ -2478,26 +2488,17 @@ - + True 1 2 + 1 + 2 - - - True - 0 - <i>Current Version:</i> - True - - - GTK_FILL - -