← Back to team overview

openshot.code team mailing list archive

[Branch ~openshot.code/openshot/main] Rev 531: Fixed 2 different regressions on the "Import Transitions" screen and "User Transitions" IconView ...

 

------------------------------------------------------------
revno: 531
committer: Jonathan Thomas <Jonathan.Oomph@xxxxxxxxx>
branch nick: openshot
timestamp: Wed 2011-08-31 22:29:15 -0500
message:
  Fixed 2 different regressions on the "Import Transitions" screen and "User Transitions" IconView code.  The new icon_size preference broke a few things, but now it all works again. =)
modified:
  openshot/windows/IcvTransitions.py
  openshot/windows/ImportTransitions.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/IcvTransitions.py'
--- openshot/windows/IcvTransitions.py	2011-08-31 05:24:34 +0000
+++ openshot/windows/IcvTransitions.py	2011-09-01 03:29:15 +0000
@@ -17,7 +17,7 @@
 #	along with OpenShot Video Editor.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-import gtk, gobject, pango
+import gtk, gobject, pango, shutil
 from classes import project, messagebox
 
 # init the foreign language
@@ -122,18 +122,54 @@
 			
 		#get any user created transitions
 		if os.path.exists(self.project.USER_TRANSITIONS_DIR):
+			
+			# Check for missing icon paths, and create them
+			if not os.path.exists(os.path.join(self.project.USER_TRANSITIONS_DIR, "icons")):
+				os.makedirs(os.path.join(self.project.USER_TRANSITIONS_DIR, "icons"))
+				
+			if not os.path.exists(os.path.join(self.project.USER_TRANSITIONS_DIR, "icons", "small")):
+				os.makedirs(os.path.join(self.project.USER_TRANSITIONS_DIR, "icons", "small"))
+				
+			if not os.path.exists(os.path.join(self.project.USER_TRANSITIONS_DIR, "icons", "medium")):
+				os.makedirs(os.path.join(self.project.USER_TRANSITIONS_DIR, "icons", "medium"))
+			
+			# Get list of user transitions
 			user_list = os.listdir(self.project.USER_TRANSITIONS_DIR)
+			
 			try:
+				
+				# Loop through each user transition (and add it to the IconView)
 				for fname in sorted(user_list):
 					(dirName, file_name) = os.path.split(fname)
 					(fileBaseName, fileExtension)=os.path.splitext(file_name)
-					file_path = os.path.join(self.project.USER_TRANSITIONS_DIR, "icons", fileBaseName + ".png")
-				
+					file_path = os.path.join(self.project.USER_TRANSITIONS_DIR, "icons", icon_size, fileBaseName + ".png")
+					
+					# ignore the 'icons' folder
 					if fileBaseName == "icons":
-						# ignore the 'icons' folder
 						continue
-				
-					# get the pixbuf
+					
+					# verify the icon actually exists
+					if not os.path.exists(file_path):
+
+						# copy the transition into the icon folder
+						shutil.copyfile(os.path.join(self.project.USER_TRANSITIONS_DIR, fname), file_path)
+						
+						# Load pixbuf of transition
+						pbThumb = gtk.gdk.pixbuf_new_from_file(file_path)
+						
+						if icon_size == "small":
+							# resize icon
+							pbThumb = pbThumb.scale_simple(80, 62, gtk.gdk.INTERP_BILINEAR)
+	
+						elif icon_size == "medium":
+							# resize icon
+							pbThumb = pbThumb.scale_simple(120, 96, gtk.gdk.INTERP_BILINEAR)
+							
+						# Save the new icon
+						pbThumb.save(file_path, fileExtension.replace(".", ""), {})
+				
+				
+					# Load the pixbuf
 					pbThumb = gtk.gdk.pixbuf_new_from_file(file_path)
 	
 					# get name of transition

=== modified file 'openshot/windows/ImportTransitions.py'
--- openshot/windows/ImportTransitions.py	2010-08-23 05:35:48 +0000
+++ openshot/windows/ImportTransitions.py	2011-09-01 03:29:15 +0000
@@ -63,49 +63,37 @@
 		pass
 
 	def on_btnOK_clicked(self, widget, *args):
-		pass
-	
-	def on_btnOK_clicked(self, widget, *args):
 		self.import_transition()
 			
 	def import_transition(self):
 		# get translation method
 		_ = self._
 		
+		# Create user directory / transitions folders for the new icon files
 		if not os.path.exists(self.project.USER_TRANSITIONS_DIR):
 			os.makedirs(self.project.USER_TRANSITIONS_DIR)
-			os.makedirs(os.path.join(self.project.USER_TRANSITIONS_DIR, "icons"))
-			
-		#try:
-		# init file paths
-		(dirName, filename) = os.path.split(self.transition_file)
-		(simple_filename, file_extention) = os.path.splitext(filename)
-		new_transition_path = os.path.join(self.project.USER_TRANSITIONS_DIR, filename)
-		new_icon_path = os.path.join(self.project.USER_TRANSITIONS_DIR, "icons", filename)
-		
-		# copy transition & icon into .openshot folder
-		shutil.copyfile(self.transition_file, new_transition_path)
-		shutil.copyfile(self.transition_file, new_icon_path)
-		
-		# Re-size icon
-		pbThumb = gtk.gdk.pixbuf_new_from_file(new_icon_path)
-		pbThumb = pbThumb.scale_simple(80, 62, gtk.gdk.INTERP_BILINEAR)
-		pbThumb.save(new_icon_path, file_extention.replace(".", ""), {})
-		
-		# Refresh the main screen, to show the new transition
-		if self.form.OSTreeTransitions:
-			self.form.OSTreeTransitions.clear()
-			self.form.OSTreeTransitions = None
-		
-		# Switch to transitions tab
-		self.form.nbFiles.set_current_page(0) # switch to files
-		self.form.nbFiles.set_current_page(1) # and then back to transitions
-		
-		messagebox.show("Openshot", _("Transition Imported successfully!"))
-		self.frmImportTransitions.destroy()
-			
-		#except:
-		#	messagebox.show(_("Error!"), _("There was an error importing the Transition!"))
+
+		try:
+			# init file paths
+			(dirName, filename) = os.path.split(self.transition_file)
+			(simple_filename, file_extention) = os.path.splitext(filename)
+			new_transition_path = os.path.join(self.project.USER_TRANSITIONS_DIR, filename)
+	
+			# copy transition & icon into .openshot folder
+			shutil.copyfile(self.transition_file, new_transition_path)
+	
+			# Refresh the main screen, to show the new transition
+			self.form.on_btnTransFilterAll_toggled(None)
+			
+			# Switch to transitions tab
+			self.form.nbFiles.set_current_page(0) # switch to files
+			self.form.nbFiles.set_current_page(1) # and then back to transitions
+			
+			messagebox.show("Openshot", _("Transition Imported successfully!"))
+			self.frmImportTransitions.destroy()
+			
+		except:
+			messagebox.show(_("Error!"), _("There was an error importing the Transition!"))
 		
 		
 def main():