summaryrefslogtreecommitdiff
path: root/gui.py
diff options
context:
space:
mode:
authorjvoisin2011-07-12 20:14:12 +0200
committerjvoisin2011-07-12 20:14:12 +0200
commitd9e4e5d7215de243458f5745a2b14ff837b430dc (patch)
tree7733f68352ea5cafe54dc36b36d7c5469c6a21fa /gui.py
parent2f4b24acb02796867a3ee6b8514d0b9d3aac6f94 (diff)
mock up of 'clean'
Diffstat (limited to 'gui.py')
-rw-r--r--gui.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/gui.py b/gui.py
index dee6742..e41a3f0 100644
--- a/gui.py
+++ b/gui.py
@@ -3,14 +3,14 @@
3from gi.repository import Gtk, GObject 3from gi.repository import Gtk, GObject
4import os 4import os
5import cli 5import cli
6import mimetypes
7from lib import mat 6from lib import mat
8 7
9__version__ = '0.1' 8__version__ = '0.1'
10__author__ = 'jvoisin' 9__author__ = 'jvoisin'
11 10
12SUPPORTED = (('image/png', 'image/jpeg', 'image/gif'), 11SUPPORTED = (('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
16class ListStoreApp: 16class 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
156def main(): 164def main():
157 app = ListStoreApp() 165 app = ListStoreApp()