diff options
| author | jvoisin | 2011-07-12 20:14:12 +0200 |
|---|---|---|
| committer | jvoisin | 2011-07-12 20:14:12 +0200 |
| commit | d9e4e5d7215de243458f5745a2b14ff837b430dc (patch) | |
| tree | 7733f68352ea5cafe54dc36b36d7c5469c6a21fa /gui.py | |
| parent | 2f4b24acb02796867a3ee6b8514d0b9d3aac6f94 (diff) | |
mock up of 'clean'
Diffstat (limited to 'gui.py')
| -rw-r--r-- | gui.py | 30 |
1 files changed, 19 insertions, 11 deletions
| @@ -3,14 +3,14 @@ | |||
| 3 | from gi.repository import Gtk, GObject | 3 | from gi.repository import Gtk, GObject |
| 4 | import os | 4 | import os |
| 5 | import cli | 5 | import cli |
| 6 | import mimetypes | ||
| 7 | from lib import mat | 6 | from lib import mat |
| 8 | 7 | ||
| 9 | __version__ = '0.1' | 8 | __version__ = '0.1' |
| 10 | __author__ = 'jvoisin' | 9 | __author__ = 'jvoisin' |
| 11 | 10 | ||
| 12 | SUPPORTED = (('image/png', 'image/jpeg', 'image/gif'), | 11 | SUPPORTED = (('image/png', 'image/jpeg', 'image/gif', |
| 13 | ('*.jpg', '*.jpeg', '*.png', '*.tiff', '*.pdf', | 12 | 'misc/pdf'), |
| 13 | ('*.jpg', '*.jpeg', '*.png', '*.bmp', '*.pdf', | ||
| 14 | '*.tar', '*.tar.bz2', '*.tar.gz', '*.mp3')) | 14 | '*.tar', '*.tar.bz2', '*.tar.gz', '*.mp3')) |
| 15 | 15 | ||
| 16 | class ListStoreApp: | 16 | class ListStoreApp: |
| @@ -68,6 +68,7 @@ class ListStoreApp: | |||
| 68 | toolbar.add(toolbutton) | 68 | toolbar.add(toolbutton) |
| 69 | 69 | ||
| 70 | toolbutton = Gtk.ToolButton(label='Check', stock_id=Gtk.STOCK_FIND) | 70 | toolbutton = Gtk.ToolButton(label='Check', stock_id=Gtk.STOCK_FIND) |
| 71 | toolbutton.connect('clicked', self.clean) | ||
| 71 | toolbar.add(toolbutton) | 72 | toolbar.add(toolbutton) |
| 72 | 73 | ||
| 73 | toolbutton = Gtk.ToolButton(stock_id=Gtk.STOCK_QUIT) | 74 | toolbutton = Gtk.ToolButton(stock_id=Gtk.STOCK_QUIT) |
| @@ -135,23 +136,30 @@ class ListStoreApp: | |||
| 135 | 136 | ||
| 136 | response = chooser.run() | 137 | response = chooser.run() |
| 137 | 138 | ||
| 138 | if response is 0: | 139 | if response is 0: #Gtk.STOCK_OK |
| 139 | filenames = chooser.get_filenames() | 140 | filenames = chooser.get_filenames() |
| 140 | self.populate(filenames) | 141 | self.populate(filenames) |
| 141 | chooser.destroy() | 142 | chooser.destroy() |
| 142 | 143 | ||
| 143 | def populate(self, filenames): | 144 | def populate(self, filenames): |
| 144 | for item in filenames: | 145 | for item in filenames: |
| 145 | name = os.path.basename(item) | ||
| 146 | fileformat = mimetypes.guess_type(item)[0] | ||
| 147 | try: | 146 | try: |
| 148 | class_file = mat.create_class_file(item, self.backup) | 147 | cfile = mat.create_class_file(item, self.backup) |
| 149 | except: | 148 | except: |
| 150 | class_file = None | 149 | cfile = None |
| 151 | 150 | ||
| 152 | if class_file is not None: | 151 | if cfile is not None: |
| 153 | self.files.append(class_file) | 152 | self.files.append(cfile) |
| 154 | self.model.append([name, fileformat, 'dirty']) | 153 | self.model.append([cfile.shortname, cfile.mime, 'unknow']) |
| 154 | |||
| 155 | def clean(self, button): | ||
| 156 | self.model.clear() | ||
| 157 | for item in self.files: | ||
| 158 | if item.is_clean(): | ||
| 159 | string = 'clean' | ||
| 160 | else: | ||
| 161 | string = 'dirty' | ||
| 162 | self.model.append([item.shortname, item.mime, string]) | ||
| 155 | 163 | ||
| 156 | def main(): | 164 | def main(): |
| 157 | app = ListStoreApp() | 165 | app = ListStoreApp() |
