Anonymous avatar Anonymous committed 73ee29d

Folder contents are now saved, too.

Comments (0)

Files changed (1)

 	    else: 
 		idx = self.circle.index(label)
 		items = items[:idx] + items[idx + 1:]
-	self.arrange_in_circle(items)
-	self.save_config()
+	self.save_config(items)
 	self.die_on_focus_lost = True
 	
 
 	
 	return items
     
-    def save_config(self): 
-	"""Save the current wheel layout to the config file."""
-	# First we create a temporary copy of the current circle
+    def save_config(self, items): 
+	"""Save the current wheel layout to the config file.
+	
+	@param items: The new layout at any level."""
+	# We roll back the circle to the top level
+	# The center can't change, so we can use the one from the previous version of the circle. 
+	while self.circle[0].action is not None: 
+	    # store items to be able to identify the folder in the lower layout
+	    items_tmp = [(label.icon, label.action) for label in self.circle]
+	    # but replace the first with a generic center. 
+	    items_tmp[0] = ( CENTER_ICON, None )
+	    self.labelClicked(self.circle[0])
+	    # find the folder corresponding to the upper layout. 
+	    items_new = [(label.icon, label.action) for label in self.circle]
+	    for item in items_new: 
+		icon, action = item
+		if action is not None and action[0] == "[" and eval(action) == items_tmp: 
+		    folder_new = items
+		    folder_new[0] = ( CENTER_ICON, None )
+		    idx = items_new.index(item)
+		    item = (icon, str(folder_new))
+		    items_new = items_new[:idx] + [item] + items_new[idx + 1:]
+		    self.arrange_in_circle(items_new)
+		    
 	items_tmp = [(i.icon, i.action) for i in self.circle]
-	# Now we roll back the circle to the top level
-	while self.circle[0].action is not None: 
-	    self.labelClicked(self.circle[0])
-	    # TODO: Make this work for folders. => save changes in the upper layout to the center item. 
-	    # the upper layout (items) equals the evaled content of the correspondig item in the lower layout.
-	# And turn the circle into items. 
-	items = [(i.icon, i.action) for i in self.circle]
 	# Now we copy the previous circle back into the current circle.
 	self.arrange_in_circle(items_tmp)
 	# Finally we prepare the config data
 	config = "# v0.1 keep this line!\n"
-	config += str(items)
+	config += str(items_tmp)
 	# And save it
 	f = open(join(home, CONFIG_FILE_NAME), "w")
 	f.write(config)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.