← Back to team overview

openshot.code team mailing list archive

[Branch ~openshot.code/openshot/main] Rev 498: Added the same file validation checking to the drag/drop import method.

 

------------------------------------------------------------
revno: 498
committer: Andy Finch <we.rocked.in79@xxxxxxxxx>
branch nick: openshot
timestamp: Thu 2011-08-11 21:33:40 +0100
message:
  Added the same file validation checking to the drag/drop import method.
modified:
  openshot/windows/MainGTK.py


--
lp:openshot
https://code.launchpad.net/~openshot.code/openshot/main

Your team OpenShot Code is subscribed to branch lp:openshot.
To unsubscribe from this branch go to https://code.launchpad.net/~openshot.code/openshot/main/+edit-subscription
=== modified file 'openshot/windows/MainGTK.py'
--- openshot/windows/MainGTK.py	2011-08-11 19:23:40 +0000
+++ openshot/windows/MainGTK.py	2011-08-11 20:33:40 +0000
@@ -2478,9 +2478,50 @@
 			# get the file path
 			path = self.project.project_folder.get_file_path_from_dnd_dropped_uri(uri)
 			
+			# The total number of ok files selected (not folders)
+			total_ok_files = 0
+			# The total number of broken files selected (could not be imported)
+			total_broken_files = 0
+			# The total number of files already imported selected
+			total_duplicate_files = 0
+			# The total number of folders selected
+			total_folders = 0
 			# add file to current project
-			self.project.project_folder.AddFile(path, session=timestamp)
-
+			result = self.project.project_folder.AddFile(path, session=timestamp)
+			
+			# parse the results and add to the total
+			total_ok_files += result[0]
+			total_broken_files += result[1]
+			total_duplicate_files += result[2]
+			total_folders += result[3]
+		
+			# The number of total selected files, not including folders
+			total_files = total_ok_files + total_broken_files + total_duplicate_files
+		
+			# print error messages (if needed)
+		
+			if total_files == 0:
+				if total_folders == 1:
+					messagebox.show(_("Empty Folder "), _("The selected folder was empty."))
+				else:
+					messagebox.show(_("Empty Folders"), _("The selected folders were empty."))
+			else:
+				if total_files == total_broken_files:
+					if total_files == 1:
+						messagebox.show(_("Unsupported File Type"), _("OpenShot does not support this file type."))
+					else:
+						messagebox.show(_("Unsupported File Types"), _("OpenShot supports none of the file types of the selected files."))
+			
+				elif total_files == total_duplicate_files:
+					if total_files == 1:
+						messagebox.show(_("Already Imported File"), _("The selected file has already been imported to the project."))
+					else:
+						messagebox.show(_("Already Imported Files"), _("All of the selected files have already been imported to the project."))
+			
+				elif total_ok_files == 0:
+					messagebox.show(_("File Import Error"), _("The selected files either have an unsupported file type or have already been imported to the project."))
+					
+			
 		# refresh the form (i.e. add new items to the treeview)
 		self.refresh_files()