summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2011-09-20 11:32:45 +0200
committerjvoisin2011-09-20 11:32:45 +0200
commit18ced164b6a9d84541d289947754a7f729d24df9 (patch)
tree987557db868ce0ef845aadab005aeebec8a03ef9
parentea2fce7e6671f6b988ab012be0a08cce9cf9ca17 (diff)
The GUI now support command-line file adding (4ZM)
-rwxr-xr-xmat-gui17
1 files changed, 14 insertions, 3 deletions
diff --git a/mat-gui b/mat-gui
index e19ac17..ed65f2c 100755
--- a/mat-gui
+++ b/mat-gui
@@ -12,6 +12,7 @@ import gettext
12import locale 12import locale
13import logging 13import logging
14import os 14import os
15import sys
15import mimetypes 16import mimetypes
16import xml.sax 17import xml.sax
17 18
@@ -275,7 +276,7 @@ data loss, but clean more efficiently'))
275 not_supported.append(item) 276 not_supported.append(item)
276 else: # filename is a regular file 277 else: # filename is a regular file
277 if self.add_file_to_treeview(filename): 278 if self.add_file_to_treeview(filename):
278 not_supported.append(item) 279 not_supported.append(filename)
279 yield True 280 yield True
280 #self.popup_non_supported(not_supported) 281 #self.popup_non_supported(not_supported)
281 if len(not_supported): 282 if len(not_supported):
@@ -286,6 +287,10 @@ data loss, but clean more efficiently'))
286 ''' 287 '''
287 Add a file to the list if it's format is supported 288 Add a file to the list if it's format is supported
288 ''' 289 '''
290 if not os.path.isfile(filename):
291 # if filename does not exist
292 return False
293
289 cf = CFile(filename, self.backup, self.add2archive) 294 cf = CFile(filename, self.backup, self.add2archive)
290 if cf.file is not None: # if the file is supported by the mat 295 if cf.file is not None: # if the file is supported by the mat
291 self.liststore.append([cf, cf.file.basename, 296 self.liststore.append([cf, cf.file.basename,
@@ -638,7 +643,6 @@ class TreeViewTooltips(object):
638 name = model[path][0] 643 name = model[path][0]
639 return name.file.filename 644 return name.file.filename
640 645
641
642if __name__ == '__main__': 646if __name__ == '__main__':
643 #Translations 647 #Translations
644 t = gettext.translation('gui', 'locale', fallback=True) 648 t = gettext.translation('gui', 'locale', fallback=True)
@@ -646,5 +650,12 @@ if __name__ == '__main__':
646 t.install() 650 t.install()
647 651
648 #Main 652 #Main
649 GUI() 653 gui = GUI()
654
655 #Add files from command line
656 infiles = [arg for arg in sys.argv[1:] if os.path.exists(arg)]
657 if infiles:
658 task = gui.populate(infiles)
659 gobject.idle_add(task.next)
660
650 gtk.main() 661 gtk.main()