summary refs log blame commit diff stats
path: root/doc/uml/idl_includes
blob: fceab64b9c648cdca4f2b6081e951b7ea109f0b6 (plain) (tree)
1
                                 
// "a type" "needed idl_includes"
pan class='oid'>3de15ddd ^
419e4aa5 ^

3de15ddd ^
419e4aa5 ^

bb2a6b16 ^

385642ef ^
bb2a6b16 ^
419e4aa5 ^
3de15ddd ^
385642ef ^
419e4aa5 ^
2bd40e06 ^











5599636d ^
a83460d8 ^
3de15ddd ^
0115ab10 ^
0b8a9d79 ^
fa704bab ^
3de15ddd ^



3201b163 ^
3de15ddd ^


a1274aba ^
b42eb058 ^
a1274aba ^
a808a661 ^
3db854ee ^
a808a661 ^
9b83f114 ^

5382110c ^
e92fe17a ^


39d74d84 ^
e92fe17a ^


3de15ddd ^
83f08a2c ^
c6953a55 ^
419e4aa5 ^
5599636d ^
83f08a2c ^
419e4aa5 ^
385e1e86 ^
3201b163 ^
4fdc58b8 ^



9b83f114 ^
9e0e9fd3 ^
4fdc58b8 ^

4fc56903 ^
9b83f114 ^




9b83f114 ^
ea87d005 ^
5599636d ^

ea87d005 ^
3201b163 ^
99e6cf47 ^
3201b163 ^
385e1e86 ^

3201b163 ^
385e1e86 ^




3201b163 ^

99e6cf47 ^
3201b163 ^



ea87d005 ^
3201b163 ^
99e6cf47 ^



385e1e86 ^
3201b163 ^
ea87d005 ^
3201b163 ^
385e1e86 ^
3201b163 ^

ea87d005 ^
3201b163 ^


385e1e86 ^
3201b163 ^




f0df3fa5 ^
5599636d ^
385e1e86 ^
3201b163 ^
385e1e86 ^
ea87d005 ^
fa704bab ^
ec5dfcb1 ^


b4b0eb24 ^
0115ab10 ^
0115ab10 ^
fae694a0 ^
fa704bab ^
a808a661 ^


2bd40e06 ^






fa704bab ^

bba8d293 ^
f5db66a1 ^
385e1e86 ^
a808a661 ^


2bd40e06 ^
f74834c2 ^
2bd40e06 ^









a808a661 ^


83f08a2c ^

a808a661 ^
83f08a2c ^
a808a661 ^



ab1a2682 ^
b42eb058 ^
a808a661 ^

a808a661 ^




2bd40e06 ^

a808a661 ^
2bd40e06 ^
a808a661 ^
a808a661 ^





d6e2900a ^
a808a661 ^


a808a661 ^



f3bc52e5 ^
a808a661 ^


586f0006 ^



fa704bab ^
7fe6d250 ^
d35bac82 ^

fa704bab ^

444f8361 ^
2b82ef62 ^
7fe6d250 ^
863f85ce ^

ea87d005 ^
2b637413 ^



7fe6d250 ^
489a1616 ^
7fe6d250 ^


85f45f48 ^
7fe6d250 ^





0115ab10 ^
7fe6d250 ^
0115ab10 ^
fa704bab ^
0115ab10 ^

419e4aa5 ^

728fb838 ^
8b60e8ca ^


5599636d ^
e92fe17a ^



bb2a6b16 ^
876e288a ^
bb2a6b16 ^


e92fe17a ^

876e288a ^
e92fe17a ^
419e4aa5 ^
876e288a ^
419e4aa5 ^

5599636d ^

419e4aa5 ^


419e4aa5 ^
728fb838 ^
9b83f114 ^

419e4aa5 ^
a2ccfbe1 ^

419e4aa5 ^
5599636d ^







419e4aa5 ^
5599636d ^
ec5dfcb1 ^
d309f218 ^

ffec67de ^
ffec67de ^


d309f218 ^


ffec67de ^
d309f218 ^

ffec67de ^



5599636d ^


ffec67de ^

dd7a4f63 ^
0b8a9d79 ^




e19f9915 ^
0b8a9d79 ^
e19f9915 ^
0b8a9d79 ^



db9bb0c9 ^
d35bac82 ^
5599636d ^
3201b163 ^
356592fa ^
766a5b6a ^
5599636d ^
356592fa ^

ea87d005 ^
fa704bab ^
728fb838 ^
586f0006 ^
7fe6d250 ^
f6f26231 ^


