Merge branch 'Add-F2' into 1.3-stable

This commit is contained in:
Calum Lind 2011-05-27 23:47:43 +01:00
commit b0e38d7bde
4 changed files with 77 additions and 55 deletions

View File

@ -165,6 +165,18 @@ def get_default_download_dir():
if windows_check(): if windows_check():
return os.path.expanduser("~") return os.path.expanduser("~")
else: else:
from xdg.BaseDirectory import xdg_config_home
userdir_file = os.path.join(xdg_config_home, 'user-dirs.dirs')
try:
for line in open(userdir_file, 'r'):
if not line.startswith('#') and 'XDG_DOWNLOAD_DIR' in line:
download_dir = os.path.expandvars(\
line.partition("=")[2].rstrip().strip('"'))
if os.path.isdir(download_dir):
return download_dir
except IOError:
pass
return os.environ.get("HOME") return os.environ.get("HOME")
def windows_check(): def windows_check():

View File

@ -271,7 +271,7 @@ class GtkUI(GtkPluginBase):
def create_columns(self, treeView): def create_columns(self, treeView):
rendererToggle = gtk.CellRendererToggle() rendererToggle = gtk.CellRendererToggle()
column = gtk.TreeViewColumn("On", rendererToggle, activatable=True, active=1) column = gtk.TreeViewColumn("On", rendererToggle, activatable=1, active=1)
column.set_sort_column_id(1) column.set_sort_column_id(1)
treeView.append_column(column) treeView.append_column(column)
tt = gtk.Tooltip() tt = gtk.Tooltip()

View File

@ -42,7 +42,7 @@ from setuptools import setup
__plugin_name__ = "AutoAdd" __plugin_name__ = "AutoAdd"
__author__ = "Chase Sterling" __author__ = "Chase Sterling"
__author_email__ = "chase.sterling@gmail.com" __author_email__ = "chase.sterling@gmail.com"
__version__ = "1.02" __version__ = "1.03"
__url__ = "http://dev.deluge-torrent.org/wiki/Plugins/AutoAdd" __url__ = "http://dev.deluge-torrent.org/wiki/Plugins/AutoAdd"
__license__ = "GPLv3" __license__ = "GPLv3"
__description__ = "Monitors folders for .torrent files." __description__ = "Monitors folders for .torrent files."

View File

@ -119,7 +119,8 @@ class FilesTab(Tab):
self._editing_index = None self._editing_index = None
# Filename column # Filename column
column = gtk.TreeViewColumn(_("Filename")) self.filename_column_name = _("Filename")
column = gtk.TreeViewColumn(self.filename_column_name)
render = gtk.CellRendererPixbuf() render = gtk.CellRendererPixbuf()
column.pack_start(render, False) column.pack_start(render, False)
column.add_attribute(render, "stock-id", 6) column.add_attribute(render, "stock-id", 6)
@ -437,9 +438,8 @@ class FilesTab(Tab):
""" """
Go through the tree and update the folder complete percentages. Go through the tree and update the folder complete percentages.
""" """
root = self.treestore.get_iter_root() root = self.treestore.get_iter_root()
if self.treestore[root][5] != -1: if root is None or self.treestore[root][5] != -1:
return return
def get_completed_bytes(row): def get_completed_bytes(row):
@ -482,7 +482,10 @@ class FilesTab(Tab):
if self._editing_index == row[5]: if self._editing_index == row[5]:
continue continue
progress_string = "%.2f%%" % (status["file_progress"][index] * 100) try:
progress_string = "%.2f%%" % (status["file_progress"][index] * 100)
except IndexError:
continue
if row[2] != progress_string: if row[2] != progress_string:
row[2] = progress_string row[2] = progress_string
progress_value = status["file_progress"][index] * 100 progress_value = status["file_progress"][index] * 100
@ -501,17 +504,15 @@ class FilesTab(Tab):
# We only care about right-clicks # We only care about right-clicks
if event.button == 3: if event.button == 3:
x, y = event.get_coords() x, y = event.get_coords()
path = self.listview.get_path_at_pos(int(x), int(y)) cursor_path = self.listview.get_path_at_pos(int(x), int(y))
if not path: if not cursor_path:
return return
row = self.treestore.get_iter(path[0])
if self.get_selected_files(): paths = self.listview.get_selection().get_selected_rows()[1]
if self.treestore.get_value(row, 5) not in self.get_selected_files(): if cursor_path[0] not in paths:
row = self.treestore.get_iter(cursor_path[0])
self.listview.get_selection().unselect_all() self.listview.get_selection().unselect_all()
self.listview.get_selection().select_iter(row) self.listview.get_selection().select_iter(row)
else:
self.listview.get_selection().select_iter(row)
for widget in self.file_menu_priority_items: for widget in self.file_menu_priority_items:
widget.set_sensitive(not self.__compact) widget.set_sensitive(not self.__compact)
@ -520,16 +521,25 @@ class FilesTab(Tab):
return True return True
def _on_key_press_event(self, widget, event): def _on_key_press_event(self, widget, event):
# Menu key keyname = gtk.gdk.keyval_name(event.keyval)
if gtk.gdk.keyval_name(event.keyval) != "Menu": func = getattr(self, 'keypress_' + keyname, None)
return selected_rows = self.listview.get_selection().get_selected_rows()[1]
if func and selected_rows:
if not self.get_selected_files(): return func(event)
else:
return return
def keypress_Menu(self, event):
self.file_menu.popup(None, None, None, 3, event.time) self.file_menu.popup(None, None, None, 3, event.time)
return True return True
def keypress_F2(self, event):
path, col = self.listview.get_cursor()
for column in self.listview.get_columns():
if column.get_title() == self.filename_column_name:
self.listview.set_cursor(path, column, True)
return True
def _on_menuitem_open_file_activate(self, menuitem): def _on_menuitem_open_file_activate(self, menuitem):
self._on_row_activated(None, None, None) self._on_row_activated(None, None, None)