From 18ced164b6a9d84541d289947754a7f729d24df9 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 20 Sep 2011 11:32:45 +0200 Subject: The GUI now support command-line file adding (4ZM) --- mat-gui | 17 ++++++++++++++--- 1 file 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 import locale import logging import os +import sys import mimetypes import xml.sax @@ -275,7 +276,7 @@ data loss, but clean more efficiently')) not_supported.append(item) else: # filename is a regular file if self.add_file_to_treeview(filename): - not_supported.append(item) + not_supported.append(filename) yield True #self.popup_non_supported(not_supported) if len(not_supported): @@ -286,6 +287,10 @@ data loss, but clean more efficiently')) ''' Add a file to the list if it's format is supported ''' + if not os.path.isfile(filename): + # if filename does not exist + return False + cf = CFile(filename, self.backup, self.add2archive) if cf.file is not None: # if the file is supported by the mat self.liststore.append([cf, cf.file.basename, @@ -638,7 +643,6 @@ class TreeViewTooltips(object): name = model[path][0] return name.file.filename - if __name__ == '__main__': #Translations t = gettext.translation('gui', 'locale', fallback=True) @@ -646,5 +650,12 @@ if __name__ == '__main__': t.install() #Main - GUI() + gui = GUI() + + #Add files from command line + infiles = [arg for arg in sys.argv[1:] if os.path.exists(arg)] + if infiles: + task = gui.populate(infiles) + gobject.idle_add(task.next) + gtk.main() -- cgit v1.3