fa704bab ^
d35bac82 ^

b4b0eb24 ^

586f0006 ^
fa704bab ^
f6f26231 ^
444f8361 ^
fa704bab ^
dd7a4f63 ^

ec5dfcb1 ^
bba8d293 ^
ec5dfcb1 ^

e6710b99 ^
356592fa ^
3db854ee ^
356592fa ^

f6f26231 ^

7fe6d250 ^
f6f26231 ^

92abe81a ^
4fc56903 ^


















419e4aa5 ^
728fb838 ^
419e4aa5 ^

ffec67de ^
728fb838 ^
ffec67de ^
3d625436 ^
ffec67de ^
b0f0027f ^
728fb838 ^
c6953a55 ^

444f8361 ^
db9bb0c9 ^
ea87d005 ^
871c502d ^
728fb838 ^
871c502d ^


728fb838 ^
871c502d ^
ea87d005 ^
3201b163 ^

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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
                                                                 
 



                                                                      
 






                                                                       
 
              


                                         


                             
                                            
                                                            
                                       
                                              
                      

                           
                                                 

                            

                                                                  
                                  
 
                            
                                                                         
                                    
 











                                                       
                                                              
                           
                         
                             
                         
                       



                        
                           


                         
                        
                      
 
                             
                               
 

                                
                              


                                             
                                                


                                                                               
 
                                       
                                                                      
 
                                          
                                                           
 
                                          
 



                                                                             
 
                                                            

                                                                  
                          




                                          
                                            
 

                                 
 
                                       
                               
                       

                                                                                
                     




                                                                      

                                    
                                                     



                                              
 
                                



                                                 
                                                
                                                  
 
                                   
                                                    

                                                              
 


                                              
                                        




                                       
                                                                           
                                      
                                                 
                     
                                 
 
                                  


                                                                      
                   
 
                                   
                                       
 


                                                         






                                                                                                  

                                     
                                                                                     
 
                                                                                      


                                                      
                                            
                                                                           









                                                                                     


                                                                                              

                                                                                             
                                             
                                                                                                  



                                                               
                                                                                         
 

                                                          




                                                                     

                                                                              
                                             
                                                                 
 





                                                                        
                                                               


                                                     



                                                      
                                              


                                            



                                          
 
                                              

                                                                             

                                     
                                             
 
                                    

                                           
 



                                                          
                                            
                                                                       


                                                                            
 





                                                                     
 
                                                         
                                                             
                                            

                                                          

                       
                                               


                                      
                                                  



                                                                      
 
                                                            


                                                              

                                                
                                              
                                            
 
                                                        

                                                                

                                                         


                                              
                                   
                                                                    

                                                   
                                   

                                   
 







                                                      
 
                                                               
 

                                                
                                    


                                  


                                                                        
                     

                                                                        



                                             


                                                        

                                           
 




                                            
                                           
                                                          
                                              



                                                            
                                  
                                                                 
                                                 
 
                    
                                                   
                                                                 

                            
 
                                             
                                                                        
                                           
                                                  


                                   
                                                    

                                                          

                                        
 
                                                               
 
                                                               
                                                  

                                   
                    
                                                                

                                         
                                    
                             
                                                              

                                        

                                              
                                                  

                                   
 


















                                                                                     
                        
                                             

                                                                 
                              
                                 
                           
                              
 
                          
                                                    

                                          
                                             
                                      
 
                                
                                                                 


                                                                               
                                                                   
                                             
 

                                      
# 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/>.

import os.path
import stat
from stat import S_ISLNK, S_ISDIR
from os.path import join, isdir, basename
from collections import deque
from time import time

from ranger.ext.mount_path import mount_path
from ranger.fsobject import BAD_INFO, File, FileSystemObject
from ranger.shared import SettingsAware
from ranger.ext.accumulator import Accumulator
import ranger.fsobject

def sort_by_basename(path):
	"""returns path.basename (for sorting)"""
	return path.basename

def sort_by_basename_icase(path):
	"""returns case-insensitive path.basename (for sorting)"""
	return path.basename_lower

def sort_by_directory(path):
	"""returns 0 if path is a directory, otherwise 1 (for sorting)"""
	return 1 - path.is_directory

def accept_file(fname, hidden_filter, name_filter):
	if hidden_filter:
		try:
			if hidden_filter.search(fname):
				return False
		except:
			if hidden_filter in fname:
				return False
	if name_filter and name_filter not in fname:
		return False
	return True

