summaryrefslogtreecommitdiff
path: root/mat-gui
diff options
context:
space:
mode:
Diffstat (limited to 'mat-gui')
-rwxr-xr-xmat-gui34
1 files changed, 31 insertions, 3 deletions
diff --git a/mat-gui b/mat-gui
index e23207d..9ea49b2 100755
--- a/mat-gui
+++ b/mat-gui
@@ -17,6 +17,7 @@ import mimetypes
17import xml.sax 17import xml.sax
18 18
19from mat import mat 19from mat import mat
20from mat import strippers
20 21
21__version__ = '0.1' 22__version__ = '0.1'
22__author__ = 'jvoisin' 23__author__ = 'jvoisin'
@@ -74,6 +75,10 @@ class GUI:
74 self.treeview.set_search_column(1) # filename column is searchable 75 self.treeview.set_search_column(1) # filename column is searchable
75 self.treeview.set_rules_hint(True) # alternate colors for rows 76 self.treeview.set_rules_hint(True) # alternate colors for rows
76 self.treeview.set_rubber_banding(True) # mouse selection 77 self.treeview.set_rubber_banding(True) # mouse selection
78 self.treeview.connect('drag_data_received', self.on_drag_data_received)
79 self.treeview.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
80 gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP,
81 [('text/uri-list', 0, 80)], gtk.gdk.ACTION_COPY)
77 self.add_columns() 82 self.add_columns()
78 self.selection = self.treeview.get_selection() 83 self.selection = self.treeview.get_selection()
79 self.selection.set_mode(gtk.SELECTION_MULTIPLE) 84 self.selection.set_mode(gtk.SELECTION_MULTIPLE)
@@ -250,7 +255,7 @@ data loss, but clean more efficiently'))
250 255
251 supported_filter = gtk.FileFilter() 256 supported_filter = gtk.FileFilter()
252 # filter that shows only supported formats 257 # filter that shows only supported formats
253 [supported_filter.add_mime_type(i) for i in mat.STRIPPERS.keys()] 258 [supported_filter.add_mime_type(i) for i in strippers.STRIPPERS.keys()]
254 supported_filter.set_name(_('Supported files')) 259 supported_filter.set_name(_('Supported files'))
255 chooser.add_filter(supported_filter) 260 chooser.add_filter(supported_filter)
256 261
@@ -299,7 +304,6 @@ data loss, but clean more efficiently'))
299 else: 304 else:
300 return True 305 return True
301 306
302
303 def popup_non_supported(self, filelist): 307 def popup_non_supported(self, filelist):
304 ''' 308 '''
305 Popup that warn the user about the unsupported files 309 Popup that warn the user about the unsupported files
@@ -448,9 +452,33 @@ non-anonymised) file to output archive'))
448 elif name == 'add2archive': 452 elif name == 'add2archive':
449 self.add2archive = not self.add2archive 453 self.add2archive = not self.add2archive
450 454
455 def on_drag_data_received(self, widget, context,
456 x, y, selection, target_type, timestamp):
457 '''
458 This function is called when something is
459 drag'n'droped into mat.
460 It basically add files.
461 '''
462 urls = selection.data.strip('\r\n\x00') # strip stupid characters
463 cleaned_urls = map(self.clean_draged_file_path, urls.split())
464 task = self.populate(cleaned_urls)
465 gobject.idle_add(task.next) # asynchrone processing
466
467 def clean_draged_file_path(self, url):
468 '''
469 Since the dragged urls are ugly,
470 we need to process them
471 '''
472 if url.startswith('file:\\\\\\'): # windows
473 return url[8:] # 8 is len('file:///')
474 elif url.startswith('file://'): # nautilus, rox
475 return url[7:] # 7 is len('file://')
476 elif url.startswith('file:'): # xffm
477 return url[5:] # 5 is len('file:')
478
451 def process_files(self, button, func): 479 def process_files(self, button, func):
452 ''' 480 '''
453 Launch the function "function" in a asynchrone way 481 Launch the function "func" in a asynchrone way
454 ''' 482 '''
455 iterator = self.selection.get_selected_rows()[1] 483 iterator = self.selection.get_selected_rows()[1]
456 if not iterator: # if nothing is selected : select everything 484 if not iterator: # if nothing is selected : select everything