diff options
| author | jvoisin | 2011-08-19 20:36:17 +0200 |
|---|---|---|
| committer | jvoisin | 2011-08-19 20:36:17 +0200 |
| commit | c35483c28bec93ea3df7ac1d99befdbcf2b8a51e (patch) | |
| tree | 6c76b2a89215ac10be11dee632a9f584481318e0 /mat-gui | |
| parent | ff67bf22c783b326ec914ea924bec1fad5267842 (diff) | |
Popup for non-supported files
Mock up of a nice popup who show to the user which
file are not supported among those he add to the processing list.
Diffstat (limited to 'mat-gui')
| -rwxr-xr-x | mat-gui | 38 |
1 files changed, 35 insertions, 3 deletions
| @@ -20,7 +20,6 @@ __version__ = '0.1' | |||
| 20 | __author__ = 'jvoisin' | 20 | __author__ = 'jvoisin' |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | |||
| 24 | logging.basicConfig(level=mat.LOGGING_LEVEL) | 23 | logging.basicConfig(level=mat.LOGGING_LEVEL) |
| 25 | 24 | ||
| 26 | 25 | ||
| @@ -264,15 +263,20 @@ data loss')) | |||
| 264 | ''' | 263 | ''' |
| 265 | Append selected files by add_file to the self.liststore | 264 | Append selected files by add_file to the self.liststore |
| 266 | ''' | 265 | ''' |
| 266 | not_supported = [] | ||
| 267 | for filename in filenames: # filenames : all selected files/folders | 267 | for filename in filenames: # filenames : all selected files/folders |
| 268 | if os.path.isdir(filename): # if "filename" is a directory | 268 | if os.path.isdir(filename): # if "filename" is a directory |
| 269 | for root, dirs, files in os.walk(filename): | 269 | for root, dirs, files in os.walk(filename): |
| 270 | for item in files: | 270 | for item in files: |
| 271 | path_to_file = os.path.join(root, item) | 271 | path_to_file = os.path.join(root, item) |
| 272 | self.add_file_to_treeview(path_to_file) | 272 | if self.add_file_to_treeview(path_to_file): |
| 273 | not_supported.append(item) | ||
| 273 | else: # filename is a regular file | 274 | else: # filename is a regular file |
| 274 | self.add_file_to_treeview(filename) | 275 | self.add_file_to_treeview(filename) |
| 276 | if self.add_file_to_treeview(path_to_file): | ||
| 277 | not_supported.append(item) | ||
| 275 | yield True | 278 | yield True |
| 279 | self.popup_non_supported(not_supported) | ||
| 276 | yield False | 280 | yield False |
| 277 | 281 | ||
| 278 | def add_file_to_treeview(self, filename): | 282 | def add_file_to_treeview(self, filename): |
| @@ -280,10 +284,38 @@ data loss')) | |||
| 280 | Add a file to the list if his format is supported | 284 | Add a file to the list if his format is supported |
| 281 | ''' | 285 | ''' |
| 282 | cf = CFile(filename, self.backup, self.add2archive) | 286 | cf = CFile(filename, self.backup, self.add2archive) |
| 283 | if cf.file is not None: | 287 | if cf.file is not None: # if the file is supported by the mat |
| 284 | self.liststore.append([cf, cf.file.basename, | 288 | self.liststore.append([cf, cf.file.basename, |
| 285 | cf.file.mime, _('unknow')]) | 289 | cf.file.mime, _('unknow')]) |
| 290 | return False | ||
| 291 | else: | ||
| 292 | return True | ||
| 293 | |||
| 294 | |||
| 295 | def popup_non_supported(self, filelist): | ||
| 296 | dialog = gtk.Dialog(title=_('Not-supported'), parent=self.window, | ||
| 297 | flags=0, buttons=(gtk.STOCK_OK, 0)) | ||
| 298 | vbox = gtk.VBox(spacing=5) | ||
| 299 | dialog.get_content_area().pack_start(vbox, True, True, 0) | ||
| 300 | store = gtk.ListStore(str, str) | ||
| 301 | |||
| 302 | # append filename - mimetype to the store | ||
| 303 | [store.append([item, 'bleh']) for item in filelist] | ||
| 304 | |||
| 305 | treeview = gtk.TreeView(store) | ||
| 306 | vbox.pack_start(treeview, True, True, 0) | ||
| 307 | |||
| 308 | #create column | ||
| 309 | rendererText = gtk.CellRendererText() | ||
| 310 | column = gtk.TreeViewColumn(_('Filename'), rendererText, text=0) | ||
| 311 | treeview.append_column(column) | ||
| 312 | column = gtk.TreeViewColumn(_('Mimetype'), rendererText, text=1) | ||
| 313 | treeview.append_column(column) | ||
| 286 | 314 | ||
| 315 | dialog.show_all() | ||
| 316 | click = dialog.run() | ||
| 317 | if click is 0: # Ok button | ||
| 318 | dialog.destroy() | ||
| 287 | 319 | ||
| 288 | def about(self, button): | 320 | def about(self, button): |
| 289 | ''' | 321 | ''' |