class Directory(FileSystemObject, Accumulator, SettingsAware):
	is_directory = True
	enterable = False
	load_generator = None
	cycle_list = None
	loading = False

	filenames = None
	files = None
	filter = None
	marked_items = None
	scroll_begin = 0
	scroll_offset = 0

	mount_path = '/'
	disk_usage = 0

	last_update_time = -1
	load_content_mtime = -1

	order_outdated = False
	content_outdated = False
	content_loaded = False

	sort_dict = {
		'basename': sort_by_basename,
		'size': lambda path: -path.size,
		'mtime': lambda path: -(path.stat and path.stat.st_mtime or 1),
		'type': lambda path: path.mimetype,
	}

	def __init__(self, path, **kw):
		assert not os.path.isfile(path), "No directory given!"

		Accumulator.__init__(self)
		FileSystemObject.__init__(self, path, **kw)

		self.marked_items = list()

		for opt in ('sort_directories_first', 'sort', 'sort_reverse',
				'sort_case_insensitive'):
			self.settings.signal_bind('setopt.' + opt,
					self.request_resort, weak=True)

		for opt in ('hidden_filter', 'show_hidden'):
			self.settings.signal_bind('setopt.' + opt,
				self.request_reload, weak=True)
		self.use()

	def request_resort(self):
		self.order_outdated = True

	def request_reload(self):
		self.content_outdated = True

	def get_list(self):
		return self.files

	def mark_item(self, item, val):
		item._mark(val)
		if val:
			if item in self.files and not item in self.marked_items:
				self.marked_items.append(item)
		else:
			while True:
				try:
					self.marked_items.remove(item)
				except ValueError:
					break

	def toggle_mark(self, item):
		self.mark_item(item, not item.marked)

	def toggle_all_marks(self):
		for item in self.files:
			self.toggle_mark(item)

	def mark_all(self, val):
		for item in self.files:
			self.mark_item(item, val)

		if not val:
			del self.marked_items[:]
			self._clear_marked_items()

	def _gc_marked_items(self):
		for item in list(self.marked_items):
			if item.path not in self.filenames:
				self.marked_items.remove(item)

	def _clear_marked_items(self):
		for item in self.marked_items:
			item._mark(False)
		del self.marked_items[:]

	def get_selection(self):
		"""READ ONLY"""
		self._gc_marked_items()
		if self.marked_items:
			return [item for item in self.files if item.marked]
		elif self.pointed_obj:
			return [self.pointed_obj]
		else:
			return []

	def load_bit_by_bit(self):
		"""
		Returns a generator which load a part of the directory
		in each iteration.
		"""

		self.loading = True
		self.load_if_outdated()

		try:
			if self.exists and self.runnable:
				yield
				self.mount_path = mount_path(self.path)

				hidden_filter = not self.settings.show_hidden \
						and self.settings.hidden_filter
				filenames = [join(self.path, fname) \
						for fname in os.listdir(self.path) \
						if accept_file(fname, hidden_filter, self.filter)]
				yield

				self.load_content_mtime = os.stat(self.path).st_mtime

				marked_paths = [obj.path for obj in self.marked_items]

				files = []
				for name in filenames:
					try:
						file_lstat = os.lstat(name)
						if S_ISLNK(file_lstat.st_mode):
							file_stat = os.stat(name)
						else:
							file_stat = file_lstat
						stats = (file_stat, file_lstat)
						is_a_dir = S_ISDIR(file_stat.st_mode)
					except:
						stats = None
						is_a_dir = False
					if is_a_dir:
						try:
							item = self.fm.env.get_directory(name)
						except:
							item = Directory(name, preload=stats,
									path_is_abs=True)
					else:
						item = File(name, preload=stats, path_is_abs=True)
					item.load_if_outdated()
					files.append(item)
					yield

				self.disk_usage = sum(f.size for f in files if f.is_file)

				self.scroll_offset = 0
				self.filenames = filenames
				self.files = files

				self._clear_marked_items()
				for item in self.files:
					if item.path in marked_paths:
						item._mark(True)
						self.marked_items.append(item)
					else:
						item._mark(False)

				self.sort()

				if len(self.files) > 0:
					if self.pointed_obj is not None:
						self.sync_index()
					else:
						self.move(to=0)
			else:
				self.filenames = None
				self.files = None

			self.cycle_list = None
			self.content_loaded = True
			self.last_update_time = time()
			self.correct_pointer()

		finally:
			self.loading = False

	def unload(self):
		self.loading = False
		self.load_generator = None

	def load_content(self, schedule=None):
		"""
		Loads the contents of the directory. Use this sparingly since
		it takes rather long.
		"""
		self.content_outdated = False

		if not self.loading:
			if not self.loaded:
				self.load()

			if not self.accessible:
				self.content_loaded = True
				return

			if schedule is None:
				schedule = True   # was: self.size > 30

			if self.load_generator is None:
				self.load_generator = self.load_bit_by_bit()

				if schedule and self.fm:
					self.fm.loader.add(self)
				else:
					for _ in self.load_generator:
						pass
					self.load_generator = None

			elif not schedule or not self.fm:
				for _ in self.load_generator:
					pass
				self.load_generator = None


	def sort(self):
		"""Sort the containing files"""
		if self.files is None:
			return

		old_pointed_obj = self.pointed_obj
		try:
			sort_func = self.sort_dict[self.settings.sort]
		except:
			sort_func = sort_by_basename

		if self.settings.sort_case_insensitive and \
				sort_func == sort_by_basename:
			sort_func = sort_by_basename_icase

		self.files.sort(key = sort_func)

		if self.settings.sort_reverse:
			self.files.reverse()

		if self.settings.sort_directories_first:
			self.files.sort(key = sort_by_directory)

		if self.pointer is not None:
			self.move_to_obj(old_pointed_obj)
		else:
			self.correct_pointer()

	def sort_if_outdated(self):
		"""Sort the containing files if they are outdated"""
		if self.order_outdated:
			self.order_outdated = False
			self.sort()
			return True
		return False

	def move_to_obj(self, arg):
		try:
			arg = arg.path
		except:
			pass
		self.load_content_once(schedule=False)
		if self.empty():
			return

		Accumulator.move_to_obj(self, arg, attr='path')

	def search_fnc(self, fnc, forward=True):
		if not hasattr(fnc, '__call__'):
			return False

		length = len(self)

		if forward:
			generator = ((self.pointer + (x + 1)) % length \
					for x in range(length-1))
		else:
			generator = ((self.pointer - (x + 1)) % length \
					for x in range(length-1))

		for i in generator:
			_file = self.files[i]
			if fnc(_file):
				self.pointer = i
				self.pointed_obj = _file
				self.correct_pointer()
				return True
		return False

	def set_cycle_list(self, lst):
		self.cycle_list = deque(lst)

	def cycle(self, forward=True):
		if self.cycle_list:
			if forward is True:
				self.cycle_list.rotate(-1)
			elif forward is False:
				self.cycle_list.rotate(1)

			self.move_to_obj(self.cycle_list[0])

	def correct_pointer(self):
		"""Make sure the pointer is in the valid range"""
		Accumulator.correct_pointer(self)

		try:
			if self == self.fm.env.cwd:
				self.fm.env.cf = self.pointed_obj
		except:
			pass

	def load_content_once(self, *a, **k):
		"""Load the contents of the directory if not done yet"""
		if not self.content_loaded:
			self.load_content(*a, **k)
			return True
		return False

	def load_content_if_outdated(self, *a, **k):
		"""
		Load the contents of the directory if it's
		outdated or not done yet
		"""

		if self.load_content_once(*a, **k): return True

		if self.files is None or self.content_outdated:
			self.load_content(*a, **k)
			return True

		try:
			real_mtime = os.stat(self.path).st_mtime
		except OSError:
			real_mtime = None
			return False
		if self.stat:
			cached_mtime = self.load_content_mtime
		else:
			cached_mtime = 0

		if real_mtime != cached_mtime:
			self.load_content(*a, **k)
			return True
		return False

	def get_description(self):
		return "Loading " + str(self)

	def use(self):
		"""mark the filesystem-object as used at the current time"""
		self.last_used = time()

	def is_older_than(self, seconds):
		"""returns whether this object wasn't use()d in the last n seconds"""
		if seconds < 0:
			return True
		return self.last_used + seconds < time()

	def go(self):
		"""enter the directory if the filemanager is running"""
		if self.fm:
			return self.fm.enter_dir(self.path)
		return False

	def empty(self):
		"""Is the directory empty?"""
		return self.files is None or len(self.files) == 0

	def __nonzero__(self):
		"""Always True"""
		return True
	__bool__ = __nonzero__

	def __len__(self):
		"""The number of containing files"""
		assert self.accessible
		assert self.content_loaded
		assert self.files is not None
		return len(self.files)

	def __eq__(self, other):
		"""Check for equality of the directories paths"""
		return isinstance(other, Directory) and self.path == other.path

	def __neq__(self, other):
		"""Check for inequality of the directories paths"""
		return not self.__eq__(other)

	def __hash__(self):
		return hash(self.path)