summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--ranger/core/environment.py20
-rw-r--r--ranger/gui/widgets/browsercolumn.py10
-rw-r--r--ranger/gui/widgets/browserview.py8
-rw-r--r--ranger/gui/widgets/statusbar.py5
5 files changed, 32 insertions, 12 deletions
diff --git a/TODO b/TODO
index 81af21db..964cccc9 100644
--- a/TODO
+++ b/TODO
@@ -47,6 +47,7 @@ General
    (X) #63  10/02/15  limit filesize in previews
    ( ) #64  10/02/25  scroll in previews
    (X) #66  10/02/28  explain how colorschemes work
+   ( ) #70  10/03/14  mouse handler for titlebar
 
 
 Bugs
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index 506e4230..984db57c 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -63,22 +63,32 @@ class Environment(SettingsAware):
 		self.keybuffer.clear()
 
 	def at_level(self, level):
-		"""Returns the FileSystemObject at the given level.
-		level 1 => preview
+		"""
+		Returns the FileSystemObject at the given level.
+		level >0 => previews
 		level 0 => current file/directory
-		level <0 => parent directories"""
+		level <0 => parent directories
+		"""
 		if level <= 0:
 			try:
 				return self.pathway[level - 1]
 			except IndexError:
 				return None
 		else:
+			directory = self.cf
+			for i in range(level - 1):
+				if directory is None:
+					return None
+				if directory.is_directory:
+					directory = directory.pointed_obj
+				else:
+					return None
 			try:
-				return self.directories[self.cf.path]
+				return self.directories[directory.path]
 			except AttributeError:
 				return None
 			except KeyError:
-				return self.cf
+				return directory
 
 	def garbage_collect(self):
 		"""Delete unused directory objects"""
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index b98005b5..51c19b8a 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -53,6 +53,14 @@ class BrowserColumn(Pager, Widget):
 	old_cf = None
 
 	def __init__(self, win, level):
+		"""
+		win = the curses window object of the BrowserView
+		level = what to display?
+
+		level >0 => previews
+		level 0 => current file/directory
+		level <0 => parent directories
+		"""
 		Pager.__init__(self, win)
 		Widget.__init__(self, win)
 		self.level = level
@@ -108,8 +116,6 @@ class BrowserColumn(Pager, Widget):
 
 	def draw(self):
 		"""Call either _draw_file() or _draw_directory()"""
-		from ranger import log
-
 		if self.target != self.old_dir:
 			self.need_redraw = True
 			self.old_dir = self.target
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index 54f21fa9..24bf85b0 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -33,7 +33,7 @@ class BrowserView(Widget, DisplayableContainer):
 
 		# normalize ratios:
 		ratio_sum = float(sum(ratios))
-		self.ratios = tuple(map(lambda x: x / ratio_sum, ratios))
+		self.ratios = tuple(x / ratio_sum for x in ratios)
 
 		if len(self.ratios) >= 2:
 			self.stretch_ratios = self.ratios[:-2] + \
@@ -114,13 +114,13 @@ class BrowserView(Widget, DisplayableContainer):
 				and self.stretch_ratios
 
 		if cut_off_last:
-			generator = zip(self.stretch_ratios, range(len(self.ratios)))
+			generator = enumerate(self.stretch_ratios)
 		else:
-			generator = zip(self.ratios, range(len(self.ratios)))
+			generator = enumerate(self.ratios)
 
 		last_i = len(self.ratios) - 1
 
-		for ratio, i in generator:
+		for i, ratio in generator:
 			wid = int(ratio * self.wid)
 
 			if i == last_i:
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 26f5c7f4..6f52f8ef 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -135,7 +135,8 @@ class StatusBar(Widget):
 	def _get_left_part(self, bar):
 		left = bar.left
 
-		if self.column is not None:
+		if self.column is not None and self.column.target is not None\
+				and self.column.target.is_directory:
 			target = self.column.target.pointed_obj
 		else:
 			target = self.env.at_level(0).pointed_obj
@@ -195,6 +196,8 @@ class StatusBar(Widget):
 			return
 
 		target = self.column.target
+		if target is None:
+			return
 
 		if not target.content_loaded or not target.accessible:
 			return