summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-23 02:05:32 +0100
committerhut <hut@lavabit.com>2010-01-23 02:05:32 +0100
commit8e1de9174e18bf804bde3186a3a893698fcf7f78 (patch)
treec2d7de58ab85a568f0957c2187f8efd73e7fc654
parentccc950aadf21f864d07edb79fd54f6c82134f5eb (diff)
downloadranger-8e1de9174e18bf804bde3186a3a893698fcf7f78.tar.gz
apps: bugfixes
-rw-r--r--ranger/defaults/apps.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py
index 935b3578..49233ce3 100644
--- a/ranger/defaults/apps.py
+++ b/ranger/defaults/apps.py
@@ -144,7 +144,7 @@ class CustomApplications(Applications):
 	
 	@depends_on('zsnes')
 	def app_zsnes(self, c):
-		return tup("zsnes", c.file)
+		return tup("zsnes", c.file.path)
 	
 	@depends_on('evince')
 	def app_evince(self, c):
@@ -152,7 +152,7 @@ class CustomApplications(Applications):
 	
 	@depends_on('wine')
 	def app_wine(self, c):
-		return tup("wine", c.file)
+		return tup("wine", c.file.path)
 
 	@depends_on('totem')
 	def app_totem(self, c):
.0&id=4162b636289f065b056e180389456d9f30ee796c'>^
24cd97b7 ^
















733dbb9d ^
24cd97b7 ^
65cb1a32 ^


733dbb9d ^












b6aff4c3 ^
733dbb9d ^


24cd97b7 ^

b6aff4c3 ^










733dbb9d ^





















65cb1a32 ^
b6aff4c3 ^

24cd97b7 ^













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
                                                                 
 



                                                                      
 






                                                                       
 
                                            
 
















                                                                             
 
                              


                               












                                                                                                   
                                                                                                  


                                   

                                                  










                                                        





















                                                                                            
 

                                                  













                                                                                   
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from ranger.ext.openstruct import OpenStruct

ALLOWED_SETTINGS = {
	'show_hidden': bool,
	'show_cursor': bool,
	'autosave_bookmarks': bool,
	'collapse_preview': bool,
	'sort': str,
	'reverse': bool,
	'directories_first': bool,
	'update_title': bool,
	'max_filesize_for_preview': (int, type(None)),
	'max_history_size': (int, type(None)),
	'scroll_offset': int,
	'preview_files': bool,
	'flushinput': bool,
	'colorscheme': object,
	'hidden_filter': lambda x: isinstance(x, str) or hasattr(x, 'match'),
}

# -- globalize the settings --
class SettingsAware(object):
	settings = OpenStruct()

	@staticmethod
	def _setup():
		from inspect import isclass, ismodule
		from ranger.gui.colorscheme import ColorScheme

		# overwrite single default options with custom options
		from ranger.defaults import options
		try:
			import options as custom_options
			for setting in ALLOWED_SETTINGS:
				if hasattr(custom_options, setting):
					setattr(options, setting, getattr(custom_options, setting))
				elif not hasattr(options, setting):
					raise Exception("This option was not defined: " + setting)
		except ImportError:
			pass

		assert check_option_types(options)

		try:
			import apps
		except ImportError:
			from ranger.defaults import apps

		try:
			import keys
		except ImportError:
			from ranger.defaults import keys


		# If a module is specified as the colorscheme, replace it with one
		# valid colorscheme inside that module.

		if isclass(options.colorscheme) and \
				issubclass(options.colorscheme, ColorScheme):
			options.colorscheme = options.colorscheme()

		elif ismodule(options.colorscheme):
			for var_name in dir(options.colorscheme):
				var = getattr(options.colorscheme, var_name)
				if var != ColorScheme and isclass(var) \
						and issubclass(var, ColorScheme):
					options.colorscheme = var()
					break
			else:
				raise Exception("The module contains no valid colorscheme!")

		else:
			raise Exception("Cannot locate colorscheme!")

		for setting in ALLOWED_SETTINGS:
			SettingsAware.settings[setting] = getattr(options, setting)

		SettingsAware.settings.keys = keys
		SettingsAware.settings.apps = apps


def check_option_types(opt):
	import inspect
	for name, typ in ALLOWED_SETTINGS.items():
		optvalue = getattr(opt, name)
		if inspect.isfunction(typ):
			assert typ(optvalue), \
				"The option `" + name + "' has an incorrect type!"
		else:
			assert isinstance(optvalue, typ), \
				"The option `" + name + "' has an incorrect type!"\
				" Expected " + str(typ) + "!"
	return True