summaryrefslogtreecommitdiff
path: root/mat-gui
diff options
context:
space:
mode:
authorjvoisin2014-01-06 23:30:28 +0000
committerjvoisin2014-01-06 23:30:28 +0000
commit68e490c9efd0885deca76e5eed5247f87aa8f733 (patch)
treeadcb4d8ebbd55294f52aa32cc26e84f24e6b66a0 /mat-gui
parent9c44ef035133d928afa4cbc41e40883b7460d210 (diff)
GUI-archive-unsupported-handling, 2nd iteration
Diffstat (limited to 'mat-gui')
-rwxr-xr-xmat-gui36
1 files changed, 15 insertions, 21 deletions
diff --git a/mat-gui b/mat-gui
index a1cb446..de0da83 100755
--- a/mat-gui
+++ b/mat-gui
@@ -10,7 +10,6 @@ import gettext
10import logging 10import logging
11import os 11import os
12import sys 12import sys
13import mimetypes
14import xml.sax 13import xml.sax
15import urllib2 14import urllib2
16 15
@@ -69,11 +68,11 @@ class GUI(object):
69 def __init_supported_popup(self): 68 def __init_supported_popup(self):
70 ''' Initialise the "supported formats" popup ''' 69 ''' Initialise the "supported formats" popup '''
71 self.supported_dict = mat.XMLParser() 70 self.supported_dict = mat.XMLParser()
72 parser = xml.sax.make_parser() 71 xml_parser = xml.sax.make_parser()
73 parser.setContentHandler(self.supported_dict) 72 xml_parser.setContentHandler(self.supported_dict)
74 path = os.path.join(mat.get_datadir(), 'FORMATS') 73 path = os.path.join(mat.get_datadir(), 'FORMATS')
75 with open(path, 'r') as xmlfile: 74 with open(path, 'r') as xmlfile:
76 parser.parse(xmlfile) 75 xml_parser.parse(xmlfile)
77 76
78 supported_cbox = self.builder.get_object('supported_cbox') 77 supported_cbox = self.builder.get_object('supported_cbox')
79 store = Gtk.ListStore(int, str) 78 store = Gtk.ListStore(int, str)
@@ -110,8 +109,7 @@ class GUI(object):
110 ''' Fill GtkEntries of the supported_format_popups 109 ''' Fill GtkEntries of the supported_format_popups
111 with corresponding data. 110 with corresponding data.
112 ''' 111 '''
113 i = window.get_active_iter() 112 index = window.get_model()[window.get_active_iter()][0]
114 index = window.get_model()[i][0]
115 support = self.builder.get_object('supported_support') 113 support = self.builder.get_object('supported_support')
116 support.set_text(self.supported_dict.list[index]['support']) 114 support.set_text(self.supported_dict.list[index]['support'])
117 metadata = self.builder.get_object('supported_metadata').get_buffer() 115 metadata = self.builder.get_object('supported_metadata').get_buffer()
@@ -234,14 +232,13 @@ non-anonymised) file to output archive'))
234 232
235 hbox.show_all() 233 hbox.show_all()
236 if not dialog.run(): # Gtk.STOCK_OK 234 if not dialog.run(): # Gtk.STOCK_OK
237 for file in self.liststore: # update preferences 235 for f in self.liststore: # update preferences
238 file[0].file.add2archive = self.add2archive 236 f[0].file.add2archive = self.add2archive
239 if file[0].file.mime.startswith('pdf'): 237 if f[0].file.mime.startswith('pdf'):
240 file[0].file.pdf_quality = self.pdf_quality 238 f[0].file.pdf_quality = self.pdf_quality
241 dialog.hide() 239 dialog.hide()
242 240
243 def cb_drag_data_received(self, widget, context, 241 def cb_drag_data_received(self, widget, context, x, y, selection, target_type, timestamp):
244 x, y, selection, target_type, timestamp):
245 ''' This function is called when something is 242 ''' This function is called when something is
246 drag'n'droped into mat. 243 drag'n'droped into mat.
247 It basically add files. 244 It basically add files.
@@ -266,9 +263,7 @@ non-anonymised) file to output archive'))
266 263
267 def __add_file_to_treeview(self, filename): 264 def __add_file_to_treeview(self, filename):
268 ''' Add a file to the list if its format is supported ''' 265 ''' Add a file to the list if its format is supported '''
269 cf = CFile(filename, add2archive=self.add2archive, 266 cf = CFile(filename, add2archive=self.add2archive, low_pdf_quality=self.pdf_quality)
270 low_pdf_quality=self.pdf_quality)
271 # if the file is supported by the mat, and is writable (for usability's sake).
272 if cf.file and cf.file.is_writable: 267 if cf.file and cf.file.is_writable:
273 self.liststore.append([cf, cf.file.basename, _('Unknown')]) 268 self.liststore.append([cf, cf.file.basename, _('Unknown')])
274 return False 269 return False
@@ -325,8 +320,7 @@ non-anonymised) file to output archive'))
325 320
326 # appends "filename - reason" to the ListStore 321 # appends "filename - reason" to the ListStore
327 for item in filelist: 322 for item in filelist:
328 ext = os.path.splitext(item)[1] 323 if os.path.splitext(item)[1] in parser.NOMETA:
329 if ext in parser.NOMETA:
330 store.append([os.path.basename(item), _('Harmless fileformat')]) 324 store.append([os.path.basename(item), _('Harmless fileformat')])
331 else: 325 else:
332 store.append([os.path.basename(item), _('Fileformat not supported')]) 326 store.append([os.path.basename(item), _('Fileformat not supported')])
@@ -372,14 +366,14 @@ non-anonymised) file to output archive'))
372 366
373 cellrenderer_text = Gtk.CellRendererText() 367 cellrenderer_text = Gtk.CellRendererText()
374 column_text.pack_start(cellrenderer_text, False) 368 column_text.pack_start(cellrenderer_text, False)
375 column_text.add_attribute(cellrenderer_text, "text", 1) 369 column_text.add_attribute(cellrenderer_text, 'text', 1)
376 370
377 cellrenderer_toggle = Gtk.CellRendererToggle() 371 cellrenderer_toggle = Gtk.CellRendererToggle()
378 column_toggle.pack_start(cellrenderer_toggle, True) 372 column_toggle.pack_start(cellrenderer_toggle, True)
379 column_toggle.add_attribute(cellrenderer_toggle, "active", 0) 373 column_toggle.add_attribute(cellrenderer_toggle, 'active', 0)
380 def cell_toggled(widget, path, model): 374 def cell_toggled(widget, path, model):
381 model[path][0] = not model[path][0] 375 model[path][0] = not model[path][0]
382 cellrenderer_toggle.connect("toggled", cell_toggled, store) 376 cellrenderer_toggle.connect('toggled', cell_toggled, store)
383 377
384 vbox.pack_start(treeview, True, True, 0) 378 vbox.pack_start(treeview, True, True, 0)
385 vbox.pack_start(Gtk.Label(_('Thoses files are not recognized by MAT, and' 379 vbox.pack_start(Gtk.Label(_('Thoses files are not recognized by MAT, and'
@@ -433,6 +427,6 @@ if __name__ == '__main__':
433 infiles = [arg for arg in sys.argv[1:] if os.path.exists(arg)] 427 infiles = [arg for arg in sys.argv[1:] if os.path.exists(arg)]
434 if infiles: 428 if infiles:
435 task = gui.populate(infiles) 429 task = gui.populate(infiles)
436 Glib.idle_add(task.next) 430 GLib.idle_add(task.next)
437 431
438 Gtk.main() 432 Gtk.main()