summaryrefslogtreecommitdiff
path: root/mat-gui
diff options
context:
space:
mode:
authorjvoisin2011-08-19 20:36:17 +0200
committerjvoisin2011-08-19 20:36:17 +0200
commitc35483c28bec93ea3df7ac1d99befdbcf2b8a51e (patch)
tree6c76b2a89215ac10be11dee632a9f584481318e0 /mat-gui
parentff67bf22c783b326ec914ea924bec1fad5267842 (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-xmat-gui38
1 files changed, 35 insertions, 3 deletions
diff --git a/mat-gui b/mat-gui
index 1d588fe..19b8444 100755
--- a/mat-gui
+++ b/mat-gui
@@ -20,7 +20,6 @@ __version__ = '0.1'
20__author__ = 'jvoisin' 20__author__ = 'jvoisin'
21 21
22 22
23
24logging.basicConfig(level=mat.LOGGING_LEVEL) 23logging.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 '''