summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-03-31 15:18:55 +0200
committerhut <hut@lavabit.com>2010-03-31 15:18:55 +0200
commit9e63489ab8bf81ec394e3248a2ef96ee1dc6e640 (patch)
tree0e12b183970275a74d706bd01cfdb11b2a1d27c2 /ranger
parentd9c5f33bc1b1b6e4c7ce82cf8d28c1af62be78cf (diff)
downloadranger-9e63489ab8bf81ec394e3248a2ef96ee1dc6e640.tar.gz
add "move" signal to environment
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/environment.py22
-rw-r--r--ranger/gui/widgets/browserview.py26
2 files changed, 33 insertions, 15 deletions
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index 89088c45..1d1464d2 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -21,15 +21,15 @@ from os.path import abspath, normpath, join, expanduser, isdir
 
 from ranger.fsobject.directory import Directory, NoDirectoryGiven
 from ranger.container import KeyBuffer, History
+from ranger.ext.signal_dispatcher import SignalDispatcher
 from ranger.shared import SettingsAware
 
-class Environment(SettingsAware):
+class Environment(SettingsAware, SignalDispatcher):
 	"""A collection of data which is relevant for more than
 	one class.
 	"""
 
 	cwd = None  # current directory
-	cf = None  # current file
 	copy = None
 	cmd = None
 	cut = None
@@ -42,7 +42,9 @@ class Environment(SettingsAware):
 	keybuffer = None
 
 	def __init__(self, path):
+		SignalDispatcher.__init__(self)
 		self.path = abspath(expanduser(path))
+		self._cf = None
 		self.pathway = ()
 		self.directories = {}
 		self.keybuffer = KeyBuffer()
@@ -59,6 +61,22 @@ class Environment(SettingsAware):
 		from ranger.shared import EnvironmentAware
 		EnvironmentAware.env = self
 
+		self.signal_bind('move', self._set_cf_from_signal, priority=0.1,
+				weak=True)
+
+	def _set_cf_from_signal(self, signal):
+		self._cf = signal.new
+
+	def _set_cf(self, value):
+		if value is not self._cf:
+			previous = self._cf
+			self.signal_emit('move', previous=previous, new=value)
+
+	def _get_cf(self):
+		return self._cf
+
+	cf = property(_get_cf, _set_cf)
+
 	def key_append(self, key):
 		"""Append a key to the keybuffer"""
 
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index e31a21ff..13142be4 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -31,9 +31,6 @@ class BrowserView(Widget, DisplayableContainer):
 		DisplayableContainer.__init__(self, win)
 		self.ratios = ratios
 		self.preview = preview
-		self.old_cf = self.env.cf
-		self.old_prevfile = None
-		self.old_prevdir = None
 
 		# normalize ratios:
 		ratio_sum = float(sum(ratios))
@@ -63,25 +60,28 @@ class BrowserView(Widget, DisplayableContainer):
 		self.pager.visible = False
 		self.add_child(self.pager)
 
+		for option in ('preview_directories', 'preview_files'):
+			self.settings.signal_bind('setopt.' + option,
+					self._request_clear_if_has_borders, weak=True)
+
+		self.fm.env.signal_bind('move', self.request_clear)
+
+	def _request_clear_if_has_borders(self):
+		if self.settings.draw_borders:
+			self.request_clear()
+
+	def request_clear(self):
+		self.need_clear = True
+
 	def draw(self):
 		try:
 			if self.env.cmd.show_obj.draw_bookmarks:
 				self._draw_bookmarks()
 		except AttributeError:
-			if self.old_cf != self.env.cf:
-				self.need_clear = True
-			if self.settings.draw_borders:
-				if self.old_prevdir != self.settings.preview_directories:
-					self.need_clear = True
-				if self.old_prevfile != self.settings.preview_files:
-					self.need_clear = True
 			if self.need_clear:
 				self.win.erase()
 				self.need_redraw = True
 				self.need_clear = False
-				self.old_cf = self.env.cf
-				self.old_prevfile = self.settings.preview_files
-				self.old_prevdir = self.settings.preview_directories
 			DisplayableContainer.draw(self)
 			if self.settings.draw_borders:
 				self._draw_borders()
8f6'>^
59874868 ^



f2818edc ^

6f8f9fb5 ^

795f5244 ^
f2818edc ^
4a943d4e ^















201b2e6c ^
4a943d4e ^










f7d3dc0e ^
1848b18f ^

201b2e6c ^
795f5244 ^
d855b0a0 ^
201b2e6c ^
d855b0a0 ^
2b250717 ^
e4630643 ^

23d3a022 ^
2b250717 ^
e4630643 ^

4f5bb5b6 ^
2b250717 ^
e4630643 ^

f7d3dc0e ^



4f5bb5b6 ^
d855b0a0 ^



dc1323e9 ^
23d3a022 ^
c442a5ad ^
201b2e6c ^

1066660e ^
c442a5ad ^
59874868 ^



201b2e6c ^

4a943d4e ^














201b2e6c ^
4a943d4e ^













201b2e6c ^
4a943d4e ^














23d3a022 ^
1848b18f ^

201b2e6c ^
795f5244 ^
d855b0a0 ^
201b2e6c ^
d855b0a0 ^
2b250717 ^
e4630643 ^

23d3a022 ^
2b250717 ^
e4630643 ^

4f5bb5b6 ^
2b250717 ^
e4630643 ^

f7d3dc0e ^



4f5bb5b6 ^
d855b0a0 ^



dc1323e9 ^
23d3a022 ^
c442a5ad ^
201b2e6c ^

1066660e ^
c442a5ad ^
59874868 ^



201b2e6c ^

4a943d4e ^














201b2e6c ^
4a943d4e ^













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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237