summaryrefslogtreecommitdiff
path: root/gui.py
diff options
context:
space:
mode:
authorjvoisin2011-08-07 22:49:25 +0200
committerjvoisin2011-08-07 22:49:25 +0200
commit4526c38014b9ad346f554efd0bf95271e88e8011 (patch)
tree8d24654db9a5af8d14bcf615e27571ef276dfbff /gui.py
parent74c556310ede8b613d3eb9db1f7f771b37c3dac0 (diff)
Fix a stupid bug who prevented the user to add a single file to the gui.
Diffstat (limited to 'gui.py')
-rw-r--r--gui.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/gui.py b/gui.py
index 520bc5a..162f3f0 100644
--- a/gui.py
+++ b/gui.py
@@ -222,16 +222,26 @@ loss')
222 Append selected files by add_file to the self.liststore 222 Append selected files by add_file to the self.liststore
223 ''' 223 '''
224 for filename in filenames: # filenames : all selected files/folders 224 for filename in filenames: # filenames : all selected files/folders
225 for root, dirs, files in os.walk(filename): 225 if os.path.isdir(filename): # directory
226 for item in files: 226 for root, dirs, files in os.walk(filename):
227 path_to_file = os.path.join(root, item) 227 for item in files:
228 cf = CFile(path_to_file, self.backup, self.add2archive) 228 path_to_file = os.path.join(root, item)
229 if cf.file is not None: 229 self.add_file_to_treeview(path_to_file)
230 self.liststore.append([cf, cf.file.basename, 230 else:
231 cf.file.mime, 'unknow']) 231 self.add_file_to_treeview(filename)
232 yield True 232 yield True
233 yield False 233 yield False
234 234
235 def add_file_to_treeview(self, filename):
236 '''
237 Add a file to the list if his format is supported
238 '''
239 cf = CFile(filename, self.backup, self.add2archive)
240 if cf.file is not None:
241 self.liststore.append([cf, cf.file.basename,
242 cf.file.mime, 'unknow'])
243
244
235 def about(self, _): 245 def about(self, _):
236 ''' 246 '''
237 About popup 247 About popup
@@ -340,21 +350,21 @@ non-anonymised) file to outputed archive')
340 elif name == 'add2archive': 350 elif name == 'add2archive':
341 self.add2archive = not self.add2archive 351 self.add2archive = not self.add2archive
342 352
343 def process_files(self, button, function): 353 def process_files(self, button, func):
344 ''' 354 '''
345 Launch the function "function" in a asynchrone way 355 Launch the function "function" in a asynchrone way
346 ''' 356 '''
347 iterator = self.selection.get_selected_rows()[1] 357 iterator = self.selection.get_selected_rows()[1]
348 if not iterator: # if nothing is selected : select everything 358 if not iterator: # if nothing is selected : select everything
349 iterator = xrange(len(self.liststore)) 359 iterator = xrange(len(self.liststore))
350 task = function(iterator) # asynchrone way 360 task = func(iterator) # launch func() in an asynchrone way
351 gobject.idle_add(task.next) 361 gobject.idle_add(task.next)
352 362
353 def mat_check(self, iterator): 363 def mat_check(self, iterator):
354 ''' 364 '''
355 Check if selected elements are clean 365 Check if selected elements are clean
356 ''' 366 '''
357 for line in iterator: 367 for line in iterator: # for each file in selection
358 if self.liststore[line][0].file.is_clean(): 368 if self.liststore[line][0].file.is_clean():
359 string = 'clean' 369 string = 'clean'
360 else: 370 else:
@@ -368,7 +378,7 @@ non-anonymised) file to outputed archive')
368 ''' 378 '''
369 Clean selected elements 379 Clean selected elements
370 ''' 380 '''
371 for line in iterator: 381 for line in iterator: # for each file in selection
372 logging.info('Cleaning %s' % self.liststore[line][1]) 382 logging.info('Cleaning %s' % self.liststore[line][1])
373 if self.liststore[line][3] is not 'clean': 383 if self.liststore[line][3] is not 'clean':
374 if self.force or not self.liststore[line][0].file.is_clean(): 384 if self.force or not self.liststore[line][0].file.is_clean():
@@ -381,9 +391,7 @@ non-anonymised) file to outputed archive')
381 ''' 391 '''
382 Clean selected elements (ugly way) 392 Clean selected elements (ugly way)
383 ''' 393 '''
384 _, iterator = self.selection.get_selected_rows() 394 for line in iterator: # for each file in selection
385 iterator = self.all_if_empy(iterator)
386 for line in iterator:
387 logging.info('Cleaning (lossy way) %s' % self.liststore[line][1]) 395 logging.info('Cleaning (lossy way) %s' % self.liststore[line][1])
388 if self.liststore[line][3] is not 'clean': 396 if self.liststore[line][3] is not 'clean':
389 if self.force or not self.liststore[line][0].file.is_clean(): 397 if self.force or not self.liststore[line][0].file.is_clean():