def __addButtonClicked( self, button ) :

		existingNames = [ p[0] for p in self.__pathListing.getPath().children() ]

		name = "New Preset"
		index = 1
		while name in existingNames :
			name = "New Preset %d" % index
			index += 1

		with Gaffer.UndoContext( self.__plug.ancestor( Gaffer.ScriptNode ) ) :
			Gaffer.Metadata.registerPlugValue( self.__plug, "preset:" + name, self.__plug.getValue() )

		self.__pathListing.setSelectedPaths(
			self.__pathListing.getPath().copy().setFromString( "/" + name )
		)

		self.__nameWidget.grabFocus()
		self.__nameWidget.setSelection( 0, len( name ) )

		return True
dataset/ETHPy150Open ImageEngine/gaffer/python/GafferUI/UIEditor.py/_PresetsEditor.__addButtonClicked/original