diff options
| author | jvoisin | 2011-07-13 17:13:52 +0200 |
|---|---|---|
| committer | jvoisin | 2011-07-13 17:13:52 +0200 |
| commit | bdb6c570e4744e635caa69c8c2b9794ddb3a0b97 (patch) | |
| tree | 00b67295a852932cb990c416c0d3914d7fc9cf22 /gui.py | |
| parent | d9e4e5d7215de243458f5745a2b14ff837b430dc (diff) | |
Folder selection now works
Diffstat (limited to 'gui.py')
| -rw-r--r-- | gui.py | 25 |
1 files changed, 17 insertions, 8 deletions
| @@ -3,6 +3,7 @@ | |||
| 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 glob | ||
| 6 | from lib import mat | 7 | from lib import mat |
| 7 | 8 | ||
| 8 | __version__ = '0.1' | 9 | __version__ = '0.1' |
| @@ -39,10 +40,10 @@ class ListStoreApp: | |||
| 39 | 40 | ||
| 40 | self.model = Gtk.ListStore(str, str, str) #name - type - cleaned | 41 | self.model = Gtk.ListStore(str, str, str) #name - type - cleaned |
| 41 | 42 | ||
| 42 | treeview = Gtk.TreeView(model=self.model) | 43 | self.treeview = Gtk.TreeView(model=self.model) |
| 43 | treeview.set_rules_hint(True) | 44 | self.treeview.set_rules_hint(True) |
| 44 | sw.add(treeview) | 45 | sw.add(self.treeview) |
| 45 | self.add_columns(treeview) | 46 | self.add_columns(self.treeview) |
| 46 | 47 | ||
| 47 | self.statusbar = Gtk.Statusbar() | 48 | self.statusbar = Gtk.Statusbar() |
| 48 | self.statusbar.push(1, 'Ready') | 49 | self.statusbar.push(1, 'Ready') |
| @@ -68,7 +69,7 @@ class ListStoreApp: | |||
| 68 | toolbar.add(toolbutton) | 69 | toolbar.add(toolbutton) |
| 69 | 70 | ||
| 70 | toolbutton = Gtk.ToolButton(label='Check', stock_id=Gtk.STOCK_FIND) | 71 | toolbutton = Gtk.ToolButton(label='Check', stock_id=Gtk.STOCK_FIND) |
| 71 | toolbutton.connect('clicked', self.clean) | 72 | toolbutton.connect('clicked', self.mat_clean) |
| 72 | toolbar.add(toolbutton) | 73 | toolbar.add(toolbutton) |
| 73 | 74 | ||
| 74 | toolbutton = Gtk.ToolButton(stock_id=Gtk.STOCK_QUIT) | 75 | toolbutton = Gtk.ToolButton(stock_id=Gtk.STOCK_QUIT) |
| @@ -138,7 +139,14 @@ class ListStoreApp: | |||
| 138 | 139 | ||
| 139 | if response is 0: #Gtk.STOCK_OK | 140 | if response is 0: #Gtk.STOCK_OK |
| 140 | filenames = chooser.get_filenames() | 141 | filenames = chooser.get_filenames() |
| 141 | self.populate(filenames) | 142 | lst = [] |
| 143 | for item in filenames: | ||
| 144 | #FIXME : not optimal at all | ||
| 145 | if os.path.isdir(item): | ||
| 146 | lst.extend(glob.glob(item + '/*')) | ||
| 147 | else: | ||
| 148 | lst.append(item) | ||
| 149 | self.populate(lst) | ||
| 142 | chooser.destroy() | 150 | chooser.destroy() |
| 143 | 151 | ||
| 144 | def populate(self, filenames): | 152 | def populate(self, filenames): |
| @@ -150,9 +158,9 @@ class ListStoreApp: | |||
| 150 | 158 | ||
| 151 | if cfile is not None: | 159 | if cfile is not None: |
| 152 | self.files.append(cfile) | 160 | self.files.append(cfile) |
| 153 | self.model.append([cfile.shortname, cfile.mime, 'unknow']) | 161 | self.model.append([cfile.filename, cfile.mime, 'unknow']) |
| 154 | 162 | ||
| 155 | def clean(self, button): | 163 | def mat_clean(self, button):#OMFG, I'm so ugly ! |
| 156 | self.model.clear() | 164 | self.model.clear() |
| 157 | for item in self.files: | 165 | for item in self.files: |
| 158 | if item.is_clean(): | 166 | if item.is_clean(): |
| @@ -161,6 +169,7 @@ class ListStoreApp: | |||
| 161 | string = 'dirty' | 169 | string = 'dirty' |
| 162 | self.model.append([item.shortname, item.mime, string]) | 170 | self.model.append([item.shortname, item.mime, string]) |
| 163 | 171 | ||
| 172 | |||
| 164 | def main(): | 173 | def main(): |
| 165 | app = ListStoreApp() | 174 | app = ListStoreApp() |
| 166 | Gtk.main() | 175 | Gtk.main() |
