diff options
Diffstat (limited to 'gui.py')
| -rw-r--r-- | gui.py | 64 |
1 files changed, 29 insertions, 35 deletions
| @@ -190,20 +190,19 @@ loss') | |||
| 190 | ''' | 190 | ''' |
| 191 | Add the files chosed by the filechoser ("Add" button) | 191 | Add the files chosed by the filechoser ("Add" button) |
| 192 | ''' | 192 | ''' |
| 193 | chooser = gtk.FileChooserDialog( | 193 | chooser = gtk.FileChooserDialog(title='Choose files', |
| 194 | title='Choose files', | 194 | parent=self.window, action=gtk.FILE_CHOOSER_ACTION_OPEN, |
| 195 | parent=self.window, | ||
| 196 | action=gtk.FILE_CHOOSER_ACTION_OPEN, | ||
| 197 | buttons=(gtk.STOCK_OK, 0, gtk.STOCK_CANCEL, 1)) | 195 | buttons=(gtk.STOCK_OK, 0, gtk.STOCK_CANCEL, 1)) |
| 198 | chooser.set_default_response(0) | 196 | chooser.set_default_response(0) |
| 199 | chooser.set_select_multiple(True) | 197 | chooser.set_select_multiple(True) |
| 200 | 198 | ||
| 201 | all_filter = gtk.FileFilter() | 199 | all_filter = gtk.FileFilter() # filter that shows all files |
| 202 | all_filter.set_name('All files') | 200 | all_filter.set_name('All files') |
| 203 | all_filter.add_pattern('*') | 201 | all_filter.add_pattern('*') |
| 204 | chooser.add_filter(all_filter) | 202 | chooser.add_filter(all_filter) |
| 205 | 203 | ||
| 206 | supported_filter = gtk.FileFilter() | 204 | supported_filter = gtk.FileFilter() |
| 205 | # filter that shows only supported formats | ||
| 207 | [supported_filter.add_mime_type(i) for i in mat.STRIPPERS.keys()] | 206 | [supported_filter.add_mime_type(i) for i in mat.STRIPPERS.keys()] |
| 208 | supported_filter.set_name('Supported files') | 207 | supported_filter.set_name('Supported files') |
| 209 | chooser.add_filter(supported_filter) | 208 | chooser.add_filter(supported_filter) |
| @@ -251,10 +250,10 @@ loss') | |||
| 251 | ''' | 250 | ''' |
| 252 | List the supported formats | 251 | List the supported formats |
| 253 | ''' | 252 | ''' |
| 254 | dialog = gtk.Dialog('Supported formats', None, 0, (gtk.STOCK_CLOSE, 0)) | 253 | dialog = gtk.Dialog('Supported formats', self.window, 0, |
| 255 | content_area = dialog.get_content_area() | 254 | (gtk.STOCK_CLOSE, 0)) |
| 256 | vbox = gtk.VBox(spacing=5) | 255 | vbox = gtk.VBox(spacing=5) |
| 257 | content_area.pack_start(vbox, True, True, 0) | 256 | dialog.get_content_area().pack_start(vbox, True, True, 0) |
| 258 | 257 | ||
| 259 | label = gtk.Label() | 258 | label = gtk.Label() |
| 260 | label.set_markup('<big><u>Supported fileformats</u></big>') | 259 | label.set_markup('<big><u>Supported fileformats</u></big>') |
| @@ -293,54 +292,55 @@ loss') | |||
| 293 | Preferences popup | 292 | Preferences popup |
| 294 | ''' | 293 | ''' |
| 295 | dialog = gtk.Dialog('Preferences', self.window, 0, (gtk.STOCK_OK, 0)) | 294 | dialog = gtk.Dialog('Preferences', self.window, 0, (gtk.STOCK_OK, 0)) |
| 296 | content_area = dialog.get_content_area() | ||
| 297 | hbox = gtk.HBox() | 295 | hbox = gtk.HBox() |
| 298 | content_area.pack_start(hbox, False, False, 0) | 296 | dialog.get_content_area().pack_start(hbox, False, False, 0) |
| 297 | |||
| 299 | icon = gtk.Image() | 298 | icon = gtk.Image() |
| 300 | icon.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_DIALOG) | 299 | icon.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_DIALOG) |
| 301 | |||
| 302 | hbox.pack_start(icon, False, False, 0) | 300 | hbox.pack_start(icon, False, False, 0) |
| 303 | 301 | ||
| 304 | table = gtk.Table(3, 2, False) # nb rows, nb lines | 302 | table = gtk.Table(3, 2, False) # nb rows, nb lines |
| 305 | table.set_row_spacings(4) | ||
| 306 | table.set_col_spacings(4) | ||
| 307 | hbox.pack_start(table, True, True, 0) | 303 | hbox.pack_start(table, True, True, 0) |
| 308 | 304 | ||
| 309 | force = gtk.CheckButton('Force Clean', False) | 305 | force = gtk.CheckButton('Force Clean', False) |
| 310 | force.connect('toggled', self.invert, 'force') | 306 | force.connect('toggled', self.invert, 'force') |
| 311 | force.set_tooltip_text('Do not check if already clean before cleaning') | 307 | force.set_tooltip_text('Do not check if already clean before cleaning') |
| 312 | force.set_active(self.force) | 308 | force.set_active(not self.force) |
| 309 | table.attach(force, 0, 1, 0, 1) | ||
| 313 | 310 | ||
| 314 | backup = gtk.CheckButton('Backup', False) | 311 | backup = gtk.CheckButton('Backup', False) |
| 315 | backup.connect('toggled', self.invert, 'backup') | 312 | backup.connect('toggled', self.invert, 'backup') |
| 316 | backup.set_tooltip_text('Keep a backup copy') | 313 | backup.set_tooltip_text('Keep a backup copy') |
| 317 | backup.set_active(self.backup) | 314 | backup.set_active(not self.backup) |
| 315 | table.attach(backup, 0, 1, 1, 2) | ||
| 318 | 316 | ||
| 319 | add2archive = gtk.CheckButton('Add unsupported file to archives', | 317 | add2archive = gtk.CheckButton('Add unsupported file to archives', |
| 320 | False) | 318 | False) |
| 321 | add2archive.connect('toggled', self.invert, 'add2archive') | 319 | add2archive.connect('toggled', self.invert, 'add2archive') |
| 322 | add2archive.set_tooltip_text('Add non-supported (and so \ | 320 | add2archive.set_tooltip_text('Add non-supported (and so \ |
| 323 | non-anonymised) file to outputed archive') | 321 | non-anonymised) file to outputed archive') |
| 324 | add2archive.set_active(self.add2archive) | 322 | add2archive.set_active(not self.add2archive) |
| 325 | 323 | table.attach(add2archive, 0, 1, 2, 3) | |
| 326 | table.attach_defaults(force, 0, 1, 0, 1) | ||
| 327 | table.attach_defaults(backup, 0, 1, 1, 2) | ||
| 328 | table.attach_defaults(add2archive, 0, 1, 2, 3) | ||
| 329 | 324 | ||
| 330 | hbox.show_all() | 325 | hbox.show_all() |
| 331 | response = dialog.run() | 326 | response = dialog.run() |
| 332 | if response is 0: # gtk.STOCK_OK | 327 | if response is 0: # gtk.STOCK_OK |
| 333 | dialog.destroy() | 328 | dialog.destroy() |
| 334 | 329 | ||
| 335 | def invert(self, _, name): # still not better :/ | 330 | def invert(self, button, name): # still not better :/ |
| 336 | ''' | 331 | ''' |
| 337 | Invert a preference state | 332 | Invert a preference state |
| 338 | ''' | 333 | ''' |
| 339 | if name is 'force': | 334 | print self.force |
| 335 | print self.backup | ||
| 336 | print self.add2archive | ||
| 337 | print name | ||
| 338 | print '\n' | ||
| 339 | if name == 'force': | ||
| 340 | self.force = not self.force | 340 | self.force = not self.force |
| 341 | elif name is 'add2archive': | 341 | elif name == 'add2archive': |
| 342 | self.add2archive = not self.add2archive | 342 | self.add2archive = not self.add2archive |
| 343 | elif name is 'backup': | 343 | elif name == 'backup': |
| 344 | self.backup = not self.backup | 344 | self.backup = not self.backup |
| 345 | 345 | ||
| 346 | def clear_model(self, _): | 346 | def clear_model(self, _): |
| @@ -354,10 +354,10 @@ non-anonymised) file to outputed archive') | |||
| 354 | if no elements are selected, all elements are processed | 354 | if no elements are selected, all elements are processed |
| 355 | thank's to this function | 355 | thank's to this function |
| 356 | ''' | 356 | ''' |
| 357 | if not iterator: | 357 | if iterator: |
| 358 | return xrange(len(self.liststore)) | ||
| 359 | else: | ||
| 360 | return iterator | 358 | return iterator |
| 359 | else: | ||
| 360 | return xrange(len(self.liststore)) | ||
| 361 | 361 | ||
| 362 | def mat_check(self, _): | 362 | def mat_check(self, _): |
| 363 | ''' | 363 | ''' |
| @@ -382,11 +382,8 @@ non-anonymised) file to outputed archive') | |||
| 382 | for i in iterator: | 382 | for i in iterator: |
| 383 | logging.info('Cleaning %s' % self.liststore[i][1]) | 383 | logging.info('Cleaning %s' % self.liststore[i][1]) |
| 384 | if self.liststore[i][3] is not 'clean': | 384 | if self.liststore[i][3] is not 'clean': |
| 385 | if self.force: | 385 | if self.force or not self.liststore[i][0].file.is_clean(): |
| 386 | self.liststore[i][0].file.remove_all() | 386 | self.liststore[i][0].file.remove_all() |
| 387 | else: | ||
| 388 | if not self.liststore[i][0].file.is_clean(): | ||
| 389 | self.liststore[i][0].file.remove_all() | ||
| 390 | self.liststore[i][3] = 'clean' | 387 | self.liststore[i][3] = 'clean' |
| 391 | 388 | ||
| 392 | def mat_clean_dirty(self, _): | 389 | def mat_clean_dirty(self, _): |
| @@ -398,11 +395,8 @@ non-anonymised) file to outputed archive') | |||
| 398 | for i in iterator: | 395 | for i in iterator: |
| 399 | logging.info('Cleaning (lossy way) %s' % self.liststore[i][1]) | 396 | logging.info('Cleaning (lossy way) %s' % self.liststore[i][1]) |
| 400 | if self.liststore[i][3] is not 'clean': | 397 | if self.liststore[i][3] is not 'clean': |
| 401 | if self.force: | 398 | if self.force or not self.liststore[i][0].file.is_clean(): |
| 402 | self.liststore[i][0].file.remove_all_ugly() | 399 | self.liststore[i][0].file.remove_all_ugly() |
| 403 | else: | ||
| 404 | if not self.liststore[i][0].file.is_clean(): | ||
| 405 | self.liststore[i][0].file.remove_all_ugly() | ||
| 406 | self.liststore[i][3] = 'clean' | 400 | self.liststore[i][3] = 'clean' |
| 407 | 401 | ||
| 408 | 402 | ||
