Allowed drag-and-drop reordering of custom places.
This commit is contained in:
		
							parent
							
								
									79ff1b93c9
								
							
						
					
					
						commit
						b43d5ffe9f
					
				| @ -1011,6 +1011,7 @@ | ||||
|                                           <widget class="GtkTreeView" id="customplacestree"> | ||||
|                                             <property name="visible">True</property> | ||||
|                                             <property name="can_focus">True</property> | ||||
|                                             <property name="reorderable">True</property> | ||||
|                                           </widget> | ||||
|                                         </child> | ||||
|                                       </widget> | ||||
|  | ||||
| @ -178,6 +178,10 @@ class mintMenuConfig( object ): | ||||
| 		 | ||||
| 		for count in range( len(self.customplacepaths) ): | ||||
| 			self.customplacestreemodel.append( [ self.customplacenames[count], self.customplacepaths[count] ] ) | ||||
| 
 | ||||
| 		self.customplacestreemodel.connect("row-changed", self.updatePlacesGconf) | ||||
| 		self.customplacestreemodel.connect("row-deleted", self.updatePlacesGconf) | ||||
| 		self.customplacestreemodel.connect("rows-reordered", self.updatePlacesGconf) | ||||
| 		self.customplacestree.set_model( self.customplacestreemodel ) | ||||
| 		self.namescolumn = gtk.TreeViewColumn( 'Name', self.cell, text = 0 ) | ||||
| 		self.placescolumn = gtk.TreeViewColumn( 'Path', self.cell, text = 1 ) | ||||
| @ -273,7 +277,6 @@ class mintMenuConfig( object ): | ||||
| 				 | ||||
| 			if (nextiter != None): | ||||
| 				self.customplacestreemodel.swap(currentiter, lagiter) | ||||
| 				self.updatePlacesGconf() | ||||
| 		 | ||||
| 		return | ||||
| 	 | ||||
| @ -307,7 +310,6 @@ class mintMenuConfig( object ): | ||||
| 			path = newPlacePath.get_text() | ||||
| 			if (name != "" and path !=""): | ||||
| 				self.customplacestreemodel.append( (name, path) ) | ||||
| 				self.updatePlacesGconf() | ||||
| 			 | ||||
| 	def editPlace(self, editButton): | ||||
| 		gladefile = os.path.join( self.path, "mintMenuConfig.glade" ) | ||||
| @ -349,7 +351,6 @@ class mintMenuConfig( object ): | ||||
| 				if (name != "" and path != ""): | ||||
| 					self.customplacestreemodel.set_value(currentiter, 0, name) | ||||
| 					self.customplacestreemodel.set_value(currentiter, 1, path) | ||||
| 					self.updatePlacesGconf() | ||||
| 	 | ||||
| 	def moveDown(self, downButton): | ||||
| 	 | ||||
| @ -360,7 +361,6 @@ class mintMenuConfig( object ): | ||||
| 		 | ||||
| 		if (nextiter != None): | ||||
| 			self.customplacestreemodel.swap(currentiter, nextiter) | ||||
| 			self.updatePlacesGconf() | ||||
| 		 | ||||
| 		return | ||||
| 		 | ||||
| @ -372,7 +372,6 @@ class mintMenuConfig( object ): | ||||
| 		 | ||||
| 		if (currentiter != None): | ||||
| 			self.customplacestreemodel.remove(currentiter) | ||||
| 			self.updatePlacesGconf() | ||||
| 		 | ||||
| 		return | ||||
| 	 | ||||
| @ -382,17 +381,18 @@ class mintMenuConfig( object ): | ||||
| 		else: | ||||
| 			self.placesHeightButton.set_sensitive(False) | ||||
| 		 | ||||
| 	def updatePlacesGconf(self): | ||||
| 		treeiter = self.customplacestreemodel.get_iter_first() | ||||
| 		customplacenames = [ ] | ||||
| 		customplacepaths = [ ] | ||||
| 		while( treeiter != None ): | ||||
| 			customplacenames = customplacenames + [ self.customplacestreemodel.get_value(treeiter, 0 ) ] | ||||
| 			customplacepaths = customplacepaths + [ self.customplacestreemodel.get_value(treeiter, 1 ) ] | ||||
| 			treeiter = self.customplacestreemodel.iter_next(treeiter) | ||||
| 		self.gconfPlaces.set( "list-string", "custom_names", customplacenames) | ||||
| 		self.gconfPlaces.set( "list-string", "custom_paths", customplacepaths) | ||||
| 		return | ||||
| 	def updatePlacesGconf(self, treemodel, path, iter = None, new_order = None): | ||||
| # Do only if not partway though an append operation; Append = insert+change+change and each creates a signal | ||||
| 		if ((iter == None) or (self.customplacestreemodel.get_value(iter, 1) != None)): | ||||
| 			treeiter = self.customplacestreemodel.get_iter_first() | ||||
| 			customplacenames = [ ] | ||||
| 			customplacepaths = [ ] | ||||
| 			while( treeiter != None ): | ||||
| 				customplacenames = customplacenames + [ self.customplacestreemodel.get_value(treeiter, 0 ) ] | ||||
| 				customplacepaths = customplacepaths + [ self.customplacestreemodel.get_value(treeiter, 1 ) ] | ||||
| 				treeiter = self.customplacestreemodel.iter_next(treeiter) | ||||
| 			self.gconfPlaces.set( "list-string", "custom_names", customplacenames) | ||||
| 			self.gconfPlaces.set( "list-string", "custom_paths", customplacepaths) | ||||
| 		 | ||||
| 
 | ||||
| window = mintMenuConfig() | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user