summary refs log tree commit diff stats
path: root/ranger/gui
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-06 14:01:49 +0100
committerhut <hut@lavabit.com>2009-12-06 14:01:49 +0100
commit65cb1a32d4d5f83f48169846afec201ab3b6f9c3 (patch)
treeccd022db0eedc2377e0318085174b96a20d614b9 /ranger/gui
parent465bff736d234e57efb2e9232df8882f3fd3a5cb (diff)
downloadranger-65cb1a32d4d5f83f48169846afec201ab3b6f9c3.tar.gz
"SettingsAware", random cleanups
Diffstat (limited to 'ranger/gui')
-rw-r--r--ranger/gui/colorscheme.py9
-rw-r--r--ranger/gui/ui.py4
-rw-r--r--ranger/gui/wconsole.py7
-rw-r--r--ranger/gui/wdisplay.py10
-rw-r--r--ranger/gui/widget.py3
5 files changed, 17 insertions, 16 deletions
diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py
index 790112ec..3e28106b 100644
--- a/ranger/gui/colorscheme.py
+++ b/ranger/gui/colorscheme.py
@@ -5,9 +5,6 @@ CONTEXT_KEYS = [ 'reset', 'error',
 		'video', 'audio', 'image', 'media', 'document', 'container',
 		'broken', 'selected', 'empty', 'maindisplay']
 
-class ColorSchemeContext():
-	pass
-
 # colorscheme specification:
 #
 # A colorscheme must...
@@ -30,6 +27,8 @@ class ColorSchemeContext():
 # If your colorscheme-file contains more than one colorscheme, specify it with:
 # colorscheme = colorschemes.filename.classname
 
+from ranger.helper import OpenStruct
+
 class ColorScheme(object):
 	def __init__(self):
 		self.cache = {}
@@ -39,10 +38,10 @@ class ColorScheme(object):
 			return self.cache[keys]
 
 		except KeyError:
-			context = ColorSchemeContext()
+			context = OpenStruct()
 
 			for key in CONTEXT_KEYS:
-				context.__dict__[key] = (key in keys)
+				context[key] = (key in keys)
 
 			color = self.use(context)
 			self.cache[keys] = color
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 5cc519b1..b5ae78dc 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -1,6 +1,6 @@
 import curses
 
-class MouseEvent():
+class MouseEvent(object):
 	import curses
 	PRESSED = [ 0,
 			curses.BUTTON1_PRESSED,
@@ -17,7 +17,7 @@ class MouseEvent():
 		except:
 			return False
 
-class UI():
+class UI(object):
 	def __init__(self, env, commandlist, colorscheme):
 		import os
 		os.environ['ESCDELAY'] = '25' # don't know a cleaner way
diff --git a/ranger/gui/wconsole.py b/ranger/gui/wconsole.py
index 9078d781..a0322c42 100644
--- a/ranger/gui/wconsole.py
+++ b/ranger/gui/wconsole.py
@@ -158,6 +158,13 @@ class WConsole(SuperClass):
 		pass
 
 def get_app_flags_mode(line, fm):
+	""" extracts the application, flags and mode from a string entered into the "openwith_quick" console. """
+	# examples:
+	# "mplayer d 1" => ("mplayer", "d", 1)
+	# "aunpack 4" => ("aunpack", "", 4)
+	# "p" => ("", "p", 0)
+	# "" => None
+
 	app = ''
 	flags = ''
 	mode = 0
diff --git a/ranger/gui/wdisplay.py b/ranger/gui/wdisplay.py
index 07111437..fd4f7dec 100644
--- a/ranger/gui/wdisplay.py
+++ b/ranger/gui/wdisplay.py
@@ -10,10 +10,6 @@ class WDisplay(SuperClass):
 
 	def feed_env(self, env):
 		self.target = env.at_level(self.level)
-		self.show_hidden = env.opt['show_hidden']
-		self.scroll_offset = env.opt['scroll_offset']
-		self.directories_first = env.opt['directories_first']
-		self.preview_files = env.opt['preview_files']
 		
 	def click(self, event, fm):
 		from ranger.fsobject import T_DIRECTORY
@@ -59,7 +55,7 @@ class WDisplay(SuperClass):
 			self.win.addnstr(self.y, self.x, "not accessible", self.wid)
 			return
 		
-		if self.preview_files:
+		if self.settings.preview_files:
 			try:
 				if self.target.size < 1024 * 20:
 					f = open(self.target.path, 'r')
@@ -74,9 +70,7 @@ class WDisplay(SuperClass):
 		import curses
 		import stat
 
-		self.target.show_hidden = self.show_hidden
 		self.target.load_content_if_outdated()
-		self.target.directories_first = self.directories_first
 		self.target.sort_if_outdated()
 
 		base_color = ['in_display']
@@ -140,7 +134,7 @@ class WDisplay(SuperClass):
 			self.color_reset()
 
 	def get_scroll_begin(self):
-		offset = self.scroll_offset
+		offset = self.settings.scroll_offset
 		dirsize = len(self.target)
 		winsize = self.hei
 		halfwinsize = winsize // 2
diff --git a/ranger/gui/widget.py b/ranger/gui/widget.py
index fa1ca585..071b88bc 100644
--- a/ranger/gui/widget.py
+++ b/ranger/gui/widget.py
@@ -8,7 +8,8 @@ def combine(keylist, keys):
 	else:
 		return tuple((keylist, ) + keys)
 
-class Widget():
+from ranger.conf import SettingsAware
+class Widget(SettingsAware):
 	def __init__(self, win, colorscheme):
 		self.win = win
 		self.focused = False