← Back to team overview

openshot.code team mailing list archive

[Branch ~openshot.code/openshot/main] Rev 508: Applied a patch from Emil to fix bug #821380, Right clicking unselected items.

 

------------------------------------------------------------
revno: 508
committer: Andy Finch <we.rocked.in79@xxxxxxxxx>
branch nick: openshot
timestamp: Thu 2011-08-18 22:38:48 +0100
message:
  Applied a patch from Emil to fix bug #821380, Right clicking unselected items.
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-18 20:34:43 +0000
+++ openshot/windows/MainGTK.py	2011-08-18 21:38:48 +0000
@@ -2612,17 +2612,36 @@
 		"""This shows the right click menu"""
 		#print "on_treeFiles_button_press_event"
 		
+		# Right click
 		if (event.button == 3):
-			# determine which item the user right clicked on
-			# path, treecolumn, mouse_x, mouse_y = treeview.get_path_at_pos(int(event.x),int(event.y))
-			# treeview.row_activated(path, treecolumn)
 			
+			results = treeview.get_path_at_pos(int(event.x),int(event.y))
 			# Get the selection
 			selection = treeview.get_selection()
-			# Get the selected path(s)
-			rows, selected = selection.get_selected_rows()
-		   
-			mnu = mnuTree(rows, selected, form=self, project=self.project)
+			# if an item was right clicked
+			if results:
+				
+				# Get the path to the right clicked item
+				path = results[0]
+				
+				# if the item wasn't selected, unselect all items
+				if not selection.path_is_selected(path):
+					selection.unselect_all()
+				
+				# Select the clicked item
+				selection.select_path(path)
+				
+				# Get the model and paths of the selected items
+				model, paths = selection.get_selected_rows()
+				
+				# Item menu
+				mnu = mnuTree(model, paths, form=self, project=self.project)
+			   	
+			else:
+				# Basic menu
+				mnu = mnuTree(None, None, form=self, project=self.project)
+			
+			# Display the menu
 			mnu.showmnu(event, treeview)
 				
 			return True
@@ -2631,13 +2650,32 @@
 	def on_icvFileIcons_button_press_event(self, widget, event, *args):
 		"""This shows the right click menu"""
 
+		#Right click
 		if (event.button == 3):
-			# iconview is active
-			selected = self.icvFileIcons.get_selected_items()
 			model = self.icvFileIcons.get_model()
 			
-			# show the right click menu
-			mnu = mnuTree(model, selected, form=self, project=self.project)
+			# Get the path to the right clicked item
+			path = self.icvFileIcons.get_path_at_pos(int(event.x),int(event.y))
+			
+			# if an item was right clicked
+			if path:
+				# if the item wasn't selected, unselect all items
+				if not self.icvFileIcons.path_is_selected(path):
+					self.icvFileIcons.unselect_all()
+			
+				# Select the clicked item
+				self.icvFileIcons.select_path(path)
+				
+				# Get a list of the paths of all selected items
+				paths = self.icvFileIcons.get_selected_items()
+				
+				# Item menu
+				mnu = mnuTree(model, paths, form=self, project=self.project)
+			else:
+				# Basic menu
+				mnu = mnuTree(None, None, form=self, project=self.project)
+			
+			# Show the right click menu
 			mnu.showmnu(event, widget)
 
 
@@ -4284,7 +4322,7 @@
 		for iter in iters:
 			
 			# get the file object
-			unique_id = self.model.get_value(iter, 4)
+			unique_id = self.model.get_value(iter, 3)
 			f = self.project.project_folder.FindFileByID(unique_id)
 			
 			# get file name, path, and extention