diff options
| author | jvoisin | 2011-09-20 11:32:45 +0200 |
|---|---|---|
| committer | jvoisin | 2011-09-20 11:32:45 +0200 |
| commit | 18ced164b6a9d84541d289947754a7f729d24df9 (patch) | |
| tree | 987557db868ce0ef845aadab005aeebec8a03ef9 /mat-gui | |
| parent | ea2fce7e6671f6b988ab012be0a08cce9cf9ca17 (diff) | |
The GUI now support command-line file adding (4ZM)
Diffstat (limited to 'mat-gui')
| -rwxr-xr-x | mat-gui | 17 |
1 files changed, 14 insertions, 3 deletions
| @@ -12,6 +12,7 @@ import gettext | |||
| 12 | import locale | 12 | import locale |
| 13 | import logging | 13 | import logging |
| 14 | import os | 14 | import os |
| 15 | import sys | ||
| 15 | import mimetypes | 16 | import mimetypes |
| 16 | import xml.sax | 17 | import 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 | |||
| 642 | if __name__ == '__main__': | 646 | if __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() |
