Tweaks to [1102]. Get compact_mode for the Files tab with

manager.get_torrent_state(), for the Files selection dialog with preferences.
This commit is contained in:
Alex Dedul 2007-07-23 14:24:38 +00:00
parent 87e2b36074
commit 98f21aca86
1 changed files with 32 additions and 22 deletions

View File

@ -38,6 +38,7 @@ import gtk.glade
import common
import dgtk
import pref
class FilesBaseManager(object):
def __init__(self, file_store):
@ -92,19 +93,13 @@ class FilesBaseManager(object):
def file_unselect_all(self, widget):
self.file_view.get_selection().unselect_all()
def compact_warning(self, widget):
def compact_allocation_warning(self):
msgBox = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK,
message_format = (_("File priority can only be set when using full allocation.\nPlease change your preference to disable compact allocation, then remove and readd this torrent.")))
msgBox.run()
msgBox.destroy()
def priority_clicked(self, widget):
import deluge_core
state = deluge_core.get_torrent_state(self.file_unique_id)
print state["compact_mode"]
if state["compact_mode"]:
self.compact_warning(widget)
else:
widget_name = widget.get_name()
priority = {'priority_dont_download': common.PRIORITY_DONT_DOWNLOAD,
'priority_normal': common.PRIORITY_NORMAL,
@ -167,6 +162,14 @@ class FilesTabManager(FilesBaseManager):
def set_unique_id(self, unique_id):
self.file_unique_id = unique_id
def priority_clicked(self, widget):
state = self.manager.get_torrent_state(self.file_unique_id)
print state["compact_mode"]
if state["compact_mode"]:
self.compact_allocation_warning()
else:
super(FilesTabManager, self).priority_clicked(widget)
# From core to UI
def prepare_file_store(self):
if not self.file_store_dict:
@ -199,12 +202,19 @@ class FilesDialogManager(FilesBaseManager):
super(FilesDialogManager, self).__init__(file_store)
self.dumped_torrent = dumped_torrent
self.config = pref.Preferences()
def prepare_file_store(self):
for file in self.dumped_torrent:
self.file_store.append([file['path'], file['size'],
common.PRIORITY_NORMAL])
def priority_clicked(self, widget):
if self.config.get("use_compact_storage"):
self.compact_allocation_warning()
else:
super(FilesDialogManager, self).priority_clicked(widget)
def get_priorities(self):
file_priorities = []
for x in self.file_store: