diff options
| author | jvoisin | 2011-08-03 19:04:20 +0200 |
|---|---|---|
| committer | jvoisin | 2011-08-03 19:04:20 +0200 |
| commit | d885cd9587a701d880049cb5c1b90a2e75c35338 (patch) | |
| tree | 024b3574b138b99a1df781753eb750395067f823 | |
| parent | bc2fb9a3944a013e05c2f84c1e324c35c26a1827 (diff) | |
Add the supported format list to the GUI
| -rw-r--r-- | gui.py | 46 |
1 files changed, 46 insertions, 0 deletions
| @@ -9,6 +9,8 @@ import gobject | |||
| 9 | 9 | ||
| 10 | import os | 10 | import os |
| 11 | import logging | 11 | import logging |
| 12 | import xml.sax | ||
| 13 | |||
| 12 | from lib import mat | 14 | from lib import mat |
| 13 | 15 | ||
| 14 | __version__ = '0.1' | 16 | __version__ = '0.1' |
| @@ -177,6 +179,8 @@ class ListStoreApp: | |||
| 177 | 179 | ||
| 178 | help_menu = self.create_sub_menu('Help', menubar) | 180 | help_menu = self.create_sub_menu('Help', menubar) |
| 179 | self.create_menu_item('About', self.about, help_menu, gtk.STOCK_ABOUT) | 181 | self.create_menu_item('About', self.about, help_menu, gtk.STOCK_ABOUT) |
| 182 | self.create_menu_item('Supported formats', self.supported, help_menu, | ||
| 183 | gtk.STOCK_INFO) | ||
| 180 | 184 | ||
| 181 | return menubar | 185 | return menubar |
| 182 | 186 | ||
| @@ -241,6 +245,48 @@ class ListStoreApp: | |||
| 241 | if click: | 245 | if click: |
| 242 | w.destroy() | 246 | w.destroy() |
| 243 | 247 | ||
| 248 | def supported(self, _): | ||
| 249 | ''' | ||
| 250 | List the supported formats | ||
| 251 | ''' | ||
| 252 | dialog = gtk.Dialog('Supported formats', None, 0, (gtk.STOCK_CLOSE, 0)) | ||
| 253 | content_area = dialog.get_content_area() | ||
| 254 | vbox = gtk.VBox(spacing=5) | ||
| 255 | content_area.pack_start(vbox, True, True, 0) | ||
| 256 | |||
| 257 | label = gtk.Label() | ||
| 258 | label.set_markup('<big><u>Supported fileformats</u></big>') | ||
| 259 | vbox.pack_start(label, True, True, 0) | ||
| 260 | |||
| 261 | #parsing xml | ||
| 262 | handler = mat.XMLParser() | ||
| 263 | parser = xml.sax.make_parser() | ||
| 264 | parser.setContentHandler(handler) | ||
| 265 | with open('FORMATS', 'r') as f: | ||
| 266 | parser.parse(f) | ||
| 267 | |||
| 268 | for item in handler.list: # list of dict : one pict per format | ||
| 269 | #create one expander per format | ||
| 270 | title = '%s (%s)' % (item['name'], item['extension']) | ||
| 271 | support = '\t<b>support</b> : ' + item['support'] | ||
| 272 | metadata = '\n\t<b>metadata</b> : ' + item['metadata'] | ||
| 273 | method = '\n\t<b>method</b> : ' + item['method'] | ||
| 274 | content = support + metadata + method | ||
| 275 | |||
| 276 | if item['support'] == 'partial': | ||
| 277 | content += '\n\t<b>remaining</b> : ' + item['remaining'] | ||
| 278 | |||
| 279 | expander = gtk.Expander(title) | ||
| 280 | vbox.pack_start(expander, False, False, 0) | ||
| 281 | label = gtk.Label() | ||
| 282 | label.set_markup(content) | ||
| 283 | expander.add(label) | ||
| 284 | |||
| 285 | dialog.show_all() | ||
| 286 | click = dialog.run() | ||
| 287 | if click is 0: | ||
| 288 | dialog.destroy() | ||
| 289 | |||
| 244 | def preferences(self, _): | 290 | def preferences(self, _): |
| 245 | ''' | 291 | ''' |
| 246 | Preferences popup | 292 | Preferences popup |
