changeset 198:c344836f4210

* Hopefully fixed the editor's objectselector to work with multiple namespaces again
author nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 12 Mar 2009 17:43:59 +0000
parents 80b3c41c3427
children 4ea1e0b56a07
files clients/editor/plugins/objectselector.py
diffstat 1 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/clients/editor/plugins/objectselector.py	Wed Mar 11 21:09:39 2009 +0000
+++ b/clients/editor/plugins/objectselector.py	Thu Mar 12 17:43:59 2009 +0000
@@ -28,7 +28,7 @@
 		scrollArea = widgets.ScrollArea(size=(200,300))
 		hbox.addChild(scrollArea)
 		self.namespaces = widgets.ListBox()
-		self.namespaces.capture(self.update)
+		self.namespaces.capture(self.update_namespace)
 		self.namespaces.items = self.engine.getModel().getNamespaces()
 		self.namespaces.selected = 0
 		scrollArea.addChild(self.namespaces)
@@ -91,6 +91,7 @@
 			self.objects.items = [obj.getId() for obj in self.engine.getModel().getObjects(self.namespaces.selected_item)]
 			if not self.objects.selected_item:
 				self.objects.selected = 0
+				self.listEntrySelected()
 
 	def listEntrySelected(self):
 		"""This function is used as callback for the TextList."""
@@ -99,7 +100,8 @@
 			self.objectSelected(obj)
 
 	def fillPreviewList(self):
-		for obj in self.engine.getModel().getObjects(self.namespaces.selected_item):
+		objects = self.engine.getModel().getObjects(self.namespaces.selected_item)
+		for obj in objects:
 			image = self._getImage(obj)
 			if image is not None:
 				imagebutton = widgets.ImageButton(up_image=image, down_image=image, hover_image=image)
@@ -109,6 +111,9 @@
 				self.gui.adaptLayout()
 			else:
 				print 'No image available for selected object'
+		if len(objects)>0:
+			self.objectSelected(objects[0])
+
 
 	def objectSelected(self, obj):
 		"""This is used as callback function to notify the editor that a new object has
@@ -118,9 +123,17 @@
 		self.gui.adaptLayout()
 		self.notify(obj)
 
-	def update(self):
+	def update_namespace(self):
 		self.namespaces.items = self.engine.getModel().getNamespaces()
-		self.namespaces.selected = 0
+		if not self.namespaces.selected_item:
+			self.namespaces.selected = 0
+		if self.mode == 'list':
+			self.setTextList()
+		elif self.mode == 'preview':
+			self.setImageList()
+		self.update()
+
+	def update(self):
 		if self.mode == 'list':
 			self.fillTextList()
 		elif self.mode == 'preview':
@@ -159,7 +172,7 @@
 
 
 	def show(self):
-		self.update()
+		self.update_namespace()
 		self.gui.show()
 
 	def hide(self):